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

indigo back port of #45 #46

Closed
wants to merge 1 commit into from
Closed
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
72 changes: 72 additions & 0 deletions test/test_urdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ def parse_and_compare(self, orig):
rewritten = minidom.parseString(robot.to_xml_string())
self.assertTrue(xml_matches(xml, rewritten))

def xml_and_compare(self, robot, xml):
robot_xml_string = robot.to_xml_string()
robot_xml = minidom.parseString(robot_xml_string)
orig_xml = minidom.parseString(xml)
self.assertTrue(xml_matches(robot_xml, orig_xml))

def test_new_transmission(self):
xml = '''<?xml version="1.0"?>
<robot name="test">
Expand All @@ -46,6 +52,18 @@ def test_new_transmission(self):
</robot>'''
self.parse_and_compare(xml)

robot = urdf.Robot(name = 'test')
trans = urdf.Transmission(name = 'simple_trans')
trans.type = 'transmission_interface/SimpleTransmission'
joint = urdf.TransmissionJoint(name = 'foo_joint')
joint.add_aggregate('hardwareInterface', 'EffortJointInterface')
trans.add_aggregate('joint', joint)
actuator = urdf.Actuator(name = 'foo_motor')
actuator.mechanicalReduction = 50.0
trans.add_aggregate('actuator', actuator)
robot.add_aggregate('transmission', trans)
self.xml_and_compare(robot, xml)

def test_new_transmission_multiple_joints(self):
xml = '''<?xml version="1.0"?>
<robot name="test">
Expand All @@ -65,6 +83,22 @@ def test_new_transmission_multiple_joints(self):
</robot>'''
self.parse_and_compare(xml)

robot = urdf.Robot(name = 'test')
trans = urdf.Transmission(name = 'simple_trans')
trans.type = 'transmission_interface/SimpleTransmission'
joint = urdf.TransmissionJoint(name = 'foo_joint')
joint.add_aggregate('hardwareInterface', 'EffortJointInterface')
trans.add_aggregate('joint', joint)
joint = urdf.TransmissionJoint(name = 'bar_joint')
joint.add_aggregate('hardwareInterface', 'EffortJointInterface')
joint.add_aggregate('hardwareInterface', 'EffortJointInterface')
trans.add_aggregate('joint', joint)
actuator = urdf.Actuator(name = 'foo_motor')
actuator.mechanicalReduction = 50.0
trans.add_aggregate('actuator', actuator)
robot.add_aggregate('transmission', trans)
self.xml_and_compare(robot, xml)

def test_new_transmission_multiple_actuators(self):
xml = '''<?xml version="1.0"?>
<robot name="test">
Expand All @@ -81,6 +115,20 @@ def test_new_transmission_multiple_actuators(self):
</robot>'''
self.parse_and_compare(xml)

robot = urdf.Robot(name = 'test')
trans = urdf.Transmission(name = 'simple_trans')
trans.type = 'transmission_interface/SimpleTransmission'
joint = urdf.TransmissionJoint(name = 'foo_joint')
joint.add_aggregate('hardwareInterface', 'EffortJointInterface')
trans.add_aggregate('joint', joint)
actuator = urdf.Actuator(name = 'foo_motor')
actuator.mechanicalReduction = 50.0
trans.add_aggregate('actuator', actuator)
actuator = urdf.Actuator(name = 'bar_motor')
trans.add_aggregate('actuator', actuator)
robot.add_aggregate('transmission', trans)
self.xml_and_compare(robot, xml)

def test_new_transmission_missing_joint(self):
xml = '''<?xml version="1.0"?>
<robot name="test">
Expand Down Expand Up @@ -113,6 +161,11 @@ def test_old_transmission(self):
</robot>'''
self.parse_and_compare(xml)

robot = urdf.Robot(name = 'test')
trans = urdf.PR2Transmission(name = 'PR2_trans', joint = 'foo_joint', actuator = 'foo_motor', type = 'SimpleTransmission', mechanicalReduction = 1.0)
robot.add_aggregate('transmission', trans)
self.xml_and_compare(robot, xml)

def test_link_material_missing_color_and_texture(self):
xml = '''<?xml version="1.0"?>
<robot name="test">
Expand All @@ -127,6 +180,20 @@ def test_link_material_missing_color_and_texture(self):
</robot>'''
self.parse_and_compare(xml)

robot = urdf.Robot(name = 'test')
link = urdf.Link(name = 'link',
visual = urdf.Visual(geometry = urdf.Cylinder(length = 1, radius = 1),
material = urdf.Material(name = 'mat')))
robot.add_link(link)
self.xml_and_compare(robot, xml)

robot = urdf.Robot(name = 'test')
link = urdf.Link(name = 'link')
link.visual = urdf.Visual(geometry = urdf.Cylinder(length = 1, radius = 1),
material = urdf.Material(name = 'mat'))
robot.add_link(link)
self.xml_and_compare(robot, xml)

def test_robot_material(self):
xml = '''<?xml version="1.0"?>
<robot name="test">
Expand All @@ -136,6 +203,11 @@ def test_robot_material(self):
</robot>'''
self.parse_and_compare(xml)

robot = urdf.Robot(name = 'test')
material = urdf.Material(name = 'mat', color = urdf.Color([0.0, 0.0, 0.0, 1.0]))
robot.add_aggregate('material', material)
self.xml_and_compare(robot, xml)

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