| 1427 | } |
| 1428 | |
| 1429 | void 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; |
nothing calls this directly
no test coverage detected