'#pragma once' equivalent for urdf/xacro files
I have multiple urdf files representing different components of a robot. As I don't want to define materials multiple times in different files, I created a file containing those definitions ('materials.urdf.xacro'). The file looks like this:
<?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="Grey">
<color rgba="0.2 0.2 0.2 1.0"/>
</material>
<material name="DarkGrey">
<color rgba="0.1 0.1 0.1 1.0"/>
</material>
<material name="Orange">
<color rgba="${255/255} ${108/255} ${10/255} 1.0"/>
</material>
<material name="Brown">
<color rgba="${222/255} ${207/255} ${195/255} 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>
</robot>
I include them via
<xacro:include filename="$(find package_name)/urdf/materials.urdf.xacro" />
in a component file ('laser.urdf.xacro') and in the robot definition file ('robot.urdf.xacro') with itself includes 'laser.urdf.xacro').
When I try to run the urdf file via rviz, I get an error:
material 'Black' is not unique.
I presume it's due to the indirect second include of the 'materials.urdf.xacro' file, just like the problems you would have in C++ without '#pragma once' or the '#ifndef ... => #define ... => #endif' construct.
So is there an equivalent to this in urdf/xacro files?
- ROS Kinetic
- Ubuntu 16.04