MRXT: The Multi-Robot eXploration Tool
Multi-Robot autonomous exploration and mapping simulator.
include/architecture/slam/mapdata/visualMap.h
00001 /*
00002 *
00003 * Author: Miguel Julia <mjulia@umh.es> 
00004 * 
00005 * Date:   2008
00006 * 
00007 * Class visualMap
00008 *
00009 *
00010 */
00011 
00012 #pragma once
00013 #ifndef __VISUAL_MAP__
00014 #define __VISUAL_MAP__
00015 
00016 #include <string.h>
00017 #include <opencv2/opencv.hpp>
00018 #include "landmarksData.h"
00019 #include "matFuns.h"
00020 #include "ConfigFile.h"
00021 #include <loki/Factory.h>
00022 #include <loki/Typelist.h>
00023 #include <loki/Functor.h>
00024 
00025 /**
00026 * @brief Implements a visual landmark 3d map
00027 *
00028 */
00029 class visualMap {
00030 
00031 ///////////////////////////////////////////////////////////////////////
00032 //-------------------------  Attributes  ------------------------------
00033 ///////////////////////////////////////////////////////////////////////
00034 protected:
00035 
00036         unsigned short nlandmarks;
00037 
00038         float camx;                                     /// camera position
00039         float camy;                                     /// camera position
00040         float camz;                                     /// camera position
00041         float rx;                                       /// camera position
00042         float ry;                                       /// camera position
00043         float rz;                                       /// camera position
00044 
00045 //      float range;
00046         float mahTh;
00047         float descTh;
00048 
00049 //--------------------------------------------------------------------- 
00050 ///////////////////////////////////////////////////////////////////////
00051 
00052 ///////////////////////////////////////////////////////////////////////
00053 //-------------------------  Methods  ---------------------------------
00054 ///////////////////////////////////////////////////////////////////////
00055 
00056 public:
00057         
00058         /// default constructor
00059         visualMap();
00060         /// constructor
00061         visualMap(int n, const ConfigFile& config);
00062         /// copy constructor
00063         visualMap(const visualMap&);
00064         /// destructor
00065         virtual ~visualMap();
00066         
00067         /// initializer
00068         void initialize(int n, const ConfigFile& config);
00069         /// assignment operator
00070         virtual visualMap& operator=(const visualMap&);
00071         /// clone method
00072         virtual visualMap* clone() const=0;     
00073 
00074         /// Data functions
00075         virtual void addLandmark(const landmark& mark)=0;
00076         /// return the number of features in the map
00077         int getNLandmarks() const;
00078         
00079         /// data association, return a NEW copy of the matched mark in the map, the returned mark must be DELETE
00080         virtual landmark* dataAssociation(const matrix& ZT, const matrix& Rt, const pos3d& globalpos, const pose& robotPos, const matrix& H, const matrix& Htrans, const float* desc)=0;
00081         /// return return a NEW copy of the landmark with descriptor desc, the returned mark must be DELETE
00082         virtual landmark* getLandmarkByDesc(const float* desc)=0;
00083         /// return return a NEW copy of the landmark with id number, the returned mark must be DELETE
00084         virtual landmark* getLandmarkById(int number)=0;                        
00085         /// changes a landmark 
00086         void changeLandmark(int id, const landmark& mark);
00087         /// changes a landmark 
00088         virtual void changeLastReturnedLandmark(const landmark& mark)=0;
00089         /// return the last returned id
00090         virtual int returnLastReturnedId() const =0;
00091 
00092         /// clear the map
00093         virtual void clear()=0;
00094         /// saves the map
00095         virtual void saveMap(const char* str)=0;
00096         /// draw the features in an opencv image
00097         virtual void drawMarks (IplImage& im, float xorigin, float yorigin, float resolution)=0;
00098         
00099         /// distance between descriptors
00100         static float descDist(const float* desc1, const float* desc2, int desclength);
00101         /// mahalanobis distance
00102         static float mahalanobis(const pos3d& pos, const matrix& sigma);
00103 
00104         /// translates a position in the camera frame of reference to the robot's frame of reference
00105         pos3d cam2base(const pos3d& p) const;
00106         /// translates a position in the robot's frame of reference to the camera frame of reference
00107         pos3d base2cam(const pos3d& p) const;
00108         
00109 //--------------------------------------------------------------------- 
00110 ///////////////////////////////////////////////////////////////////////
00111 };
00112 
00113 inline int visualMap::getNLandmarks() const             {return nlandmarks;}
00114 
00115 
00116 typedef Loki::Functor<visualMap*, LOKI_TYPELIST_2(int,const ConfigFile&)> visualMapCreator;
00117 typedef Loki::SingletonHolder< Loki::Factory< visualMap, int, LOKI_TYPELIST_2(int,const ConfigFile&)> > visualMapFactory;
00118 
00119 
00120 #endif
 All Classes Functions Variables Typedefs