0
$\begingroup$

I'm trying to launch two panda robots from the same urdf file but I'm stuck as is giving me parsing errors when I launch two robots together. If I try to launch one it works but not with two (I commented the part in the urdf.xacro code). How can I workaround this issue?

my launch:

<?xml version="1.0"?>

<launch>

  <!-- Gazebo & GUI Configuration -->
  <arg name="debug" default="false"/>
  <arg name="gui" default="true"/>
  <arg name="paused" default="true"/>
  <arg name="world" default="$(find franka_gazebo)/world/worldTable.world"/>
  <arg name="gazebo"      default="true" />

  <!-- Define arguments to be passed to dual_panda.urdf.xacro -->
    <arg name="use_gripper" default="true" />
    <arg name="x" default="0" />
    <arg name="y" default="0" />
    <arg name="z" default="0" />
    <arg name="roll" default="0" />
    <arg name="pitch" default="0" />
    <arg name="yaw" default="0" />

    <!-- World launch -->
    <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="world_name" value="$(arg world)"/>
        <arg name="debug" value="$(arg debug)"/>
        <arg name="paused" value="$(arg paused)"/>
        <arg name="gui" value="$(arg gui)"/>
        <arg name="use_sim_time" value="true"/>
        <arg name="headless"    default="false" />
    </include>

    <!-- Spawn dual panda -->
    <param name="robot_description"
         command="xacro $(find franka_description)/robots/dual_panda/dual_panda.urdf.xacro
                  gazebo:=$(arg gazebo)
                  hand:=$(arg use_gripper)
                  xyz:='$(arg x) $(arg y) $(arg z)'
                  rpy:='$(arg roll) $(arg pitch) $(arg yaw)'">
  </param>

  <node name="spawn" pkg="gazebo_ros" type="spawn_model" args="-param robot_description -urdf -model panda"/>

</launch>

my urdf.xacro:

<?xml version='1.0' encoding='utf-8'?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="panda">

  <xacro:include filename="$(find franka_description)/robots/common/franka_robot_2.xacro"/>

  <!-- Name for this robot -->
  <xacro:arg name="arm_id" default="panda_1" />

  <!-- Should a franka_gripper be mounted at the flange?" -->
  <xacro:arg name="hand" default="false" />
  <!-- Positional offset between $(arm_id)_hand -> $(arm_id)_hand_tcp [m]. Only used when hand:=true -->
  <xacro:arg name="tcp_xyz" default="0 0 0.1034" />
  <!-- Rotational offset between $(arm_id)_hand -> $(arm_id)_hand_tcp [rad]. Only used when hand:=true -->
  <xacro:arg name="tcp_rpy" default="0 0 0" />

  <!-- Is the robot being simulated in gazebo?" -->
  <xacro:arg name="gazebo" default="false" />
  <!-- If `gazebo` arg is set, to which frame shall $(arm_id)_link0 be parented. Empty string for not fixing at all -->
  <xacro:arg name="parent" default="world" />
  <!-- If `gazebo` arg is set and `parent` not empty, what position offset between `parent` & $(arm_id)_link0 -->
  <xacro:arg name="xyz" default="0 0.5 1" />
  <!-- If `gazebo` arg is set and `parent` not empty, what rotation offset between `parent` & $(arm_id)_link0 -->
  <xacro:arg name="rpy" default="0 0 ${-pi/4}" />

  <!-- Define offset for panda_1 and panda_2 -->
    <arg name="offset_y" default="0.5" />

  <xacro:franka_robot arm_id="panda_1"
                      joint_limits="${xacro.load_yaml('$(find franka_description)/robots/panda/joint_limits.yaml')}"
                      hand="$(arg hand)"
                      tcp_xyz="$(arg tcp_xyz)"
                      tcp_rpy="$(arg tcp_rpy)"
                      gazebo="$(arg gazebo)"
                      parent="$(arg parent)"
                      xyz='0 0.5 0.501'
                      rpy="$(arg rpy)">
  </xacro:franka_robot>
  <xacro:franka_robot arm_id="panda_2"
                      joint_limits="${xacro.load_yaml('$(find franka_description)/robots/panda/joint_limits.yaml')}"
                      hand="$(arg hand)"
                      tcp_xyz="$(arg tcp_xyz)"
                      tcp_rpy="$(arg tcp_rpy)"
                      gazebo="$(arg gazebo)"
                      parent="$(arg parent)"
                      xyz='0 -0.5 0.501'
                      rpy="$(arg rpy)">
  </xacro:franka_robot>

