Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions nav2_controller/src/controller_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,12 +518,18 @@ void ControllerServer::computeControl()
// Don't compute a trajectory until costmap is valid (after clear costmap)
rclcpp::Rate r(100);
auto waiting_start = now();
bool was_waiting = !costmap_ros_->isCurrent();
while (!costmap_ros_->isCurrent()) {
if (now() - waiting_start > params_->costmap_update_timeout) {
throw nav2_core::ControllerTimedOut("Costmap timed out waiting for update");
}
r.sleep();
}
if (was_waiting) {
RCLCPP_INFO(
get_logger(), "Local costmap became current after %.3f s",
(now() - waiting_start).seconds());
}

updateGlobalPath();

Expand Down
1 change: 1 addition & 0 deletions nav2_costmap_2d/plugins/static_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ StaticLayer::incomingMap(const nav_msgs::msg::OccupancyGrid::ConstSharedPtr & ne
}
std::lock_guard<Costmap2D::mutex_t> guard(*getMutex());
map_buffer_ = new_map;
current_ = false;
}

void
Expand Down
7 changes: 7 additions & 0 deletions nav2_planner/src/planner_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,18 @@ bool PlannerServer::isServerInactive(
void PlannerServer::waitForCostmap()
{
if (params_->costmap_update_timeout > rclcpp::Duration(0, 0)) {
auto waiting_start = now();
bool was_waiting = !costmap_ros_->isCurrent();
try {
costmap_ros_->waitUntilCurrent(params_->costmap_update_timeout);
} catch (const std::runtime_error & ex) {
throw nav2_core::PlannerTimedOut(ex.what());
}
if (was_waiting) {
RCLCPP_INFO(
get_logger(), "Global costmap became current after %.3f s",
(now() - waiting_start).seconds());
}
}
}

Expand Down
Loading