Loading variables with xacro:include
In roslaunch, if I include a file, I can pass it arguments like this:
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" value="worlds/empty.world" />
</include>
Is there an equivalent for xacro:include? For example:
<xacro:include filename="robot_description.urdf.xacro">
<xacro:arg name="lidar" value="true"/>
</xacro:include>
I know I can do this using something like:
<param name="robot_description" command="$(find xacro)/xacro.py robot_description.urdf.xacro lidar:=true" />
However, this is not an ideal solution, as I would like to nest my robotdescription urdf in a larger definition of robotdescription.
Asked by CatherineH on 2015-09-02 12:20:53 UTC
Answers
I don't believe that is possible, but there are two workarounds.
One is that variables are global, such that if you declare a variable in the including file, it will still have that value in the included file.
However, if you want to include something more than once (say, a left and a right leg) then you should create a macro and use the argument passing logic in there to achieve your goal.
Asked by David Lu on 2015-09-02 12:38:48 UTC
Comments
"variables are global" - I don't think this is true for xacro files. For example, this does not send lidar=true to the description:
<xacro:arg name="lidar" value="true"/>
<xacro:include filename="robot_description.urdf.xacro" />
Asked by CatherineH on 2015-09-02 13:06:07 UTC
Sorry. I knew I should have actually tried that.
Asked by David Lu on 2015-09-02 20:44:02 UTC
Properties are global though, so the following would work:
xml
<xacro:property name="lidar" value="true"/>
<xacro:include filename="robot_description.urdf.xacro" />
Asked by zlackoff on 2020-09-02 21:37:38 UTC
Comments