|
18 | 18 | #define timeDiff(start, end) ((end.tv_sec - start.tv_sec) * 1000000 + end.tv_usec - start.tv_usec)
|
19 | 19 | #endif
|
20 | 20 |
|
21 |
| -// #define DEBUG_FLAG |
| 21 | +#define DEBUG_FLAG |
22 | 22 |
|
23 | 23 | MapUpdateModule::MapUpdateModule(
|
24 | 24 | rclcpp::Node * node, std::mutex * ndt_ptr_mutex,
|
@@ -135,23 +135,23 @@ void MapUpdateModule::prefetch_map(const geometry_msgs::msg::Point& position, Nd
|
135 | 135 | #ifdef DEBUG_FLAG
|
136 | 136 | // If the current position is super far from the previous loading position,
|
137 | 137 | // lock and rebuild ndt_ptr_
|
138 |
| - // if (rebuild_) |
139 |
| - // { |
140 |
| - // ndt_ptr_mutex_->lock(); |
141 |
| - // prefetch_map(position, ndt_ptr_); |
142 |
| - // ndt_ptr_mutex_->unlock(); |
143 |
| - // rebuild_ = false; |
144 |
| - // } |
145 |
| - // else |
146 |
| - // { |
| 138 | + if (rebuild_) |
| 139 | + { |
| 140 | + ndt_ptr_mutex_->lock(); |
| 141 | + prefetch_map(position, ndt_ptr_); |
| 142 | + ndt_ptr_mutex_->unlock(); |
| 143 | + rebuild_ = false; |
| 144 | + } |
| 145 | + else |
| 146 | + { |
147 | 147 | // Load map to the secondary_ndt_ptr, which does not require a mutex lock
|
148 | 148 | // Since the update of the secondary ndt ptr and the NDT align (done on
|
149 | 149 | // the main ndt_ptr_) overlap, the latency of updating/alignment reduces partly.
|
150 | 150 | // If the updating is done the main ndt_ptr_, either the update or the NDT
|
151 | 151 | // align will be blocked by the other.
|
152 |
| - // ndt_ptr_mutex_->lock(); |
153 |
| - // prefetch_map(position, ndt_ptr_); |
154 |
| - // ndt_ptr_mutex_->unlock(); |
| 152 | + prefetch_map(position, secondary_ndt_ptr_); |
| 153 | + |
| 154 | + auto tmp = ndt_ptr_; |
155 | 155 |
|
156 | 156 | // // Now lock and update the main ndt_ptr_ by the secondary_ndt_ptr_
|
157 | 157 | // ndt_ptr_mutex_->lock();
|
|
0 commit comments