Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 2015-04-26 17:33:43 -0500

Cerin gravatar image

How do you use externally defined materials in a URDF.Xacro file?

How do you apply a material definition located in an external udrf.xacro file?

I have a materials.urdf.xacro file like:

<?xml version="1.0"?>
<robot>
  <material name="black">
    <color rgba="0.0 0.0 0.0 1.0"/>
  </material>

  <material name="blue">
    <color rgba="0.0 0.0 0.8 1.0"/>
  </material>

  <material name="green">
    <color rgba="0.0 0.8 0.0 1.0"/>
  </material>

  <material name="gray">
    <color rgba="0.7 0.7 0.7 1.0"/>
  </material>

  <material name="darkgray">
    <color rgba="0.3 0.3 0.3 1.0"/>
  </material>

  <material name="red">
    <color rgba="0.8 0.0 0.0 1.0"/>
  </material>

  <material name="white">
    <color rgba="1.0 1.0 1.0 1.0"/>
  </material>

  <material name="yellow">
    <color rgba="0.8 0.8 0.0 1.0"/>
  </material>
</robot>

and I'm trying to include and use these materials like:

<?xml version="1.0"?>
<robot name="myrobot"
    xmlns:xacro="http://www.ros.org/wiki/xacro">
    <xacro:include filename="$(find myrobot_description)/urdf/materials.urdf.xacro" />
    <link name="torso">
        <visual>
            <geometry>
                <box size="1 1 1" />
            </geometry>
            <material name="red"/>
        </visual>
        <xacro:default_inertial mass="1"/>
    </link>
</robot>

However, when I run:

roslaunch urdf_tutorial xacrodisplay.launch model:='$(find myrobot_description)/urdf/myrobot.urdf.xacro'

Rviz renders the box as white and not red. Why is that?