00001
00002
00003 #ifndef SLAM_MANAGER_TOOLS_HPP
00004 #define SLAM_MANAGER_TOOLS_HPP
00005
00006 #include "jmath/jblas.hpp"
00007
00008 #include "geom/t3dEuler.hpp"
00009
00010 #include "slam/feature.hpp"
00011 #include "slam/bearingOnlyFeature.hpp"
00012 #include "slam/slamEvents.hpp"
00013
00014 namespace jafar {
00015 namespace slampt {
00016
00020 struct DBFrameLandmark {
00021
00022 DBFrameLandmark(std::size_t hpmIndex_,
00023 unsigned int id_) :
00024 hpmIndex(hpmIndex_), id(id_) {};
00025
00027 std::size_t hpmIndex;
00029 unsigned int id;
00030 };
00031
00032 struct LandmarkListRemovePred {
00033 unsigned int id;
00034
00035 LandmarkListRemovePred(unsigned int id_) : id(id_) {}
00036
00037 bool operator()(DBFrameLandmark const& landmark) {
00038 return landmark.id == id;
00039 }
00040
00041 };
00042
00046 struct DBFrame {
00047
00048 typedef std::list<DBFrameLandmark> LandmarksList;
00049
00051 unsigned int index;
00052
00056 geom::T3DEuler pose;
00057
00059 LandmarksList landmarks;
00060
00061 void removeLandmark(unsigned int id_) {
00062 landmarks.remove_if(LandmarkListRemovePred(id_));
00063 }
00064
00065 };
00066
00070 class FrameDataBase : public slam::BoSlamEventAdapter {
00071
00072 protected:
00073
00074 void removeLandmark(unsigned int id) {
00075 JFR_DEBUG("FrameDataBase::removeLandmark: " << id);
00076 for (DBFrameList::iterator it = frameList.begin() ; it != frameList.end() ; ++it) {
00077 it->removeLandmark(id);
00078 }
00079 }
00080
00081 void removeLandmark(slam::BaseFeature const& landmark) {
00082 removeLandmark(landmark.id());
00083 }
00084
00085 void removeTentativeLandmark(slam::InitFeature const& landmark) {
00086 removeLandmark(landmark.id());
00087 }
00088
00089 public:
00090
00091
00092 typedef std::list<DBFrame> DBFrameList;
00093 DBFrameList frameList;
00094
00095 void changeLandmarkId(unsigned int oldId, unsigned int newId,
00096 unsigned int frameIndexBegin, unsigned int frameIndexEnd);
00097
00098 };
00099
00103 struct QualityIndexPoint {
00104
00105 QualityIndexPoint(std::size_t hpmIndex_,
00106 double quality_ = 0.0) :
00107 hpmIndex(hpmIndex_), quality(quality_) {};
00108
00109 std::size_t hpmIndex;
00110 double quality;
00111 };
00112
00113 bool operator<(QualityIndexPoint const& p1, QualityIndexPoint const& p2);
00114
00115 }
00116 }
00117
00118 #endif // SLAM_MANAGER_TOOLS_HPP