(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Implementing an Observation Layer

Description: C++ Walkthrough

Tutorial Level:

Next Tutorial: Implementing a Control Layer

Note: If your decision-making problem is fully observable (MDPs, SMDPs, etc.), then you don't need an observation layer.

An example of the implementation of a simple Observation Layer in ROS will now be analyzed. In this example, there is a single observation factor, defined over events which are associated to a robot's task of patrolling its environment for fires.

   1 #include <markov_decision_making/ObservationLayer.h>
   2 
   3 using namespace ros;
   4 using namespace markov_decision_making;
   5 
   6 int main (int argc, char** argv)
   7 {
   8   init (argc, argv, "observation_layer_example");
   9   
  10   ObservationLayer ol;
  11   ol.addObservationFactor (ObservationDep()
  12                            .add ("Elevator Hallway Clear")
  13                            .add ("West Corridor Clear")
  14                            .add ("Coffee Room Clear")
  15                            .add ("South Corridor Clear")
  16                            .add ("LRM Clear")
  17                            .add ("Soccer Field Clear")
  18                            .add ("Found Fire"));
  19                            
  20   spin();
  21   
  22   return 0;
  23 }

Breaking down the code:

   1 ObservationLayer ol;

This declares an Observation Layer which silently subscribes to event topics coming from Predicate Manager (~/event_updates and ~/event_map). The Observation Layer isn't started until the spin() function is called. Before that is done, however, the observation space description must be provided.

   1 ol.addObservationFactor (ObservationDep()
   2                          .add ("Elevator Hallway Clear")
   3                          .add ("West Corridor Clear")
   4                          .add ("Coffee Room Clear")
   5                          .add ("South Corridor Clear")
   6                          .add ("LRM Clear")
   7                          .add ("Soccer Field Clear")
   8                          .add ("Found Fire"));  

This creates our observation factor and associates it to a set of named events (which will be flowing in from ~/event_updates). As before, indexes start at 0 -- the output of this Observation Layer is the index 0 when the event "Elevator Hallway Clear" is received.

While spinning, the resulting observation is published to the ~/observation topic, whenever one of the associated events is caught. The Observation Layer also listens in the ~/observation_metadata topic for incoming observation space descriptions from associated Control Layers, for validation purposes.

Wiki: markov_decision_making/Tutorials/Implementing an Observation Layer (last edited 2015-07-16 12:23:15 by JoaoMessias)