MCPcopy Create free account
hub / github.com/PeterFWS/Structure-PLP-SLAM / optimize

Method optimize

src/PLPSLAM/module/loop_bundle_adjuster.cc:68–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66 }
67
68 void loop_bundle_adjuster::optimize(const unsigned int identifier)
69 {
70 spdlog::info("start loop bundle adjustment");
71
72 unsigned int num_exec_loop_BA = 0;
73 {
74 std::lock_guard<std::mutex> lock(mtx_thread_);
75 loop_BA_is_running_ = true;
76 abort_loop_BA_ = false;
77 num_exec_loop_BA = num_exec_loop_BA_;
78 }
79
80 // FW: global BA with point and line
81 const auto global_bundle_adjuster = optimize::global_bundle_adjuster(map_db_, num_iter_, false);
82 global_bundle_adjuster.optimize(identifier, &abort_loop_BA_);
83
84 {
85 std::lock_guard<std::mutex> lock1(mtx_thread_);
86
87 // if count_loop_BA_execution() was called during the loop BA or the loop BA was aborted,
88 // cannot update the map
89 if (num_exec_loop_BA != num_exec_loop_BA_ || abort_loop_BA_)
90 {
91 spdlog::info("abort loop bundle adjustment");
92 loop_BA_is_running_ = false;
93 abort_loop_BA_ = false;
94 return;
95 }
96
97 spdlog::info("finish loop bundle adjustment");
98 spdlog::info("updating the map with pose propagation");
99
100 // stop mapping module
101 mapper_->request_pause();
102 while (!mapper_->is_paused() && !mapper_->is_terminated())
103 {
104 std::this_thread::sleep_for(std::chrono::microseconds(1000));
105 }
106
107 std::lock_guard<std::mutex> lock2(data::map_database::mtx_database_);
108
109 // update the camera pose along the spanning tree from the origin
110 std::list<data::keyframe *> keyfrms_to_check;
111 keyfrms_to_check.push_back(map_db_->origin_keyfrm_);
112 while (!keyfrms_to_check.empty())
113 {
114 auto parent = keyfrms_to_check.front();
115 const Mat44_t cam_pose_wp = parent->get_cam_pose_inv();
116
117 const auto children = parent->graph_node_->get_spanning_children();
118 for (auto child : children)
119 {
120 if (child->loop_BA_identifier_ != identifier)
121 {
122 // if `child` is NOT optimized by the loop BA
123 // propagate the pose correction from the spanning parent
124
125 // parent->child

Callers 6

motion_based_trackMethod · 0.45
bow_match_based_trackMethod · 0.45
relocalizeMethod · 0.45

Calls 15

infoFunction · 0.85
get_cam_pose_invMethod · 0.80
get_spanning_childrenMethod · 0.80
get_cam_poseMethod · 0.80
pop_frontMethod · 0.80
get_all_landmarksMethod · 0.80
update_informationMethod · 0.80
get_PlueckerCoordMethod · 0.80

Tested by

no test coverage detected