Skip to content

Commit

Permalink
Support name attribute for collisions (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
nlamprian authored Sep 14, 2021
1 parent ee114d8 commit 66fcee5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/urdf_parser_py/urdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,14 @@ def write_xml(self, node, obj):


class Collision(xmlr.Object):
def __init__(self, geometry=None, origin=None):
def __init__(self, geometry=None, origin=None, name=None):
self.geometry = geometry
self.name = name
self.origin = origin


xmlr.reflect(Collision, tag='collision', params=[
xmlr.Attribute('name', str, False),
origin_element,
xmlr.Element('geometry', 'geometric')
])
Expand Down
13 changes: 13 additions & 0 deletions test/test_urdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,19 @@ def test_link_multiple_collision(self):
robot.add_link(link)
self.xml_and_compare(robot, xml)

def test_collision_with_name(self):
xml = '''<?xml version="1.0"?>
<robot name="test" version="1.0">
<link name="link">
<collision name="alice">
<geometry>
<cylinder length="1" radius="1"/>
</geometry>
</collision>
</link>
</robot>'''
self.parse_and_compare(xml)

def test_version_attribute_not_enough_dots(self):
xml = '''<?xml version="1.0"?>
<robot name="test" version="1">
Expand Down

0 comments on commit 66fcee5

Please sign in to comment.