00001
00009 #ifndef MAPMANAGER_HPP_
00010 #define MAPMANAGER_HPP_
00011
00012 #include <list>
00013
00014 #include "rtslam/parents.hpp"
00015 #include "rtslam/mapAbstract.hpp"
00016 #include "rtslam/landmarkFactory.hpp"
00017 #include "rtslam/spaceGrid.hpp"
00018
00019
00020 namespace jafar {
00021 namespace rtslam {
00022
00023 class LandmarkAbstract;
00024 class DataManagerAbstract;
00025
00031 class MapManagerAbstract:
00032 public ParentOf<LandmarkAbstract>,
00033 public ParentOf<DataManagerAbstract>,
00034 public ChildOf<MapAbstract>,
00035 public boost::enable_shared_from_this<MapManagerAbstract>
00036 {
00037 public:
00038
00039 ENABLE_LINK_TO_PARENT(MapAbstract,Map,MapManagerAbstract);
00040
00041 ENABLE_ACCESS_TO_PARENT(MapAbstract,map);
00042
00043 ENABLE_ACCESS_TO_CHILDREN(LandmarkAbstract,Landmark,landmark);
00044
00045 ENABLE_ACCESS_TO_CHILDREN(DataManagerAbstract,DataManager,dataManager);
00046
00047 protected:
00048 landmark_factory_ptr_t lmkFactory;
00049 public:
00050 MapManagerAbstract(landmark_factory_ptr_t lmkFactory):
00051 lmkFactory(lmkFactory) {}
00052 virtual ~MapManagerAbstract(void) {
00053 }
00057 virtual bool mapSpaceForInit() {
00058 return mapPtr()->unusedStates(lmkFactory->sizeInit());
00059 }
00063 observation_ptr_t createNewLandmark(data_manager_ptr_t dmaOrigin);
00064 void reparametrizeLandmark(landmark_ptr_t lmkIter);
00065 LandmarkList::iterator reparametrizeLandmark(LandmarkList::iterator lmkIter)
00066 {
00067 landmark_ptr_t lmkPtr = *lmkIter;
00068 lmkIter++;
00069 reparametrizeLandmark(lmkPtr);
00070 lmkIter--;
00071 return lmkIter;
00072 }
00073 void unregisterLandmark(landmark_ptr_t lmkPtr, bool liberateFilter = true);
00074 LandmarkList::iterator unregisterLandmark(LandmarkList::iterator lmkIter, bool liberateFilter = true)
00075 {
00076 landmark_ptr_t lmkPtr = *lmkIter;
00077 lmkIter++;
00078 unregisterLandmark(lmkPtr, liberateFilter);
00079 lmkIter--;
00080 return lmkIter;
00081 }
00082
00086 virtual void manage(void) = 0;
00093 virtual bool isExclusive(observation_ptr_t obsPtr) = 0;
00094 };
00095
00096
00101 class MapManager: public MapManagerAbstract {
00102 protected:
00103 double reparTh;
00104 double killSizeTh;
00105 protected:
00106 virtual void manageReparametrization();
00107 virtual void manageDefaultDeletion();
00108 virtual void manageDeletion() {};
00109 public:
00110 MapManager(landmark_factory_ptr_t lmkFactory, double reparTh = 0.1, double killSizeTh = 100000):
00111 MapManagerAbstract(lmkFactory), reparTh(reparTh), killSizeTh(killSizeTh) {}
00112 virtual ~MapManager(void) {}
00113
00114 virtual void manage()
00115 {
00116 manageDefaultDeletion();
00117 manageDeletion();
00118 manageReparametrization();
00119 }
00120
00121 virtual bool isExclusive(observation_ptr_t obsPtr)
00122 {
00123 return true;
00124 }
00125 };
00126
00127
00131 class MapManagerGrid: public MapManager {
00132 protected:
00133 struct Cell { std::list<landmark_ptr_t> landmarks; };
00134
00135 SphericalGrid<Cell> grid_visible_updated;
00136 SphericalGrid<Cell> grid_visible_failed;
00137
00138 protected:
00139 void fillGrids();
00140 void processGrid(SphericalGrid<Cell> & grid);
00141
00142 public:
00143 MapManagerGrid(landmark_factory_ptr_t lmkFactory, double reparTh, double killSizeTh,
00144 double gridAngularRes, double gridDistInit, double gridDistFactor, int gridNDist, double gridPhiFactor):
00145 MapManager(lmkFactory, reparTh, killSizeTh),
00146 grid_visible_updated(gridAngularRes, gridDistInit, gridDistFactor, gridNDist, gridPhiFactor),
00147 grid_visible_failed(gridAngularRes, gridDistInit, gridDistFactor, gridNDist, gridPhiFactor)
00148 {}
00149 virtual void manageDeletion();
00150 };
00151
00152
00158 class MapManagerOdometry: public MapManagerGrid {
00159 public:
00160 MapManagerOdometry(landmark_factory_ptr_t lmkFactory, double reparTh, double killSizeTh,
00161 double gridAngularRes, double gridDistInit, double gridDistFactor, int gridNDist, double gridPhiFactor):
00162 MapManagerGrid(lmkFactory, reparTh, killSizeTh, gridAngularRes, gridDistInit, gridDistFactor, gridNDist, gridPhiFactor)
00163 {}
00164 virtual void manageDeletion();
00165 virtual bool isExclusive(observation_ptr_t obsPtr);
00166 };
00167
00168
00179 class MapManagerGlobal: public MapManagerGrid {
00180 protected:
00181 double killSearchTh;
00182 double killMatchTh;
00183 double killConsistencyTh;
00184 double killUncertaintyTh;
00185
00186 SphericalGrid<MapManagerGrid::Cell> grid_invisible;
00187
00188 protected:
00189 void fillGrids(bool fill_visible);
00190
00191 public:
00192 MapManagerGlobal(landmark_factory_ptr_t lmkFactory, double reparTh, double killSizeTh,
00193 double killSearchTh, double killMatchTh, double killConsistencyTh, double killUncertaintyTh,
00194 double gridAngularRes, double gridDistInit, double gridDistFactor, int gridNDist, double gridPhiFactor):
00195 MapManagerGrid(lmkFactory, reparTh, killSizeTh, gridAngularRes, gridDistInit, gridDistFactor, gridNDist, gridPhiFactor),
00196 killSearchTh(killSearchTh), killMatchTh(killMatchTh), killConsistencyTh(killConsistencyTh), killUncertaintyTh(killUncertaintyTh),
00197 grid_invisible(gridAngularRes, gridDistInit, gridDistFactor, gridNDist, gridPhiFactor)
00198 {}
00199 virtual void manageDeletion();
00200 virtual bool mapSpaceForInit();
00201 virtual bool isExclusive(observation_ptr_t obsPtr);
00202 };
00203
00204
00209 class MapManagerLocal: public MapManager {
00210 public:
00211 MapManagerLocal(landmark_factory_ptr_t lmkFactory, double reparTh, double killSizeTh):
00212 MapManager(lmkFactory, reparTh, killSizeTh) {}
00213 virtual void manageDeletion()
00214 {
00215
00216 }
00217 };
00218
00219
00220 }
00221 }
00222
00223 #endif // #ifndef MAPMANAGER_HPP_