Skip to content

Commit 634e6fe

Browse files
MarqRazzbmagyar
andauthored
Fix JTC from immediately returning success (ros-controls#565)
Co-authored-by: Bence Magyar <[email protected]>
1 parent 00a8c2e commit 634e6fe

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

joint_trajectory_controller/src/joint_trajectory_controller.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ controller_interface::return_type JointTrajectoryController::update(
152152
sort_to_local_joint_order(*new_external_msg);
153153
// TODO(denis): Add here integration of position and velocity
154154
traj_external_point_ptr_->update(*new_external_msg);
155+
// set the active trajectory pointer to the new goal
156+
traj_point_active_ptr_ = &traj_external_point_ptr_;
155157
}
156158

157159
// TODO(anyone): can I here also use const on joint_interface since the reference_wrapper is not
@@ -315,6 +317,8 @@ controller_interface::return_type JointTrajectoryController::update(
315317
// TODO(matthew-reynolds): Need a lock-free write here
316318
// See https://github.com/ros-controls/ros2_controllers/issues/168
317319
rt_active_goal_.writeFromNonRT(RealtimeGoalHandlePtr());
320+
// remove the active trajectory pointer so that we stop commanding the hardware
321+
traj_point_active_ptr_ = nullptr;
318322

319323
// check goal tolerance
320324
}
@@ -328,6 +332,8 @@ controller_interface::return_type JointTrajectoryController::update(
328332
// TODO(matthew-reynolds): Need a lock-free write here
329333
// See https://github.com/ros-controls/ros2_controllers/issues/168
330334
rt_active_goal_.writeFromNonRT(RealtimeGoalHandlePtr());
335+
// remove the active trajectory pointer so that we stop commanding the hardware
336+
traj_point_active_ptr_ = nullptr;
331337

332338
RCLCPP_INFO(get_node()->get_logger(), "Goal reached, success!");
333339
}

0 commit comments

Comments
 (0)