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"?>
  <material name="black">
    <color rgba="0.0 0.0 0.0 1.0"/>

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

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

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

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

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

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

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

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

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

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?