I have my 6-axis robot.

ros2 rolling c++

moveit::planning_interface::MoveGroupInterface move_group_interface

After planning the path I use move_group_interface.execute(plan) to move robot.

I'd like to break the motion and stop robot by trigger (for example trigger from external sensor). How can I do that?


1 Answer 1


I don't see any execute-cancel feature in the moveit2 move_group API. The standard move_group.execute() method passes your trajectory plan to a separate FollowJointTrajectory action server. You can do the same from your own code.

You can create an action client and use it rather than using the move_group.execute() method. That action client object has a cancel operation which should do what you want.

For reference, you can look at the execute() code in move_group_interface.cpp to see how they did it.

  • $\begingroup$ Thanks, I'll check it. $\endgroup$ Dec 14, 2023 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.