码迷,mamicode.com
首页 > 其他好文 > 详细

SLAM对象的初始化

时间:2019-09-28 23:34:16      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:cto   影响   pos   map   tab   类型   值传递   cas   ext   

(1) SLAM对象的数据成员

// 传感器的类型
eSensor mSensor;

// ORB 字典 ORBVocabulary
* mpVocabulary;

// 用于重定位与回环检测的关键帧数据库
KeyFrameDatabase* mpKeyFrameDatabase;

// 存放所有关键帧与地图点的指针 Map
* mpMap;

// Tracker
// 1:跟踪局部地图,计算pose
// 2:判断关键帧
// 3:重定位
Tracking* mpTracker;

// Local Mapper
// 管理局部地图
LocalMapping* mpLocalMapper;

// Loop Closer
// 关键帧回环检测
LoopClosing* mpLoopClosing;

// 绘图类(对)
View* mpViewer;
FrameDrawer* mpFrameDrawer;
MapDrawer* mpMapDrawer;

// 跟踪部分在主线中执行,除此之外还有其他三个线程
std::thread* mpLocalMapping;
std::thread* mpLoopClosing;
std::thread* mpViewer;

// 复位标志位
std::mutex; //线程锁
bool mbReset;

// 模式切换标志位
std::mutex mMutexMode;
bool mbActivateLocalizationMode;
bool mbDeactivateLocalizationMode;

// 跟踪标志位
std::mutex mMutexState;
int mTrackingState;
std::vector<MapPoint*> mTrackedMapPoints;
std::vector<cv::KeyPoint> mTrackedKeyPointsUn;

 

(2) SLAM对象的构造函数

初始化列表:
System::System(const string &strVocFile, const string &strSettingsFile, const eSensor sensor, const bool bUseViewer):
  mSensor(sensor), mpViewer(static_cast<View*>(NULL)), mbReset(false), mbActivateLocalizationMode(false), mbDeactivateLocalizationMode(false)

内部成员数据初始化及关联:
mpVocabulary = new ORBVocabulary();
mpVocabulary->loadFromTextFile(strVocFile);

mpKeyFrameDatabase = new KeyFrameDatabase(*mpVocabulary); //注意这里是值传递

mpMap = new Map();

mpFrameDrawer = new FrameDrawer(mpMap);
mpMapDrawer = new MapDrawer(mapMap, strSettingsFile);

// 初始化Tracker
mpTracker = new Tracking(this, mpVocabulary, mpFrameDrawer, mpMapDrawer, mpMap, mpKeyFrameDatabase, strSettingFile, mSensor);

// 开启局部建图线程
mpLocalMapper = new LocalMapping(mpMap, mSensor == MONOCULAR);
mptLocalMapping = new thread(&ORB_SLAM2::LocalMapping::Run, mpLocalMapper);

// 开启回环检测线程
mpLoopCloser = new LoopCloser(mpMap, mpKeyFramDatabase, mpVocabulary, mSensor!=MONOCULAR);
mptLoopClosing = new thread(&ORB_SLAM2::LoopingClosing::Run, mpLoopcloser);

//if (bUseViewer == 1)
mpViewer = new(this, mpFrameDrawer, mpMapDrawer, strSettingsFile);
mptViewer = new thread(&Viewer::Run, mpViewer);
mpTracker->SetViewer(mpViewer);

//三个线程相互影响,相互引用 ("铁三角")
mpTracker->SetLocalMapper(mpLocalMapper);
mpTracker->SetLoopClosing(mpLoopCloser);

mpLocalMapper->SetTracker(mpTracker);
mpLocalMapper->SetLoopCloser(mpLoopCloser);

mpLoopCloser->SetTracker(mpTracker);
mpLoopCloser->SetLocalMapper(mpLocalMapper)

 博客扩展接口

SLAM对象的初始化

标签:cto   影响   pos   map   tab   类型   值传递   cas   ext   

原文地址:https://www.cnblogs.com/npulzb/p/11605189.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!