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

Support name attribute for collisions #67

Merged
merged 1 commit into from
Sep 14, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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