HippocampusI.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef HIPPOCAMPUSI_H_DEFINED
00040 #define HIPPOCAMPUSI_H_DEFINED
00041
00042 #include "Component/ModelComponent.H"
00043 #include "Component/ModelParam.H"
00044 #include "Media/FrameSeries.H"
00045 #include "Transport/FrameInfo.H"
00046 #include "Raster/GenericFrame.H"
00047 #include "Image/Image.H"
00048 #include "GUI/XWinManaged.H"
00049 #include "GUI/ImageDisplayStream.H"
00050 #include "Image/Image.H"
00051 #include "Image/Pixels.H"
00052 #include "Ice/RobotBrainObjects.ice.H"
00053 #include "Ice/RobotSimEvents.ice.H"
00054 #include "Ice/IceImageUtils.H"
00055 #include "Ice/SimEventsUtils.H"
00056 #include <IceUtil/Thread.h>
00057
00058 class HippocampusI : public ModelComponent, public RobotBrainObjects::Hippocampus, public IceUtil::Thread
00059 {
00060
00061 public:
00062
00063
00064 struct Landmark
00065 {
00066 std::string name;
00067 double posX;
00068 double posY;
00069 Image<double> cov;
00070
00071 Landmark(std::string n, double x, double y,
00072 Image<double>& c) : name(n), posX(x), posY(y), cov(c) {};
00073
00074 Landmark() : name(""), posX(-1.0), posY(-1.0), cov(Image<double>(2,2,ZEROS)) {};
00075 };
00076
00077 struct Particle
00078 {
00079 float x;
00080 float y;
00081 float theta;
00082 std::map<std::string, Landmark> landmarksDB;
00083 float w;
00084 };
00085
00086
00087 HippocampusI(OptionManager& mgr,
00088 const std::string& descrName = "Hippocampus",
00089 const std::string& tagName = "Hippocampus");
00090 ~HippocampusI();
00091
00092 virtual void run();
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 void evolve();
00109
00110
00111 virtual void updateMessage(const RobotSimEvents::EventMessagePtr& eMsg,
00112 const Ice::Current&);
00113
00114
00115 void init(Ice::CommunicatorPtr ic, Ice::ObjectAdapterPtr adapter);
00116
00117
00118
00119
00120 void displayMap();
00121
00122
00123
00124 void resampleParticles();
00125
00126
00127
00128 void updateParticleObservation(RobotSimEvents::LandmarksMessagePtr landmarksMsg);
00129
00130
00131
00132 void updateParticleSlamObservation(RobotSimEvents::LandmarksMessagePtr landmarksMsg);
00133
00134
00135
00136 void addLandmark(Landmark lm);
00137
00138
00139 void updateParticleMotion(RobotSimEvents::MotionMessagePtr newMotion);
00140
00141
00142
00143 private:
00144 nub::soft_ref<OutputFrameSeries> itsOfs;
00145 Image<PixRGB<byte> > itsMap;
00146 RobotSimEvents::EventsPrx itsEventsPub;
00147 std::vector<SimEventsUtils::TopicInfo> itsTopicsSubscriptions;
00148 Ice::ObjectPrx itsObjectPrx;
00149 RobotSimEvents::StateMessagePtr itsCurrentState;
00150 RobotSimEvents::GPSMessagePtr itsCurrentGPSPos;
00151 RobotSimEvents::MotionMessagePtr itsCurrentMotion;
00152 RobotSimEvents::LandmarksMessagePtr itsCurrentLandmarks;
00153 RobotSimEvents::StateMessagePtr itsLastLandmarkState;
00154
00155 std::vector<Particle> itsParticles;
00156
00157 std::map<std::string, Landmark> itsLandmarkDB;
00158 std::map<std::string, Landmark> itsGTLandmarkDB;
00159
00160
00161
00162
00163 std::vector<float> itsLmDistanceHistory;
00164 float itsLmDistanceMax;
00165
00166 int itsNumParticles;
00167 float itsRangeVariance;
00168 float itsBearingVariance;
00169 int itsFrame;
00170
00171 IceUtil::Mutex itsParticlesMutex;
00172
00173
00174 };
00175
00176 #endif