Multiple Robots TF problem

Hello, I have created a launch file that can successfully launch and control two UR5 robots. But it seems that the TF of both the robots is not published separately, they are published as one. I need two to have two unique TF’s for both the robots. I dont know where I have made mistake.

here is my launch file

<?xml version="1.0"?>
<launch>
  <param name="red_box_path" type="str" value="$(find ur5_notebook)/urdf/red_box.urdf"/>
  <arg name="robot_name"/>
  <!-- <arg name="init_pose"/> -->
  <arg name="limited" default="true"/>
  <arg name="paused" default="false"/>
  <arg name="gui" default="true"/>
  <arg name="debug" default="false" />
  <arg name="sim" default="true" />

  <!-- startup simulated world -->
  <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>

  <node name="bin" pkg="gazebo_ros" type="spawn_model" args="-file $(find ur5_notebook)/urdf/bin.urdf -urdf -model bin -y 0.8 -x -0.5 -z 0.05" />
  <!-- <node name="bin2" pkg="gazebo_ros" type="spawn_model" args="-file $(find ur5_notebook)/urdf/bin.urdf -urdf -model bin -y -0.8 -x 0.5 -z 0.05" /> -->

  <!-- spawn the conveyor_belt in gazebo -->
  <node name="spawn_conveyor_belt" pkg="gazebo_ros" type="spawn_model" args="-file $(find ur5_notebook)/urdf/conveyor_belt.urdf -urdf -model conveyor_belt" />
  <!-- spawn the conveyor_belt in gazebo -->
  
  <!-- the red blocks spawner node -->
 
  <node name="blocks_spawner" pkg="ur5_notebook" type="blocks_spawner" output="screen" />
  <!-- <node name="blocks_spawner2" pkg="ur5_notebook" type="blocks_spawner2" output="screen" /> -->

  <node name="blocks_poses_publisher" pkg="ur5_notebook" type="blocks_poses_publisher" output="screen" />

  <group ns="robot1">
    <param name="tf_prefix" value="robot1_tf" />
      <include file="$(find ur_gazebo)/launch/ur5.launch">
        <arg name="init_pose" value="-z 0.2 -y 0.7"/>
        <arg name="robot_name" value="robot1"/>
        <!-- <node name="spawn_gazebo_model" pkg="gazebo_ros" type="spawn_model" args="-urdf -param robot_description -model $(arg robot_name)-x 0.5 -z 0.2 -y 1.1" respawn="false" output="screen" /> -->
      </include>

      <include file="$(find ur5_moveit_config)/launch/move_group.launch">
        <arg name="limited" default="$(arg limited)"/>
        <arg name="debug" default="$(arg debug)" />
      </include>

      <!-- <node name="ur5_vision" pkg="ur5_notebook" type="ur5_vision.py" output="screen" />
      <node name="ur5_gripper" pkg="ur5_notebook" type="ur5_gripper.py" output="screen"/> -->

      <remap if="$(arg sim)" from="follow_joint_trajectory" to="arm_controller/follow_joint_trajectory"/>

      <node name="ur5_vision_robot1" pkg="ur5_notebook" type="ur5_vision_robot1.py" output="screen" />
  <!-- <node name="ur5_mp_robot1" pkg="ur5_notebook" type="ur5_mp_robot1.py" output="screen" /> -->
      <node name="ur5_gripper_robot1" pkg="ur5_notebook" type="ur5_gripper_robot1.py" output="screen"/>



  </group>

  <group ns="robot2">
    <param name="tf_prefix" value="robot2_tf" />
      <include file="$(find ur_gazebo)/launch/ur5_r2.launch">
        <arg name="init_pose" value="-z 0.2 -y -0.70"/>
        <arg name="robot_name" value="robot2"/>
        <!-- <node name="spawn_gazebo_model" pkg="gazebo_ros" type="spawn_model" args="-urdf -param robot_description -model $(arg robot_name)-x 0.5 -z 0.2 -y 1.1" respawn="false" output="screen" /> -->

      </include>
      <!-- <node name="blocks_poses_publisher" pkg="ur5_notebook" type="blocks_poses_publisher" output="screen" /> -->
      <!-- <node name="ur5_mp" pkg="ur5_notebook" type="ur5_mp.py" output="screen" /> -->

      <remap if="$(arg sim)" from="follow_joint_trajectory" to="arm_controller/follow_joint_trajectory"/>

      <include file="$(find ur5_r2_moveit_config)/launch/move_group.launch">
        <arg name="limited" default="$(arg limited)"/>
        <arg name="debug" default="$(arg debug)" />
      </include>
      <!-- <node name="ur5_vision" pkg="ur5_notebook" type="ur5_vision.py" output="screen" />
      <node name="ur5_gripper" pkg="ur5_notebook" type="ur5_gripper.py" output="screen"/> -->


      <node name="ur5_vision" pkg="ur5_notebook" type="ur5_vision.py" output="screen" />
      <node name="ur5_r2_gripper" pkg="ur5_notebook" type="ur5_gripper.py" output="screen"/>
    <!-- Remap follow_joint_trajectory -->
  </group>
<!-- 
  <node name="ur5_mp" pkg="ur5_notebook" type="ur5_mp.py" output="screen" />
  <node name="ur5_mp_robot1" pkg="ur5_notebook" type="ur5_mp_robot1.py" output="screen" /> -->



  <!-- for ros control to be used with scara robot -->
  <!--   <param name="/scara_robot_left/robot_description" textfile="$(find two_scara_collaboration)/urdf/scara_robot_left.urdf" />-->

<!-- spawn the red_box in gazebo -->
<!-- node name="spawn_red_box" pkg="gazebo_ros" type="spawn_model" args="-file $(find ur5_notebook)/urdf/red_box.urdf -urdf -model red_box"/ -->

</launch>

I get the following output in Gazebo

and here is the output fromrosrun rqt_tf_tree rqt_tf_tree

As seen from the above picture the world frame should share tf with the baselink of robot1 and robot2.

Hi Murtaza,
we solved today this problem in the ROS Developers Live Class n.68. Check the rosject and the video to get the answer.

1 Like

Hi @murtazab22 I would like to know how you paste the code in this way to solve your doubts? which button or plugin have you used to share it “isolated” from your written? I am sharing my code and doubts to the staff, but in a not nice way…
Thanks