How to Control Two Universal Robots (UR-5) in the same Simulation Window

Hello, I need help here in controlling two Universal Robots in the same Simulation Window.

I have made my own launch file which can launch two ur5’s at the same time in the same simulation. The launch file is,
roslaunch two_ur5 start.launch

<launch>
  <arg name="robot_name"/>
  <arg name="init_pose"/>
  <arg name="paused" default="false" doc="Starts gazebo in paused mode" />
  <arg name="gui" default="true" doc="Starts gazebo gui" />

  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" default="worlds/empty.world"/>
    <arg name="paused" value="$(arg paused)"/>
    <arg name="gui" value="$(arg gui)"/>
  </include>

  <group ns="robot1">
    <param name="tf_prefix" value="robot1_tf" />
      <include file="$(find ur_gazebo)/launch/ur5.launch">
        <arg name="init_pose" value="-x 1 -y 1 -z 0.2"/>
        <arg name="robot_name" value="robot1"/>
      </include>
    </group>

   <group ns="robot2">
    <param name="tf_prefix" value="robot2_tf" />
      <include file="$(find ur_gazebo)/launch/ur5.launch">
        <arg name="init_pose" value="-x 1 -y -1 -z 0.2"/>
        <arg name="robot_name" value="robot2"/>

      </include>
    </group>    

</launch>

But when it comes two controlling using it “moveit” I can only control one of them at one time, my controllers.yaml file is

controller_list:
  - name: robot1/arm_controller
    action_ns: follow_joint_trajectory
    type: FollowJointTrajectory
    default: true
    joints:
      - shoulder_pan_joint
      - shoulder_lift_joint
      - elbow_joint
      - wrist_1_joint
      - wrist_2_joint
      - wrist_3_joint

controller_list:
  - name: robot2/arm_controller
    action_ns: follow_joint_trajectory
    type: FollowJointTrajectory
    default: true
    joints:
      - shoulder_pan_joint
      - shoulder_lift_joint
      - elbow_joint
      - wrist_1_joint
      - wrist_2_joint
      - wrist_3_joint

The above .yaml controls only one of the two robots
The launch file for controlling the obot using moveit is,

roslaunch demo_moveit_config demo_planning_execution.launch

<launch>

  <rosparam command="load" file="$(find demo_moveit_config)/config/joint_names.yaml" />

  <include file="$(find demo_moveit_config)/launch/planning_context.launch">
    <arg name="load_robot_description" value="true"/>
  </include>

  <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
    <param name="/use_gui" value="false"/>
    <rosparam param="/source_list">[/joint_states]</rosparam>
  </node>

  <include file="$(find demo_moveit_config)/launch/move_group.launch">
    <arg name="publish_monitored_planning_scene" value="true"/>
  </include>

  <include file="$(find demo_moveit_config)/launch/moveit_rviz.launch">
    <arg name="config" value="true"/>
  </include>

</launch>

This is the result I get which is displayed in the following picture,

Also, the motion planning is presented in the above image.

I have the following questions,

  1. How can I pass a single command from RviZ so that my both the robots follow the same command and execute the trajectory at the same time?
  2. How can I pass two different commands to robot1 and robot2 for e.g. (Goal state as “Home” for the first robot (robot-1) and Goal State as “Up” for the second robot (robot-2)) at the same time so that they execute their corresponding trajectories (as per the command given to them) at the same time in the same simulation window.

I would be glad if anyone can answer me the questions with suitable examples for better understanding as I need to know this for my Thesis.

Hello!

This is a very interesting question. Unfortunately, I cannot provide an straight-forward answer, since it is not a trivial issue. I suggest you to have a look at this question from ROS Answers forum: https://answers.ros.org/question/307774/how-to-run-two-jaco-arms-for-use-with-movieit/

It might set you on the path to achieve it. If you still cannot get it working, let me know and I will personally try to help you when I have some time.

Best,

Can you share a rosject of it with us so we can do some tests and provide you with an answer?
Checking the code you wrote is ok but makes very difficult for us to detect the error. Please create a rosject with all the material and share it with us.

Another thing, do you know that tomorrow Tuesday the 3rd of September we have a ROS Developers Live Class where I’ll be teaching how to launch 2 turtlebot robots and control each one independently doing navigation?
I think the content of that class can help you clarify your own case.

You can share the rosject by clicking on the share icon of it, like in the following picture:1

Then a new window will open where you only have to click on the Copy link button:

Hello, please find the ROSJect here,

Please find my ROSJect here http://www.rosject.io/l/c74b625/

Hope to hear soon from you,

Received. Please allow us to check it next Saturday and give you an answer.

Hello, did you solve the problem? I have the same issue with you.