Currently, you cannot execute two trajectories at the same time with MoveIt. This is a known limitation and related to the way MoveIt does trajectory execution monitoring. Here is a Github issue with more in-depth discussion (and how you could contribute to improving this part of the codebase).
At the moment, the main workarounds are:
- Combine your two robots into one planning group, e.g.
both_arms
, and set multiple goals (e.g. one pose goal for each end effector) for your plan. This way, the plan will contain both robots' trajectories and avoid collisions between the robots. This is the safe and sane option.
- If you need to move the robots asynchronously, you can obtain your two robot trajectories with the
plan()
function and then send them to the robot controllers to be executed. However, there will be no collision monitoring, and if the two trajectories move the robots are moving into the same area, they will collide. Only do this if are absolutely certain (!) that the two independent robot trajectories will not result in a collision.
- Alternatively to calling the robot controllers'
follow_joint_trajectory
action, you can merge the two robot trajectories into a single trajectory containing the joints of both robots and execute it with MoveGroupCommander
or move_group_interface
. But the risks regarding collision are the same, because the plan for each robot was calculated without considering the other robot's motion.
To reiterate: Do not attempt the two latter options unless there is no risk of collision between the robots, and be aware that this is dangerous and that you can absolutely break your robots if you are not careful.
Originally posted by fvd with karma: 2180 on 2020-10-04
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by Vaneltin on 2020-10-06:
Thank you very much for your clear answer!
Comment by cshmilyc on 2021-09-16:
Hi~
We can not execute two trajectories at the same time, but we can plan them one by one?
Comment by fvd on 2021-09-16:
You can plan them one by one already, but you can currently only execute one at a time through the MoveGroupInterface's execute()
function. We recently submitted this PR which allows the execution of multiple trajectories via the MoveIt interfaces while checking for collision between them. You can test it yourself if you build it from source.
Comment by cshmilyc on 2021-09-17:
Thanks, @fvd~
I'll follow your research and try
Comment by cshmilyc on 2021-09-17:
Hi, again~
Shall I pull the repository from
cambel:simultaneous-motions
and build a specialized version "moveit" and replace the origin one in ROS?
Comment by fvd on 2021-09-18:\
- Put it in your catkin workspace with the dependencies and build it, then it will be used instead of the binary install
- Post a new question or look at the tutorial to build moveit if you get stuck more