Skip to content

Commit

Permalink
added current controller loop rate logging
Browse files Browse the repository at this point in the history
Signed-off-by: ARK3r <[email protected]>
  • Loading branch information
ARK3r committed Mar 8, 2024
1 parent cc82151 commit af6fd1a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions nav2_controller/src/controller_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ void ControllerServer::computeControl()
{
std::lock_guard<std::mutex> lock(dynamic_params_lock_);

auto start_time = this->now();

RCLCPP_INFO(get_logger(), "Received a goal, begin computing control effort.");

try {
Expand Down Expand Up @@ -479,10 +481,12 @@ void ControllerServer::computeControl()
break;
}

auto cycle_duration = this->now() - start_time;

if (!loop_rate.sleep()) {
RCLCPP_WARN(
get_logger(), "Control loop missed its desired rate of %.4fHz",
controller_frequency_);
get_logger(), "Control loop missed its desired rate of %.4fHz. Current loop rate is %.4f Hz",
controller_frequency_, 1 / cycle_duration.seconds());
}
}
} catch (nav2_core::InvalidController & e) {
Expand Down Expand Up @@ -815,3 +819,4 @@ ControllerServer::dynamicParametersCallback(std::vector<rclcpp::Parameter> param
// This acts as a sort of entry point, allowing the component to be discoverable when its library
// is being loaded into a running process.
RCLCPP_COMPONENTS_REGISTER_NODE(nav2_controller::ControllerServer)

0 comments on commit af6fd1a

Please sign in to comment.