Skip to content

Commit 4c6d723

Browse files
[JTC] Add console output for tolerance checks (#932)
1 parent 6911750 commit 4c6d723

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

joint_trajectory_controller/include/joint_trajectory_controller/tolerances.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ inline bool check_state_tolerance_per_joint(
150150
if (show_errors)
151151
{
152152
const auto logger = rclcpp::get_logger("tolerances");
153-
RCLCPP_ERROR(logger, "Path state tolerances failed:");
153+
RCLCPP_ERROR(logger, "State tolerances failed for joint %d:", joint_idx);
154154

155155
if (state_tolerance.position > 0.0 && abs(error_position) > state_tolerance.position)
156156
{

joint_trajectory_controller/src/joint_trajectory_controller.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,20 +247,21 @@ controller_interface::return_type JointTrajectoryController::update(
247247

248248
// Always check the state tolerance on the first sample in case the first sample
249249
// is the last point
250+
// print output per default, goal will be aborted afterwards
250251
if (
251-
(before_last_point || first_sample) &&
252+
(before_last_point || first_sample) && *(rt_is_holding_.readFromRT()) == false &&
252253
!check_state_tolerance_per_joint(
253-
state_error_, index, default_tolerances_.state_tolerance[index], false) &&
254-
*(rt_is_holding_.readFromRT()) == false)
254+
state_error_, index, default_tolerances_.state_tolerance[index],
255+
true /* show_errors */))
255256
{
256257
tolerance_violated_while_moving = true;
257258
}
258259
// past the final point, check that we end up inside goal tolerance
259260
if (
260-
!before_last_point &&
261+
!before_last_point && *(rt_is_holding_.readFromRT()) == false &&
261262
!check_state_tolerance_per_joint(
262-
state_error_, index, default_tolerances_.goal_state_tolerance[index], false) &&
263-
*(rt_is_holding_.readFromRT()) == false)
263+
state_error_, index, default_tolerances_.goal_state_tolerance[index],
264+
false /* show_errors */))
264265
{
265266
outside_goal_tolerance = true;
266267

@@ -269,6 +270,10 @@ controller_interface::return_type JointTrajectoryController::update(
269270
if (time_difference > default_tolerances_.goal_time_tolerance)
270271
{
271272
within_goal_time = false;
273+
// print once, goal will be aborted afterwards
274+
check_state_tolerance_per_joint(
275+
state_error_, index, default_tolerances_.goal_state_tolerance[index],
276+
true /* show_errors */);
272277
}
273278
}
274279
}

0 commit comments

Comments
 (0)