Robotics StackExchange | Archived questions

No link elements found in urdf file

Hello everyone,

I'm struggling a lot with launching my urdf file. I have been working on melodic with that urdf files perfectly but since I moved to work with noetic I can't run it. I have been searching on google and here but nothing helps me. I hope that someone here could help me with that issue.

I tried to put xacro:macro in every place but it didn't solved. In my last attempt, I kept just one link in my file and it didn't solve the problem. Just when I use urdf without ant macro I could run it well.

so here are my 3 files:

launch file:

        <?xml version="1.0"?>
    <launch>

    <!-- Load the URDF/Xacro model of your robot -->
    <arg name="urdf_file" default="$(find xacro)/xacro '$(find robot_model)/urdf/robot.urdf.xacro'" />
        <param name="robot_description" command="$(arg urdf_file)" />

     <!--Publish the robot state -->
    <node name="robot_state_publisher" pkg="robot_state_publisher"  type="robot_state_publisher">
        <param name="publish_frequency" value="20.0"/>
    </node>


<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
    <param name="rate" value="20.0"/>
</node>

</launch>

robot.urdf.xacro:

<?xml version="1.0"?>

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

   <!-- Include all component files -->
   <include filename="$(find robot_model)/urdf/materials.urdf.xacro" />


<include filename="$(find robot_model)/urdf/base.urdf.xacro" />


<!-- Add the drive wheels -->
   <wheel parent="base" suffix="fr" reflects="1"  reflectd="1" color="Black"   type="fixed"/>
   <wheel parent="base" suffix="fl" reflects="-1" reflectd="1" color="Black"   type="fixed"/>
   <rear_wheel parent="base" suffix="br" reflects="1"  reflectd="-1" color="Black"  type="fixed"/>
   <rear_wheel parent="base" suffix="bl" reflects="-1" reflectd="-1" color="Black"  type="fixed"/>
<!-- Add the base and wheels -->
   <base name="base" color="Green"/>


</robot> 

base.urdf.xacro:

<?xml version="1.0"?>

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

  <!-- Define a number of dimensions using properties -->
  <property name="base_size_x" value="1.09" />
  <property name="base_size_y" value="1.8" />
  <property name="base_size_z" value="1.0" />
  <property name="wheel_length" value="0.8" />
  <property name="wheel_radius" value="0.5" />
  <property name="wheel_offset_x" value="1.5" />
  <property name="wheel_offset_y" value="0.8" />
  <property name="wheel_offset_z" value="0.49" />
   <property name="rear_wheel_offset_x" value="0.5" />
  <property name="rear_wheel_offset_y" value="0.75" />
  <property name="rear_wheel_offset_z" value="0.65" />
  <property name="PI" value="3.1415" />

  <!-- define a front wheel -->
  <macro name="wheel" params="suffix parent reflects reflectd color type">
    <joint name="${parent}_${suffix}_wheel_joint" type="${type}">
      <axis xyz="0 0 1" />
      <limit effort="100" velocity="100"/>
      <safety_controller k_velocity="10" />
      <origin xyz="${reflectd*wheel_offset_x} ${reflects*(wheel_offset_y)} ${wheel_offset_z}" rpy="0 0 0" />
    <parent link="${parent}_link"/>
      <child link="${parent}_${suffix}_wheel_link"/>
    </joint>

    <link name="${parent}_${suffix}_wheel_link">
      <visual>
        <origin xyz="0.06 0.85 0.6" rpy="-2 -0.2 -1.95" />
        <geometry>
          <mesh filename="package://robot_model/meshes/front_wheel.STL" scale="0.7 0.7 0.7" />
        </geometry>
        <material name="${color}" />
      </visual>
     <inertial>
        <mass value="0.54391"/>
        <inertia
          ixx="0.0034711"
          ixy="0"
          ixz="0"
          iyy="0.0034739"
          iyz="0"
          izz="0.0061305"
        />
      </inertial>
      <collision>
        <geometry>
          <mesh filename="package://robot_model/meshes/front_wheel.STL" scale="1 1 1" />
          <!-- got to fix all the collisions and inertial stuff
          <cylinder length="0.08" radius="0.13"/> -->
        </geometry>
      </collision>
    </link>
  </macro>

  <!-- define a rear wheel -->
  <macro name="rear_wheel" params="suffix parent reflects reflectd color type">
    <joint name="${parent}_${suffix}_wheel_joint" type="${type}">
      <axis xyz="0 0 1" />
      <limit effort="100" velocity="100"/>
      <safety_controller k_velocity="10" />
      <origin xyz="${reflectd*rear_wheel_offset_x} ${reflects*(rear_wheel_offset_y)} ${rear_wheel_offset_z}" rpy="0 0 0" />
    <parent link="${parent}_link"/>
      <child link="${parent}_${suffix}_wheel_link"/>
    </joint>

    <link name="${parent}_${suffix}_wheel_link">
      <visual>
        <origin xyz="0.65 -0.7 -0.7" rpy="0 0 1.57" />
        <geometry>
          <mesh filename="package://robot_model/meshes/rear_wheel.STL" scale="0.7 0.7 0.7" />
        </geometry>
        <material name="${color}" />
      </visual>
     <inertial>
        <mass value="0.54391"/>
        <inertia
          ixx="0.0034711"
          ixy="0"
          ixz="0"
          iyy="0.0034739"
          iyz="0"
          izz="0.0061305"
        />
      </inertial>
      <collision>
        <geometry>
          <mesh filename="package://robot_model/meshes/rear_wheel.STL" scale="1 1 1" />
          <!-- got to fix all the collisions and inertial stuff
          <cylinder length="0.08" radius="0.13"/> -->
        </geometry>
      </collision>
    </link>
  </macro>


  <!-- The base xacro macro -->
  <macro name="base" params="name color">
    <link name="${name}_link">
      <visual>
        <origin xyz="2 0.8 0.4" rpy="${PI/2} 0 -${PI/2}" />
        <geometry>
          <mesh filename="package://robot_model/meshes/original.STL" scale="0.7 0.7 0.7" />
        <!--<box size="${base_size_x} ${base_size_y} ${base_size_z}" /> -->
        </geometry>
        <material name="${color}" />
      </visual>
      <collision>
        <origin xyz="2 0.8 ${base_size_z/2 }" rpy="0 0 0" />
        <geometry>
        <mesh filename="package://robot_model/meshes/original.STL" scale="0.001 0.001 0.001" />
          <!--<box size="${base_size_x} ${base_size_y} ${base_size_z}" />-->
        </geometry>
      </collision>
    <inertial>
      <origin xyz="0 0 ${base_size_z}" rpy="0 0 0"/>
      <mass value="20"/>
      <inertia
          ixx="${20 / 12.0 * (base_size_y*base_size_z + base_size_z*base_size_z)}" ixy="0.0" ixz="0.0"
          iyy="${20 / 12.0 * (base_size_z*base_size_z + base_size_y*base_size_y)}" iyz="0.0"
          izz="${20 / 12.0 * (base_size_z*base_size_z + base_size_y*base_size_y)}"/>
    </inertial>
    </link>
  </macro>
  <!--
  <link name="base_footprint">
      <visual>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <box size="0.05 0.05 0.001" />
        </geometry>
        <material name="TransparentGreen" />
      </visual>
  </link>

  <joint name="base_joint" type="fixed">
    <origin xyz="0 0 ${base_size_z/2 - wheel_offset_z}" rpy="0 0 0" />        
    <parent link="base_footprint"/>
    <child link="base_link" />
  </joint>
