Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nav2_controller: add loop rate log #4228

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Changes from 1 commit
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
9 changes: 7 additions & 2 deletions nav2_controller/src/controller_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ void ControllerServer::computeControl()
last_valid_cmd_time_ = now();
rclcpp::WallRate loop_rate(controller_frequency_);
while (rclcpp::ok()) {
auto start_time = this->now();

if (action_server_ == nullptr || !action_server_->is_server_active()) {
RCLCPP_DEBUG(get_logger(), "Action server unavailable or inactive. Stopping.");
return;
Expand Down Expand Up @@ -479,10 +481,13 @@ void ControllerServer::computeControl()
break;
}

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

ARK3r marked this conversation as resolved.
Show resolved Hide resolved
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 %.4f Hz. Current loop rate is %.4f Hz.",
controller_frequency_, 1 / cycle_duration.seconds());
}
}
} catch (nav2_core::InvalidController & e) {
Expand Down
Loading