Skip to content

Commit

Permalink
fix deadlock in updating costmap (ros-navigation#3109)
Browse files Browse the repository at this point in the history
- isolate processMap from static_layer's lock_guard scope

Signed-off-by: Daisuke Sato <[email protected]>
  • Loading branch information
daisukes committed Aug 21, 2022
1 parent 37789e9 commit a24cfb0
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions nav2_costmap_2d/plugins/static_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,17 +269,18 @@ StaticLayer::interpretValue(unsigned char value)
void
StaticLayer::incomingMap(const nav_msgs::msg::OccupancyGrid::SharedPtr new_map)
{
std::lock_guard<Costmap2D::mutex_t> guard(*getMutex());
if (!map_received_) {
map_received_ = true;
processMap(*new_map);
}
if (update_in_progress_.load()) {
map_buffer_ = new_map;
} else {
processMap(*new_map);
map_buffer_ = nullptr;
{
std::lock_guard<Costmap2D::mutex_t> guard(*getMutex());
if (!map_received_) {
map_received_ = true;
}

if (update_in_progress_.load()) {
map_buffer_ = new_map;
return;
}
}
processMap(*new_map);
}

void
Expand Down

0 comments on commit a24cfb0

Please sign in to comment.