ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org

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

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"/>

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

<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 ... edit retag close merge delete ## Comments How is this different than this question? https://answers.ros.org/question/3544... ( 2020-06-15 16:55:21 -0500 )edit ## 1 Answer Sort by » oldest newest most voted 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. 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

( 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

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