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 #4171

Merged
merged 8 commits into from
Mar 8, 2024
Merged
Changes from 4 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
10 changes: 8 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();

SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
RCLCPP_INFO(get_logger(), "Received a goal, begin computing control effort.");

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

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

SteveMacenski 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 %.4fHz. Current loop rate is %.4f Hz",
controller_frequency_, 1 / cycle_duration.seconds());
}
}
} catch (nav2_core::InvalidController & e) {
Expand Down Expand Up @@ -815,3 +820,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)

Loading