</robot>

and my franka_robot_2 (is the same as the original panda file):

<?xml version='1.0' encoding='utf-8'?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
  <xacro:macro name="franka_robot" params="arm_id joint_limits parent:='world' xyz:='0 0 0' rpy:='0 0 0' hand:=false gazebo:=false tcp_xyz:='0 0 0.1034' tcp_rpy='0 0 0'">

    <xacro:include filename="$(find franka_description)/robots/common/utils.xacro" />
    <xacro:include filename="$(find franka_description)/robots/common/franka_arm.xacro" />

    <xacro:franka_arm arm_id="${arm_id}" safety_distance="0.03" gazebo="${gazebo}" joint_limits="${joint_limits}"/>

    <xacro:if value="${hand}">
      <xacro:include filename="$(find franka_description)/robots/common/franka_hand.xacro"/>
      <xacro:franka_hand
          arm_id="${arm_id}"
          rpy="0 0 ${-pi/4}"
          tcp_xyz="${tcp_xyz}"
          tcp_rpy="${tcp_rpy}"
          connected_to="${arm_id}_link8"
          safety_distance="0.03"
          gazebo="${gazebo}"
       />
    </xacro:if>

    <!-- Define additional Gazebo tags -->
    <xacro:if value="${gazebo}">

      <xacro:if value="${parent != ''}">
        <!-- Gazebo requires a joint to a link called "world" for statically mounted robots -->
        <xacro:if value="${parent == 'world'}">
          <link name="${parent}" />
        </xacro:if>
        <joint name="${parent}_joint" type="fixed">
          <origin xyz="${xyz}" rpy="${rpy}" />
          <parent link="${parent}" />
          <child  link="${arm_id}_link0" />
        </joint>
      </xacro:if>

      <xacro:gazebo-joint joint="${arm_id}_joint1" transmission="hardware_interface/PositionJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint2" transmission="hardware_interface/PositionJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint3" transmission="hardware_interface/PositionJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint4" transmission="hardware_interface/PositionJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint5" transmission="hardware_interface/PositionJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint6" transmission="hardware_interface/PositionJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint7" transmission="hardware_interface/PositionJointInterface" />

      <xacro:gazebo-joint joint="${arm_id}_joint1" transmission="hardware_interface/VelocityJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint2" transmission="hardware_interface/VelocityJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint3" transmission="hardware_interface/VelocityJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint4" transmission="hardware_interface/VelocityJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint5" transmission="hardware_interface/VelocityJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint6" transmission="hardware_interface/VelocityJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint7" transmission="hardware_interface/VelocityJointInterface" />

      <xacro:gazebo-joint joint="${arm_id}_joint1" transmission="hardware_interface/EffortJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint2" transmission="hardware_interface/EffortJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint3" transmission="hardware_interface/EffortJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint4" transmission="hardware_interface/EffortJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint5" transmission="hardware_interface/EffortJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint6" transmission="hardware_interface/EffortJointInterface" />
      <xacro:gazebo-joint joint="${arm_id}_joint7" transmission="hardware_interface/EffortJointInterface" />

      <xacro:transmission-franka-state arm_id="${arm_id}" />
      <xacro:transmission-franka-model arm_id="${arm_id}"
         root="${arm_id}_joint1"
         tip="${arm_id}_joint8"
       />

      <xacro:if value="${hand}">
        <xacro:gazebo-joint joint="${arm_id}_finger_joint1" transmission="hardware_interface/EffortJointInterface" />
        <xacro:gazebo-joint joint="${arm_id}_finger_joint2" transmission="hardware_interface/EffortJointInterface" />
        <!-- Friction specific material for Rubber/Rubber contact -->
        <xacro:gazebo-friction link="${arm_id}_leftfinger" mu="1.13" />
        <xacro:gazebo-friction link="${arm_id}_rightfinger" mu="1.13" />
      </xacro:if>

      <gazebo>
        <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
          <controlPeriod>0.001</controlPeriod>
          <robotSimType>franka_gazebo/FrankaHWSim</robotSimType>
          <robotNamespace>/{arm_id}</robotNamespace>
        </plugin>
        <self_collide>true</self_collide>
      </gazebo>
    </xacro:if>
  </xacro:macro>
</robot>
$\endgroup$

0

Your Answer

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

Browse other questions tagged or ask your own question.