Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow expressions in comments #300

Merged
merged 1 commit into from Dec 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/xacro/__init__.py
Expand Up @@ -1098,8 +1098,7 @@ def eval_all(node, macros, symbols):

eval_all(node, macros, symbols)

# TODO: Also evaluate content of COMMENT_NODEs?
elif node.nodeType == xml.dom.Node.TEXT_NODE:
elif node.nodeType == xml.dom.Node.TEXT_NODE or node.nodeType == xml.dom.Node.COMMENT_NODE:
node.data = unicode(eval_text(node.data, symbols))

node = next
Expand Down
1 change: 0 additions & 1 deletion test/robots/pr2/gripper_v0/gripper.gazebo.xacro
Expand Up @@ -29,7 +29,6 @@
<mu2 value="${finger_mu}" />
<kp value="1000000.0" />
<kd value="1.0" />
<!-- for "${prefix}_l_finger_joint"-->
</gazebo>
<gazebo reference="${prefix}_l_finger_joint">
<stopKd value="${finger_stop_kd}" />
Expand Down
6 changes: 0 additions & 6 deletions test/robots/pr2/pr2_1.11.4.xml
Expand Up @@ -1450,10 +1450,6 @@
</geometry>
</collision>
</link>
<!-- plugin for updating structure pose \
<xacro:kinect_prosilica_gazebo joint_name="${name}_kinect_prosilica_joint"
link_name="${name}_kinect_prosilica_link" />
-->
<!-- kinect ir sensor physical attachment -->
<joint name="head_mount_kinect_ir_joint" type="fixed">
<origin rpy="0 0 0" xyz="-0.032267 0.0125 0.136453"/>
Expand Down Expand Up @@ -2450,7 +2446,6 @@
<mu2 value="500.0"/>
<kp value="1000000.0"/>
<kd value="1.0"/>
<!-- for "${prefix}_l_finger_joint"-->
</gazebo>
<gazebo reference="r_gripper_l_finger_joint">
<stopKd value="1.0"/>
Expand Down Expand Up @@ -3383,7 +3378,6 @@
<mu2 value="500.0"/>
<kp value="1000000.0"/>
<kd value="1.0"/>
<!-- for "${prefix}_l_finger_joint"-->
</gazebo>
<gazebo reference="l_gripper_l_finger_joint">
<stopKd value="1.0"/>
Expand Down
5 changes: 0 additions & 5 deletions test/robots/pr2/sensors/kinect_prosilica_camera.urdf.xacro
Expand Up @@ -43,11 +43,6 @@
</collision>
</link>

<!-- plugin for updating structure pose \
<xacro:kinect_prosilica_gazebo joint_name="${name}_kinect_prosilica_joint"
link_name="${name}_kinect_prosilica_link" />
-->

<!-- kinect ir sensor physical attachment -->
<joint name="${name}_kinect_ir_joint" type="fixed">
<origin xyz="-0.032267 0.0125 0.136453" rpy="0 0 0"/>
Expand Down
7 changes: 7 additions & 0 deletions test/test_xacro.py
Expand Up @@ -1223,6 +1223,13 @@ def test_xml_namespace_lifting(self):
res = '''<a xmlns:a="http://www.ros.org/a" xmlns:b="http://www.ros.org/b" />'''
self.assert_matches(self.quick_xacro(src), res)

def test_comments(self):
src = '''<a xmlns:xacro="http://www.ros.org/wiki/xacro">
<xacro:property name="name" value="foo"/>
<!-- ${name} --></a>'''
res = '''<a><!-- foo --></a>'''
self.assert_matches(self.quick_xacro(src), res)


# test class for in-order processing
class TestXacroInorder(TestXacro):
Expand Down