ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
4

Loading variables with xacro:include

asked 2015-09-02 12:20:53 -0500

CatherineH gravatar image

updated 2015-09-02 12:22:27 -0500

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 robot_description urdf in a larger definition of robot_description.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-09-02 12:38:48 -0500

David Lu gravatar image

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.

edit flag offensive delete link more

Comments

2

"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" />
CatherineH gravatar image CatherineH  ( 2015-09-02 13:06:07 -0500 )edit

Sorry. I knew I should have actually tried that.

David Lu gravatar image David Lu  ( 2015-09-02 20:44:02 -0500 )edit

Properties are global though, so the following would work: xml <xacro:property name="lidar" value="true"/> <xacro:include filename="robot_description.urdf.xacro" />

zlackoff gravatar image zlackoff  ( 2020-09-02 21:37:38 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2015-09-02 12:20:53 -0500

Seen: 4,192 times

Last updated: Sep 02 '15