xacro (Melodic) parsing content within xml-comment-brackets
SeniorKullken opened this issue · comments
1. Xacro Trouble Report
1.1 Expected behaviour
- xacro processing/interpreter should ignore all content in between xml-comment-brackets
<!--
and-->
.
1.2 Current behaviour
My analysis:
- Comments/Content in between xml comment brackets,
<! --
and-->
, are also expanded/interpreted.
Which causes, in my example, xacro to stop and display error messageUndefined substitution argument world
.
1.3 Background
- Recently (last month?) my old .world.xacro files stopped working =>
Undefined substitution argument world
. - I have been using those .xacro files since the summer 2021. Without any changes.
But now in jan/deb-2022 they have stop working.
1.4 My work environment
- Melodic with the latest updates (Today is: 27 feb, 2022).
Note! - It looks like it works with Noetic... - Ubuntu 18.04(64-bit)
2. Examples
See example below "How to repeat the issue", in Melodic, and "Temporary workaround" I made.
(I have cut down the attached examples and ,almost ,only kept the xml comments that causing the error)
2.1 Example: How to repeat the issue
Output from: $ cat TroubleReport_error.xacro
Attached: TroubleReport_error.xacro
<?xml version="1.0" ?>
<sdf version="1.5">
<!--
".xacro" => SDF/URDF-macro file that need to be parsed before loading into Gazebo.
Example - Via shell/command line:
$ rosrun xacro xacro src/Pet-Mk-IV/pet_mk_iv_simulation/worlds/pet_play_yard.world.xacro > src/Pet-Mk-IV/pet_mk_iv_simulation/worlds/pet_play_yard.world
Example - Via launch file:
<node name="xacro" pkg="xacro" type="xacro" args="$(find pet_mk_iv_simulation)/worlds/$(arg world).xacro -o $(find pet_mk_iv_simulation)/worlds/$(arg world)" />
http://wiki.ros.org/xacro
-->
<world name="default">
<!-- REMOVED ALL THE CONTENT IN DEBUGGING PURPOSE... ONLY LEAVING A EMPTY WORLD -->
<!-- A global light source -->
<include>
<uri>model://sun</uri>
</include>
<!-- A ground plane -->
<include>
<uri>model://ground_plane</uri>
</include>
</world>
</sdf>
Pay attention to the "$(arg world)
" in the example above. It is those string, INSIDE the xml-comment-brackets, that causing my problem. See the output/result from xacro below.
Output from: $ rosrun xacro xacro TroubleReport_error.xacro
Undefined substitution argument world
when processing file: TroubleReport_error.xacro
2.2 Example: A temporary workaround
As a workaround, I replaced $
with [** dollars **]
in between the xml-comment-brackets <!--
and -->
.
Output from: $ cat TroubleReport_workaraound.xacro
Attached: TroubleReport_workaraound.xacro
<?xml version="1.0" ?>
<sdf version="1.5">
<!--
".xacro" => SDF/URDF-macro file that need to be parsed before loading into Gazebo.
Example - Via shell/command line:
$ rosrun xacro xacro src/Pet-Mk-IV/pet_mk_iv_simulation/worlds/pet_play_yard.world.xacro > src/Pet-Mk-IV/pet_mk_iv_simulation/worlds/pet_play_yard.world
Example - Via launch file:
<node name="xacro" pkg="xacro" type="xacro" args="$(find pet_mk_iv_simulation)/worlds/[**dollar**](arg world).xacro -o $(find pet_mk_iv_simulation)/worlds/[**dollar**](arg world)" />
http://wiki.ros.org/xacro
-->
<world name="default">
<!-- REMOVED ALL THE CONTENT IN DEBUGGING PURPOSE... ONLY LEAVING A EMPTY WORLD -->
<!-- A global light source -->
<include>
<uri>model://sun</uri>
</include>
<!-- A ground plane -->
<include>
<uri>model://ground_plane</uri>
</include>
</world>
</sdf>
- Pay attention to how "
$(find pet_mk_iv_simulation)
", inside the comment, is handled...!
Expanded to "/home/sk/ros_ws/src/pet_mk_iv_simulation
".*
This should not either happens... But in this case it did not cause any error.
Output from: $ rosrun xacro xacro TroubleReport_workaraound.xacro
Attached: TroubleReport_workaraound.world
<?xml version="1.0" encoding="utf-8"?>
<!-- =================================================================================== -->
<!-- | This document was autogenerated by xacro from TroubleReport_workaraound.xacro.txt | -->
<!-- | EDITING THIS FILE BY HAND IS NOT RECOMMENDED | -->
<!-- =================================================================================== -->
<sdf version="1.5">
<!--
".xacro" => SDF/URDF-macro file that need to be parsed before loading into Gazebo.
Example - Via shell/command line:
$ rosrun xacro xacro src/Pet-Mk-IV/pet_mk_iv_simulation/worlds/pet_play_yard.world.xacro > src/Pet-Mk-IV/pet_mk_iv_simulation/worlds/pet_play_yard.world
Example - Via launch file:
<node name="xacro" pkg="xacro" type="xacro" args="/home/sk/ros_ws/src/pet_mk_iv_simulation/worlds/[**dollar**](arg world).xacro -o /home/sk/ros_ws/src/pet_mk_iv_simulation/worlds/[**dollar**](arg world)" />
http://wiki.ros.org/xacro
-->
<world name="default">
<!-- REMOVED ALL THE CONTENT IN DEBUGGING PURPOSE... ONLY LEAVING A EMPTY WORLD -->
<!-- A global light source -->
<include>
<uri>model://sun</uri>
</include>
<!-- A ground plane -->
<include>
<uri>model://ground_plane</uri>
</include>
</world>
</sdf>
2.3 Attached files
Attached: TroubleReport_error.xacro
Attached: TroubleReport_workaraound.xacro
Attached: TroubleReport_workaraound.world
See #309 (comment) for a fix. Unfortunately, Melodic hasn't seen a release sync for a while. Consider using the debian packages from the ROS testing
repo or build xacro from source.
Closing as Melodic as well as Noetic distros have synced the latest fixes.