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

Nested properties in xacro

asked 2013-04-02 23:14:10 -0500

updated 2015-11-06 01:02:45 -0500

Akif gravatar image

I know you can nest xacro macros, but is it also possible to nest properties in xacro?

I'm trying something like this

test.xacro contains

<?xml version="1.0"?>
<robot
    xmlns:xacro="http://www.ros.org/wiki/xacro"
    name="test">

  <property name="foo" value="1.0"/>
  <property name="bar" value="${foo + 1.0}"/>

  <link name="test_link">
    <inertial>
      <origin xyz="${foo} ${bar} 0"/>
    </inertial>
  </link>
</robot>

but the output of rosrun xacro xacro.py test.xacro gives me:

<?xml version="1.0" ?>
...
<robot name="test" xmlns:xacro="http://www.ros.org/wiki/xacro">
<link name="test_link">
   <inertial>
      <origin xyz="1.0 ${foo + 1.0} 0"/>
   </inertial>
</link>
</robot>

note the not expanded contents of the bar property

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2015-11-06 00:56:23 -0500

Akif gravatar image

With pull request: https://github.com/ros/xacro/pull/40 this problem is solved with Indigo release. I have tested your code and it now generates:

<?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- |    This document was autogenerated by xacro from test.xacro                     | -->
<!-- |    EDITING THIS FILE BY HAND IS NOT RECOMMENDED                                 | -->
<!-- =================================================================================== -->
<robot name="test" xmlns:xacro="http://www.ros.org/wiki/xacro">
  <link name="test_link">
    <inertial>
      <origin xyz="1.0 2.0 0"/>
    </inertial>
  </link>
</robot>

which is the expected result.

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2013-04-02 23:14:10 -0500

Seen: 924 times

Last updated: Nov 06 '15