Ask Your Question
1

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

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

Cerin gravatar image

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?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-04-26 18:30:53 -0500

130s gravatar image

updated 2015-04-26 18:39:26 -0500

From the tutorial you see:

If a TF frame does not exist for a given URDF link, then it will be placed at the origin in white.

In your case, changing link name from "torso" to "base_link" should do the work.

UPDATE: @DLu is right. Although torso might not be available in the fixed frame pulldown menu, you can manually type in torso.

edit flag offensive delete link more

Comments

Unfortunately, that tutorial never explains what a "TF frame" is, so that note doesn't help.

Cerin gravatar imageCerin ( 2015-04-26 21:32:35 -0500 )edit

Although I don't understand why, this fixes it. I wish there was a more intuitive solution though.

Cerin gravatar imageCerin ( 2015-04-26 21:44:09 -0500 )edit

Might be a good call: URDF tutorial requires you to have finished TF tutorials. I opened a ticket.

130s gravatar image130s ( 2015-04-27 02:51:45 -0500 )edit
0

answered 2015-04-26 18:24:56 -0500

DLu gravatar image

Set the base frame of rviz to be torso

edit flag offensive delete link more

Comments

I don't understand. What code would I change to do that? Or are you suggesting I'll have to manually set some GUI widget every time I load a model?

Cerin gravatar imageCerin ( 2015-04-26 21:33:46 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 1,711 times

Last updated: Apr 26 '15