6 xmlr.start_namespace(
'sdf')
8 class Pose(xmlr.Object):
9 def __init__(self, vec=None, extra=None):
13 assert isinstance(vec, list)
19 elif extra
is not None:
20 assert xyz
is None,
"Cannot specify 6-length vector and 3-length vector" 21 assert len(extra) == 3,
"Invalid length" 24 def from_vec(self, vec):
25 assert len(vec) == 6,
"Invalid length" 30 xyz = self.xyz
if self.xyz
else [0, 0, 0]
31 rpy = self.rpy
if self.rpy
else [0, 0, 0]
34 def read_xml(self, node):
36 vec = get_type(
'vector6').read_xml(node)
39 def write_xml(self, node):
41 get_type(
'vector6').write_xml(node, vec)
43 def check_valid(self):
44 assert self.xyz
is not None or self.rpy
is not None 46 name_attribute = xmlr.Attribute(
'name', str)
47 pose_element = xmlr.Element(
'pose', Pose,
False)
50 def __init__(self, name = None, pose = None):
54 xmlr.reflect(Entity, params = [
61 KEYS = [
'ixx',
'ixy',
'ixz',
'iyy',
'iyz',
'izz']
63 def __init__(self, ixx=0.0, ixy=0.0, ixz=0.0, iyy=0.0, iyz=0.0, izz=0.0):
73 [self.ixx, self.ixy, self.ixz],
74 [self.ixy, self.iyy, self.iyz],
75 [self.ixz, self.iyz, self.izz]]
77 xmlr.reflect(Inertia, params = [xmlr.Element(key, float)
for key
in Inertia.KEYS])
82 def __init__(self, mass = 0.0, inertia = None, pose=None):
84 self.inertia = inertia
87 xmlr.reflect(Inertial, params = [
88 xmlr.Element(
'mass', float),
89 xmlr.Element(
'inertia', Inertia),
95 def __init__(self, name = None, pose = None, inertial = None, kinematic = False):
96 Entity.__init__(self, name, pose)
97 self.inertial = inertial
98 self.kinematic = kinematic
100 xmlr.reflect(Link, parent_cls = Entity, params = [
101 xmlr.Element(
'inertial', Inertial),
102 xmlr.Attribute(
'kinematic', bool,
False),
103 xmlr.AggregateElement(
'visual', Visual, var =
'visuals'),
104 xmlr.AggregateElement(
'collision', Collision, var =
'collisions')
109 def __init__(self, name = None, pose=None):
110 Entity.__init__(self, name, pose)
115 xmlr.reflect(Model, parent_cls = Entity, params = [
116 xmlr.AggregateElement(
'link', Link, var =
'links'),
117 xmlr.AggregateElement(
'joint', Joint, var =
'joints'),
118 xmlr.AggregateElement(
'plugin', Plugin, var =
'plugins')
121 xmlr.end_namespace(
'sdf')