Task5
orb-slam3的 pangolin gui,工作流:
- new Viewer
// 130 System.cc
if(bUseViewer)
{
mpViewer = new Viewer(this, mpFrameDrawer,mpMapDrawer,mpTracker,strSettingsFile);
// 开了一个新线程,运行pangolin
mptViewer = new thread(&Viewer::Run, mpViewer);
mpTracker->SetViewer(mpViewer);
mpLoopCloser->mpViewer = mpViewer;
mpViewer->both = mpFrameDrawer->both;
}
- Viewer::Run 运行 pangolin
逐行解析
对 Viewer::Run 中的代码进行解析,挑着看。
// 166 Viewer.cc
pangolin::OpenGlMatrix Twc, Twr;
Twc.SetIdentity();
pangolin::OpenGlMatrix Ow; // Oriented with g in the z axis
Ow.SetIdentity();
pangolin::OpenGlMatrix Twwp; // Oriented with g in the z axis, but y and x from camera
Twwp.SetIdentity();
//...
// 188
mpMapDrawer->GetCurrentOpenGLCameraMatrix(Twc,Ow,Twwp);
三个矩阵:
- Twc,slam相机的位姿(旋转+平移)增量
- Twr,slam相机的平移增量
- Twwp,没有用
后面说Twc、Twr的作用。
通过GetCurrentOpenGLCameraMatrix来获得slam相机的位姿增量,更新三个矩阵。
// 195
if(menuFollowCamera && bFollow)
{
if(bCameraView)
s_cam.Follow(Twc);
else
s_cam.Follow(Ow);
}
Follow 是根据位姿矩阵变换观察相机的位置和姿态。 Twc 是slam相机的位姿矩阵增量,它会使观察相机的位置和姿态随着slam相机变动。Ow 只有slam相机的平移,观察相机会跟随slam相机运动,但姿态保持不变。后面的都差不多,就不写了。
if(menuLocalizationMode && !bLocalizationMode)
{
mpSystem->ActivateLocalizationMode();
bLocalizationMode = true;
}
else if(!menuLoca