-->

<!-- realsense d265 link
  <joint name="d265_joint" type="fixed">
    <origin xyz="0.6 0 0.3" rpy="0 0 0" />        
    <parent link="base_link"/>
    <child link="t265_pose_frame" />
  </joint>

<link name="t265_pose_frame">
      <visual>
        <origin xyz="0 0 0" rpy="${1.5 * PI} 0 -1.57" />
        <geometry>
          <mesh filename="package://vineyard/meshes/d435.dae" scale="1 1 1" />
        </geometry>
        <material name="black" />
      </visual>
     <inertial>
        <mass value="0.54391"/>
        <inertia
          ixx="0.0034711"
          ixy="0"
          ixz="0"
          iyy="0.0034739"
          iyz="0"
          izz="0.0061305"
        />
      </inertial>
      <collision>
        <geometry>
          <mesh filename="package://vineyard/meshes/d435.dae" scale="1 1 1" />
        </geometry>
      </collision>
    </link>-->

<!-- realsense d435 link
  <joint name="d435_joint" type="fixed">
    <origin xyz="0.6 0 0.25" rpy="0 0 0" />        
    <parent link="base_link"/>
    <child link="d435_link" />
  </joint>

<link name="d435_link">
      <visual>
        <origin xyz="0 0 0" rpy="${1.5 * PI} 0 -1.57" />
        <geometry>
          <mesh filename="package://vineyard/meshes/d435.dae" scale="1 1 1" />
        </geometry>
        <material name="black" />
      </visual>
     <inertial>
        <mass value="0.54391"/>
        <inertia
          ixx="0.0034711"
          ixy="0"
          ixz="0"
          iyy="0.0034739"
          iyz="0"
          izz="0.0061305"
        />
      </inertial>
      <collision>
        <geometry>
          <mesh filename="package://vineyard/meshes/d435.dae" scale="1 1 1" />
        </geometry>
      </collision>
    </link>
-->

</robot>

Asked by Aviad on 2021-12-09 17:00:02 UTC

Comments

I struggled a lot with this before. Not sure the changes were done between versions so what I opted to do with smaller urdfis to get rid of macro all together. Make sure when check_urdf tool passes then add them back one at the time.

Asked by osilva on 2021-12-09 17:23:46 UTC

By getting rid of the macro what I mean is add each component manually

Asked by osilva on 2021-12-09 17:26:41 UTC

But one thing I’ll try before doing all that. Sorry I just noticed to change to xacro:property

Asked by osilva on 2021-12-09 17:30:36 UTC

Also please this discussion: https://github.com/ros/xacro/issues/270

Asked by osilva on 2021-12-10 09:45:37 UTC

Answers