ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

how to include an existing urdf file into anothe urdf file with xacro

asked 2020-06-14 05:59:10 -0500

brunnese gravatar image

Hi, I have written a short urdf file to describe my tool and a launch file to open it in rviz. So far everything displays correctly and there are no errors.

Now, I want to include another urdf file and position it with respect to my part with a joint. The other urdf file is using xacro, which I find really confusing to use. When I try to launch it, I get an error that "no link elements found' and in rviz it says no tf data and there are no fixed frames available. I tried to put assembly_tool] but it can't find this frame. The first is my urdf file and the one below is the relevant excerpt of the existing urdf that I want to include and the third the launch file I use. Could anyone tell me where my problem lies? Thanks in advance!

<?xml version="1.0"?>

<robot name="grinding_tool" xmlns:xacro="http://www.ros.org/wiki/xacro">

<xacro:include filename="$(find compliant_tool_description)/urdf_src/compliant_tool2.urdf.xacro" />

<!-- Useful definitions -->


  <xacro:macro name="grinding_tool" params="ee_link_name">

  <xacro:property name="ee_link_name" value="ee_link"/>

  <link name="ee_link"/>

  <link name="assembly_tool">
    <visual>
      <geometry>
        <mesh filename="package://grinding_tool/meshes/assembly.stl" scale="0.001 0.001 0.001"/>
      </geometry>
      <material name="gray">
          <color rgba="0.8 0.8 0.8 1.0"/>
      </material>
    </visual>
    <collision>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <geometry>
          <box size="0.42 0.17 0.15"/>
        </geometry>
     </collision>
     <inertial>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <mass value="3.3"/>
        <inertia ixx="0.0019"
                 ixy="0" iyy="0.072"
                 ixz="0" iyz="0" izz="0.074"/>
     </inertial>
  </link>

   </xacro:macro>



<gazebo reference="tool">
      <mu1 value="200.0"/>
      <mu2 value="100.0"/>
      <kp value="10000000.0" />
      <kd value="1.0" />
      <material>Gazebo/Grey</material>
  </gazebo>

  <gazebo> 
        <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
          <robotNamespace>/</robotNamespace>
        </plugin>



  </gazebo>
</robot>

The only thing I adapted was including a joint: comp_grinding_joint to connect my urdf to the compliant tool urdf.

<robot xmlns:xacro="http://www.ros.org/wiki/xacro">

  <xacro:include filename="$(find compliant_tool_description)/urdf_src/include/compliant_tool_parameters.urdf.xacro"
                 ns="cmptool"/>

  <!-- Useful definitions -->
  <xacro:property name="meshes_path"
                  value="package://compliant_tool_description/meshes"/>
  <xacro:property name="meshes_scale"
                  value="0.001 0.001 0.001"/>

  <xacro:macro name="compliant_tool" params="ee_link_name">

    <joint name="comp_grinding_JOINT" type="fixed">
          <origin xyz="0 0 0.0019" rpy="0 0 0"/>
          <parent link="assembly_tool"/>
...

<link name="${ee_link_name}_sliderplate">
      <visual>
        <origin xyz="0 0 0.057" rpy="${cmptool.PI} 0 0"/>
        <geometry>
          <mesh filename="${meshes_path}/sliderplate_with_joint.stl" scale="${meshes_scale}"/>
        </geometry>
        <material name="gray">
          <color rgba="${105/255} ${105/255} ${105/255} 1.0"/>
        </material>
      </visual>
      <collision>
        <origin xyz="0 0 0 ...
(more)
edit retag flag offensive close merge delete

Comments

How is this different than this question? https://answers.ros.org/question/3544...

David Lu gravatar image David Lu  ( 2020-06-15 16:55:21 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-06-14 23:31:17 -0500

robustify gravatar image

updated 2020-06-15 11:18:33 -0500

I think your problem is that <xacro:macro name="grinding_tool" params="ee_link_name"> down to its corresponding </xacro:macro> defines a macro that can be instantiated potentially multiple times elsewhere, but does not create the contents on its own. Some more info on macros can be found here: http://wiki.ros.org/xacro#Macros

If this is the entire issue, then simply removing the <xacro:macro name="grinding_tool" params="ee_link_name"> and </xacro:macro> should fix it. Based on the info you posted, this is all that jumps out to me that could be the problem.

edit flag offensive delete link more

Comments

I removed it but it didn't solve the problem. I thought I needed the xacro:macro in order to use ee_link_name from the compliant_tool urdf to make a joint between [assembly_tool] and [${ee_link_name}_sliderplate. The launch file that opens the robot and the robot includes the two tools defines in the robot urdf the ee_link_name

brunnese gravatar image brunnese  ( 2020-06-15 06:40:32 -0500 )edit

Sorry, I didn't notice the other macro for "compliant_tool". I don't see the ending </xacro:macro> in your excerpt, but I assume that macro encompasses the whole model you want to attach. See my edited answer

robustify gravatar image robustify  ( 2020-06-15 11:18:38 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2020-06-14 05:59:10 -0500

Seen: 2,342 times

Last updated: Jun 15 '20