MapperI.H

00001 #include "Component/ModelOptionDef.H"
00002 #include "Component/ModelComponent.H"
00003 #include "Component/ModelParam.H"
00004 #include "Media/FrameSeries.H"
00005 #include "Transport/FrameInfo.H"
00006 #include "Raster/GenericFrame.H"
00007 #include "Image/Image.H"
00008 #include "GUI/XWinManaged.H"
00009 #include "GUI/ImageDisplayStream.H"
00010 #include "Image/Image.H"
00011 #include "Image/Pixels.H"
00012 #include "Robots/RobotBrain/RobotBrainComponent.H"
00013 #include "Util/Timer.H"
00014 
00015 #include "Ice/RobotBrainObjects.ice.H"
00016 #include "Ice/RobotSimEvents.ice.H"
00017 #include "Ice/IceImageUtils.H"
00018 #include <IceUtil/Thread.h>
00019 
00020 
00021 class MapperI : public RobotBrainComponent
00022 {
00023 public:
00024 
00025   MapperI(int id, OptionManager& mgr,
00026       const std::string& descrName = "Mapper",
00027       const std::string& tagName   = "Mapper");
00028 
00029   ~MapperI();
00030 
00031   virtual void evolve();
00032 
00033   //!Get a message
00034   virtual void updateMessage(const RobotSimEvents::EventMessagePtr& eMsg,
00035       const Ice::Current&);
00036 
00037   virtual void registerTopics();
00038 
00039   //When a new heading/speed reading comes in, this function
00040   //will update the positions of all particles accordingly
00041   void moveParticles(float speed, float heading, uint64 elapsedTicks);
00042 
00043   //Inspect the particle vector and decide on a single position point
00044   //For now, we just average all particles together
00045   Point2D<float> resolvePosition();
00046 
00047   void updateObservation(RobotSimEvents::SeaBeeObjectType obsObjType,
00048                          bool forwardCamera,
00049                          ImageIceMod::Point3DIce obsObjectPosition,
00050                          ImageIceMod::Point3DIce obsObjectVariance);
00051 typedef struct
00052   {
00053     Point2D<float>   pos;
00054     Point2D<float> variance;
00055     RobotSimEvents::SeaBeeObjectType type;
00056 
00057   } MapObject;
00058 
00059 private:
00060 
00061   //Simple structure to keep track of the position estimates
00062   typedef struct
00063   {
00064     Point2D<float> pos;                     //Position of a particle
00065 
00066     double P;                               //Probability of the particle
00067   } Particle;
00068 
00069   std::vector<Particle> itsParticles;       //A vector of coordinates with associated probabilities indicating
00070                                             //a sparse probability distribution of our current location
00071 
00072   std::vector<MapObject> itsMap;             //A vector representing our knowledge of the map
00073 
00074 
00075   IceUtil::Mutex         itsParticlesMutex;  //A lock to make sure that only one thread accesses the particle
00076                                              //vector at a time
00077 
00078   Timer                   itsSampleTimer;    //A timer to keep track of when our last measurement was recieved -
00079                                              //Useful for calculating distances from speeds
00080 
00081   OModelParam<int>   itsNumParticles;
00082   OModelParam<float> itsHeadingVariance;
00083   OModelParam<float> itsSpeedVariance;
00084 };
00085 
00086 
00087 
Generated on Sun May 8 08:41:38 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3