| 88 | } |
| 89 | |
| 90 | void global_optimization_module::run() |
| 91 | { |
| 92 | spdlog::info("start global optimization module"); |
| 93 | |
| 94 | is_terminated_ = false; |
| 95 | |
| 96 | while (true) |
| 97 | { |
| 98 | std::this_thread::sleep_for(std::chrono::milliseconds(5)); |
| 99 | |
| 100 | // check if termination is requested |
| 101 | if (terminate_is_requested()) |
| 102 | { |
| 103 | // terminate and break |
| 104 | terminate(); |
| 105 | break; |
| 106 | } |
| 107 | |
| 108 | // check if pause is requested |
| 109 | if (pause_is_requested()) |
| 110 | { |
| 111 | // pause and wait |
| 112 | pause(); |
| 113 | // check if termination or reset is requested during pause |
| 114 | while (is_paused() && !terminate_is_requested() && !reset_is_requested()) |
| 115 | { |
| 116 | std::this_thread::sleep_for(std::chrono::milliseconds(3)); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | // check if reset is requested |
| 121 | if (reset_is_requested()) |
| 122 | { |
| 123 | // reset and continue |
| 124 | reset(); |
| 125 | continue; |
| 126 | } |
| 127 | |
| 128 | // if the queue is empty, the following process is not needed |
| 129 | if (!keyframe_is_queued()) |
| 130 | { |
| 131 | continue; |
| 132 | } |
| 133 | |
| 134 | // dequeue the keyframe from the queue -> cur_keyfrm_ |
| 135 | { |
| 136 | std::lock_guard<std::mutex> lock(mtx_keyfrm_queue_); |
| 137 | cur_keyfrm_ = keyfrms_queue_.front(); |
| 138 | keyfrms_queue_.pop_front(); |
| 139 | } |
| 140 | |
| 141 | // not to be removed during loop detection and correction |
| 142 | cur_keyfrm_->set_not_to_be_erased(); |
| 143 | |
| 144 | // pass the current keyframe to the loop detector |
| 145 | loop_detector_->set_current_keyframe(cur_keyfrm_); |
| 146 | |
| 147 | // detect some loop candidate with BoW |
nothing calls this directly
no test coverage detected