1 from __future__
import print_function
9 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),
'.')))
10 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),
13 from xml.dom
import minidom
14 from xml_matching
import xml_matches
15 from urdf_parser_py
import urdf
23 @mock.patch(
'urdf_parser_py.xml_reflection.on_error',
24 mock.Mock(side_effect=ParseException))
26 return urdf.Robot.from_xml_string(xml)
29 xml = minidom.parseString(orig)
30 robot = urdf.Robot.from_xml_string(orig)
31 rewritten = minidom.parseString(robot.to_xml_string())
35 xml =
'''<?xml version="1.0"?> 37 <transmission name="simple_trans"> 38 <type>transmission_interface/SimpleTransmission</type> 39 <joint name="foo_joint"> 40 <hardwareInterface>EffortJointInterface</hardwareInterface> 42 <actuator name="foo_motor"> 43 <mechanicalReduction>50.0</mechanicalReduction> 50 xml =
'''<?xml version="1.0"?> 52 <transmission name="simple_trans"> 53 <type>transmission_interface/SimpleTransmission</type> 54 <joint name="foo_joint"> 55 <hardwareInterface>EffortJointInterface</hardwareInterface> 57 <joint name="bar_joint"> 58 <hardwareInterface>EffortJointInterface</hardwareInterface> 59 <hardwareInterface>EffortJointInterface</hardwareInterface> 61 <actuator name="foo_motor"> 62 <mechanicalReduction>50.0</mechanicalReduction> 69 xml =
'''<?xml version="1.0"?> 71 <transmission name="simple_trans"> 72 <type>transmission_interface/SimpleTransmission</type> 73 <joint name="foo_joint"> 74 <hardwareInterface>EffortJointInterface</hardwareInterface> 76 <actuator name="foo_motor"> 77 <mechanicalReduction>50.0</mechanicalReduction> 79 <actuator name="bar_motor"/> 85 xml =
'''<?xml version="1.0"?> 87 <transmission name="simple_trans"> 88 <type>transmission_interface/SimpleTransmission</type> 91 self.assertRaises(Exception, self.
parse, xml)
94 xml =
'''<?xml version="1.0"?> 96 <transmission name="simple_trans"> 97 <type>transmission_interface/SimpleTransmission</type> 98 <joint name="foo_joint"> 99 <hardwareInterface>EffortJointInterface</hardwareInterface> 103 self.assertRaises(Exception, self.
parse, xml)
106 xml =
'''<?xml version="1.0"?> 108 <transmission name="PR2_trans" type="SimpleTransmission"> 109 <joint name="foo_joint"/> 110 <actuator name="foo_motor"/> 111 <mechanicalReduction>1.0</mechanicalReduction> 117 xml =
'''<?xml version="1.0"?> 122 <cylinder length="1" radius="1"/> 124 <material name="mat"/> 131 xml =
'''<?xml version="1.0"?> 133 <material name="mat"> 134 <color rgba="0.0 0.0 0.0 1.0"/> 140 xml =
'''<?xml version="1.0"?> 142 <material name="mat"/> 144 self.assertRaises(ParseException, self.
parse, xml)
148 @mock.patch(
'urdf_parser_py.xml_reflection.on_error',
149 mock.Mock(side_effect=ParseException))
151 return urdf.Robot.from_xml_string(xml)
154 xml =
'''<?xml version="1.0"?> 156 <link name="test_link"> 163 robot = self.
parse(xml)
164 origin = robot.links[0].inertial.origin
165 self.assertEquals(origin.xyz, [0, 0, 0])
166 self.assertEquals(origin.rpy, [0, 0, 0])
169 xml =
'''<?xml version="1.0"?> 171 <link name="test_link"> 174 <origin xyz="1 2 3"/> 178 robot = self.
parse(xml)
179 origin = robot.links[0].inertial.origin
180 self.assertEquals(origin.xyz, [1, 2, 3])
181 self.assertEquals(origin.rpy, [0, 0, 0])
184 if __name__ ==
'__main__':
def test_robot_material(self)
def test_new_transmission_multiple_joints(self)
def test_old_transmission(self)
def test_robot_link_defaults_xyz_set(self)
def xml_matches(a, b, ignore_nodes=[])
def test_new_transmission_missing_actuator(self)
def test_new_transmission(self)
def test_link_material_missing_color_and_texture(self)
def test_new_transmission_missing_joint(self)
def test_robot_link_defaults(self)
def test_robot_material_missing_color_and_texture(self)
def test_new_transmission_multiple_actuators(self)
def parse_and_compare(self, orig)