Skip to content

Commit e2343c9

Browse files
author
Felix Exner
committed
Improve duration output
1 parent 5cca2f9 commit e2343c9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ur_controllers/src/passthrough_trajectory_controller.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,7 @@ controller_interface::return_type PassthroughTrajectoryController::update(const
296296

297297
// When the trajectory is finished, report the goal as successful to the client.
298298
} else if (current_transfer_state == TRANSFER_STATE_DONE) {
299-
std::shared_ptr<control_msgs::action::FollowJointTrajectory::Result> result =
300-
std::make_shared<control_msgs::action::FollowJointTrajectory::Result>();
299+
auto result = active_goal->preallocated_result_;
301300
// Check if the actual position complies with the tolerances given.
302301
if (!check_goal_tolerance()) {
303302
result->error_code = control_msgs::action::FollowJointTrajectory::Result::GOAL_TOLERANCE_VIOLATED;
@@ -317,10 +316,12 @@ controller_interface::return_type PassthroughTrajectoryController::update(const
317316
end_goal();
318317
} else {
319318
result->error_code = control_msgs::action::FollowJointTrajectory::Result::SUCCESSFUL;
319+
result->error_string = "Trajectory executed successfully in " +
320+
std::to_string(active_trajectory_elapsed_time_.seconds()) +
321+
" (scaled) seconds! The real time needed for execution could be longer.";
320322
active_goal->setSucceeded(result);
321323
end_goal();
322-
RCLCPP_INFO(get_node()->get_logger(), "Trajectory executed successfully in %f seconds!",
323-
active_trajectory_elapsed_time_.seconds());
324+
RCLCPP_INFO(get_node()->get_logger(), "%s", result->error_string.c_str());
324325
}
325326
} else if (current_transfer_state == TRANSFER_STATE_IN_MOTION) {
326327
// Keep track of how long the trajectory has been executing, if it takes too long, send a warning.

0 commit comments

Comments
 (0)