MCPcopy Create free account
hub / github.com/UZ-SLAMLab/ORB_SLAM3 / OptimizeEssentialGraph4DoF

Method OptimizeEssentialGraph4DoF

src/Optimizer.cc:5292–5588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5290}
5291
5292void Optimizer::OptimizeEssentialGraph4DoF(Map* pMap, KeyFrame* pLoopKF, KeyFrame* pCurKF,
5293 const LoopClosing::KeyFrameAndPose &NonCorrectedSim3,
5294 const LoopClosing::KeyFrameAndPose &CorrectedSim3,
5295 const map<KeyFrame *, set<KeyFrame *> > &LoopConnections)
5296{
5297 typedef g2o::BlockSolver< g2o::BlockSolverTraits<4, 4> > BlockSolver_4_4;
5298
5299 // Setup optimizer
5300 g2o::SparseOptimizer optimizer;
5301 optimizer.setVerbose(false);
5302 g2o::BlockSolverX::LinearSolverType * linearSolver =
5303 new g2o::LinearSolverEigen<g2o::BlockSolverX::PoseMatrixType>();
5304 g2o::BlockSolverX * solver_ptr = new g2o::BlockSolverX(linearSolver);
5305
5306 g2o::OptimizationAlgorithmLevenberg* solver = new g2o::OptimizationAlgorithmLevenberg(solver_ptr);
5307
5308 optimizer.setAlgorithm(solver);
5309
5310 const vector<KeyFrame*> vpKFs = pMap->GetAllKeyFrames();
5311 const vector<MapPoint*> vpMPs = pMap->GetAllMapPoints();
5312
5313 const unsigned int nMaxKFid = pMap->GetMaxKFid();
5314
5315 vector<g2o::Sim3,Eigen::aligned_allocator<g2o::Sim3> > vScw(nMaxKFid+1);
5316 vector<g2o::Sim3,Eigen::aligned_allocator<g2o::Sim3> > vCorrectedSwc(nMaxKFid+1);
5317
5318 vector<VertexPose4DoF*> vpVertices(nMaxKFid+1);
5319
5320 const int minFeat = 100;
5321 // Set KeyFrame vertices
5322 for(size_t i=0, iend=vpKFs.size(); i<iend;i++)
5323 {
5324 KeyFrame* pKF = vpKFs[i];
5325 if(pKF->isBad())
5326 continue;
5327
5328 VertexPose4DoF* V4DoF;
5329
5330 const int nIDi = pKF->mnId;
5331
5332 LoopClosing::KeyFrameAndPose::const_iterator it = CorrectedSim3.find(pKF);
5333
5334 if(it!=CorrectedSim3.end())
5335 {
5336 vScw[nIDi] = it->second;
5337 const g2o::Sim3 Swc = it->second.inverse();
5338 Eigen::Matrix3d Rwc = Swc.rotation().toRotationMatrix();
5339 Eigen::Vector3d twc = Swc.translation();
5340 V4DoF = new VertexPose4DoF(Rwc, twc, pKF);
5341 }
5342 else
5343 {
5344 Sophus::SE3d Tcw = pKF->GetPose().cast<double>();
5345 g2o::Sim3 Siw(Tcw.unit_quaternion(),Tcw.translation(),1.0);
5346
5347 vScw[nIDi] = Siw;
5348 V4DoF = new VertexPose4DoF(pKF);
5349 }

Callers

nothing calls this directly

Calls 15

setVerboseMethod · 0.80
setAlgorithmMethod · 0.80
GetMaxKFidMethod · 0.80
findMethod · 0.80
setMarginalizedMethod · 0.80
GetWeightMethod · 0.80
setVertexMethod · 0.80
GetLoopEdgesMethod · 0.80
GetCovisiblesByWeightMethod · 0.80
hasChildMethod · 0.80
computeActiveErrorsMethod · 0.80

Tested by

no test coverage detected