Skip to content

Commit 19e3f46

Browse files
authored
nav2_controller: add loop rate log (#4228)
* added current loop rate printout Signed-off-by: ARK3r <[email protected]> * remove empty line Signed-off-by: ARK3r <[email protected]> --------- Signed-off-by: ARK3r <[email protected]>
1 parent 63b6d90 commit 19e3f46

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

nav2_controller/src/controller_server.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,8 @@ void ControllerServer::computeControl()
452452
last_valid_cmd_time_ = now();
453453
rclcpp::WallRate loop_rate(controller_frequency_);
454454
while (rclcpp::ok()) {
455+
auto start_time = this->now();
456+
455457
if (action_server_ == nullptr || !action_server_->is_server_active()) {
456458
RCLCPP_DEBUG(get_logger(), "Action server unavailable or inactive. Stopping.");
457459
return;
@@ -479,10 +481,12 @@ void ControllerServer::computeControl()
479481
break;
480482
}
481483

484+
auto cycle_duration = this->now() - start_time;
482485
if (!loop_rate.sleep()) {
483486
RCLCPP_WARN(
484-
get_logger(), "Control loop missed its desired rate of %.4fHz",
485-
controller_frequency_);
487+
get_logger(),
488+
"Control loop missed its desired rate of %.4f Hz. Current loop rate is %.4f Hz.",
489+
controller_frequency_, 1 / cycle_duration.seconds());
486490
}
487491
}
488492
} catch (nav2_core::InvalidController & e) {

0 commit comments

Comments
 (0)