Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
observation.hpp
00001 /* $Id$ */
00002 
00003 #ifndef SLAM_OBSERVATION_HPP
00004 #define SLAM_OBSERVATION_HPP
00005 
00006 #include <ostream>
00007 
00008 #include "jmath/jblas.hpp"
00009 #include "kernel/jafarMacro.hpp"
00010 
00011 namespace jafar {
00012   namespace slam {
00013 
00014 
00019     class Observation {
00020     
00021     public:
00022 
00023       enum ObservationType {
00024         POINT_CARTESIAN,   
00025         POINT_POLAR,       
00026       POINT_STEREOIMAGE, 
00027         POINT_BEARING,     
00028       POINT_IMAGE,       
00029       POINT_OMNIIMAGE,   
00030       SEGMENT_IMAGE,     
00031         SEGMENTAP_IMAGE,     
00032         SEGMENTID_IMAGE,     
00033         SEGMENTID_EXT_IMAGE, 
00034         SEGMENT_STEREOIMAGE,     
00035         BASIS,             
00036         ROBOT              
00037       };
00038 
00039       static std::size_t observationSize(ObservationType ot) {
00040   switch(ot) {
00041   case POINT_CARTESIAN:
00042     return 3;
00043   case POINT_POLAR:
00044     return 3;
00045   case POINT_STEREOIMAGE:
00046     return 3;
00047   case POINT_BEARING:
00048     return 2;
00049   case POINT_IMAGE:
00050     return 2;
00051   case POINT_OMNIIMAGE:
00052     return 2;
00053   case SEGMENT_IMAGE:
00054     return 2;
00055     case SEGMENTAP_IMAGE:
00056       return 2;
00057         case SEGMENTID_IMAGE:
00058             return 2;
00059         case SEGMENTID_EXT_IMAGE:
00060             return 4;
00061         case SEGMENT_STEREOIMAGE:
00062             return 4;
00063         case BASIS:
00064             return 6;
00065         case ROBOT:
00066           return 6;
00067   default:
00068     JFR_RUN_TIME("Undefined observation size for type: " << ot);
00069   }
00070       };
00071 
00072       ObservationType type;
00073 
00076       int sensorId;
00077 
00079       unsigned int id;
00080 
00082       jblas::vec z; 
00083 
00084       
00086       unsigned int robotId;
00087 
00088       Observation(ObservationType type_, unsigned int robotId_ = 0) :
00089         type(type_),
00090         sensorId(),
00091         id(), 
00092         z(observationSize(type)),
00093         robotId(robotId_)
00094       {
00095       }
00096 
00097       Observation(Observation const& obs) :
00098         type(obs.type),
00099         sensorId(obs.sensorId),
00100         id(obs.id),
00101         z(obs.z),
00102         robotId(obs.robotId)
00103       {}
00104 
00105       virtual ~Observation() {}
00106 
00107       inline std::size_t size() const {return z.size();};
00108 
00109       void set(unsigned int id_, const jblas::vec& z_, unsigned int sensorId_ = 0)
00110       {
00111         JFR_PRECOND(z_.size() == z.size(), "Observation::set: invalid size ");
00112         sensorId = sensorId_;
00113         id = id_;
00114         z.assign(z_);
00115       }
00116 
00117 
00118     void set(unsigned int id_,        
00119            const jblas::vec& z_,
00120            unsigned int sensorId_, unsigned int robotId_) {
00121     JFR_PRECOND(z_.size() == z.size(),
00122             "Observation::set: invalid size ");
00123     sensorId = sensorId_;
00124     robotId = robotId_;
00125     id = id_;
00126     z.assign(z_);
00127       }
00128     
00129 
00130     }; // class Observation
00131 
00132     std::ostream& operator <<(std::ostream& s, Observation::ObservationType const& t);
00133     std::ostream& operator <<(std::ostream& s, Observation const& o_);
00134 
00135   } // namespace slam
00136 } // namespace jafar
00137 
00138 
00139 #endif // SLAM_OBSERVATION_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:28 for Jafar by doxygen 1.7.6.1
LAAS-CNRS