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

Method ScaleRefinement

src/LocalMapping.cc:1429–1496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1427}
1428
1429void LocalMapping::ScaleRefinement()
1430{
1431 // Minimum number of keyframes to compute a solution
1432 // Minimum time (seconds) between first and last keyframe to compute a solution. Make the difference between monocular and stereo
1433 // unique_lock<mutex> lock0(mMutexImuInit);
1434 if (mbResetRequested)
1435 return;
1436
1437 // Retrieve all keyframes in temporal order
1438 list<KeyFrame*> lpKF;
1439 KeyFrame* pKF = mpCurrentKeyFrame;
1440 while(pKF->mPrevKF)
1441 {
1442 lpKF.push_front(pKF);
1443 pKF = pKF->mPrevKF;
1444 }
1445 lpKF.push_front(pKF);
1446 vector<KeyFrame*> vpKF(lpKF.begin(),lpKF.end());
1447
1448 while(CheckNewKeyFrames())
1449 {
1450 ProcessNewKeyFrame();
1451 vpKF.push_back(mpCurrentKeyFrame);
1452 lpKF.push_back(mpCurrentKeyFrame);
1453 }
1454
1455 const int N = vpKF.size();
1456
1457 mRwg = Eigen::Matrix3d::Identity();
1458 mScale=1.0;
1459
1460 std::chrono::steady_clock::time_point t0 = std::chrono::steady_clock::now();
1461 Optimizer::InertialOptimization(mpAtlas->GetCurrentMap(), mRwg, mScale);
1462 std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now();
1463
1464 if (mScale<1e-1) // 1e-1
1465 {
1466 cout << "scale too small" << endl;
1467 bInitializing=false;
1468 return;
1469 }
1470
1471 Sophus::SO3d so3wg(mRwg);
1472 // Before this line we are not changing the map
1473 unique_lock<mutex> lock(mpAtlas->GetCurrentMap()->mMutexMapUpdate);
1474 std::chrono::steady_clock::time_point t2 = std::chrono::steady_clock::now();
1475 if ((fabs(mScale-1.f)>0.002)||!mbMonocular)
1476 {
1477 Sophus::SE3f Tgw(mRwg.cast<float>().transpose(),Eigen::Vector3f::Zero());
1478 mpAtlas->GetCurrentMap()->ApplyScaledRotation(Tgw,mScale,true);
1479 mpTracker->UpdateFrameIMU(mScale,mpCurrentKeyFrame->GetImuBias(),mpCurrentKeyFrame);
1480 }
1481 std::chrono::steady_clock::time_point t3 = std::chrono::steady_clock::now();
1482
1483 for(list<KeyFrame*>::iterator lit = mlNewKeyFrames.begin(), lend=mlNewKeyFrames.end(); lit!=lend; lit++)
1484 {
1485 (*lit)->SetBadFlag();
1486 delete *lit;

Callers

nothing calls this directly

Calls 10

GetCurrentMapMethod · 0.80
transposeMethod · 0.80
ApplyScaledRotationMethod · 0.80
UpdateFrameIMUMethod · 0.80
GetImuBiasMethod · 0.80
IncreaseChangeIndexMethod · 0.80
sizeMethod · 0.45
SetBadFlagMethod · 0.45
clearMethod · 0.45
GetMapMethod · 0.45

Tested by

no test coverage detected