Skip to content

values of macro parameters only containing numbers and underscores are truncated #246

@pleemann

Description

@pleemann

Hi

Consider the following minimal example xacro file

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

<xacro:macro name="leg" params="prefix:=0_0_0">
    <link name="${prefix}_leg">
    </link>
</xacro:macro>

<xacro:leg prefix="1_2_3"/>
<xacro:leg prefix="'1_2_3'"/>
<xacro:leg prefix="a_1_2_3"/>
<xacro:leg />
</robot>

Output of rosrun xacro xacro test.urdf.xacro on noetic:

<robot name="firefighter">
  <link name="123_leg">
    </link>
  <link name="1_2_3_leg">
    </link>
  <link name="a_1_2_3_leg">
    </link>
  <link name="0_leg">
    </link>
</robot>

If I run the same on melodic, the output looks as expected:

<robot name="firefighter">
  <link name="1_2_3_leg">
    </link>
  <link name="1_2_3_leg">
    </link>
  <link name="a_1_2_3_leg">
    </link>
  <link name="0_0_0_leg">
    </link>
</robot>

It seems like that xacro treats values which only contain numbers and underscores as integers, omitting all leading 0's and removing all underscores. If I enforce it to treat it as string (by adding single quotes '), it also works as intended. I tried to check the xacro implementation, but was unable to find the cause so far. Any idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions