twizy_description/src/twizy_description/robot_description.py
def xml(self, doc, link):
        """Represent this visual element as xml"""

        # Extract scale and shear from transformation
        _, _, Z, S = decompose44(self.trans)
        z = np.mean(Z)

        meta = _URDFVisual.meta[self.node.name]
        if not meta.non_uniform_scale and not np.allclose(Z, z):
            raise ValueError('Non uniform scale not supported for node '
                             f'{self.node.name}')
        if not meta.shear and not np.allclose(S, 0):
            raise ValueError('Scaling which induces shear is not supported '
                             f'for node {self.node.name}')

        fields = self.node.fields

        visual = doc.createElement('visual')

        xyz, rpy = xyz_rpy(self.trans)
        origin = doc.createElement('origin')
        origin.setAttribute('xyz', ' '.join(str(a) for a in xyz))
        origin.setAttribute('rpy', ' '.join(str(a) for a in rpy))
        visual.appendChild(origin)

        geometry = doc.createElement('geometry')
        if self.node.name == 'Box':
            size = [float(a) for a in fields['size'].split()]
            box = doc.createElement('box')
            box.setAttribute('size', ' '.join(str(a) for a in Z * size))
            geometry.appendChild(box)
        elif self.node.name == 'Cylinder':
            cylinder = doc.createElement('cylinder')
            cylinder.setAttribute('radius', str(float(fields['radius']) * z))
            cylinder.setAttribute('length', str(float(fields['height']) * z))
            geometry.appendChild(cylinder)
        elif self.node.name == 'Sphere':
            sphere = doc.createElement('sphere')
            sphere.setAttribute('radius', str(float(fields['radius']) * z))
            geometry.appendChild(sphere)
        elif self.node.name == 'Mesh':
            mesh = doc.createElement('mesh')
            mesh.setAttribute('filename', str(fields['url']))
            mesh.setAttribute('scale', ' '.join(str(a) for a in Z))
            geometry.appendChild(mesh)
        visual.appendChild(geometry)

        link.appendChild(visual)
Represent this visual element as xml
Represent this visual element as xml
Represent this visual element as xml
def xml(self, doc, link):
        _, _, Z, S = decompose44(self.trans)
        z = np.mean(Z)
        meta = _URDFVisual.meta[self.node.name]
        if not meta.non_uniform_scale and not np.allclose(Z, z):
            raise ValueError('Non uniform scale not supported for node '
                             f'{self.node.name}')
        if not meta.shear and not np.allclose(S, 0):
            raise ValueError('Scaling which induces shear is not supported '
                             f'for node {self.node.name}')
        fields = self.node.fields
        visual = doc.createElement('visual')
        xyz, rpy = xyz_rpy(self.trans)
        origin = doc.createElement('origin')
        origin.setAttribute('xyz', ' '.join(str(a) for a in xyz))
        origin.setAttribute('rpy', ' '.join(str(a) for a in rpy))
        visual.appendChild(origin)
        geometry = doc.createElement('geometry')
        if self.node.name == 'Box':
            size = [float(a) for a in fields['size'].split()]
            box = doc.createElement('box')
            box.setAttribute('size', ' '.join(str(a) for a in Z * size))
            geometry.appendChild(box)
        elif self.node.name == 'Cylinder':
            cylinder = doc.createElement('cylinder')
            cylinder.setAttribute('radius', str(float(fields['radius']) * z))
            cylinder.setAttribute('length', str(float(fields['height']) * z))
            geometry.appendChild(cylinder)
        elif self.node.name == 'Sphere':
            sphere = doc.createElement('sphere')
            sphere.setAttribute('radius', str(float(fields['radius']) * z))
            geometry.appendChild(sphere)
        elif self.node.name == 'Mesh':
            mesh = doc.createElement('mesh')
            mesh.setAttribute('filename', str(fields['url']))
            mesh.setAttribute('scale', ' '.join(str(a) for a in Z))
            geometry.appendChild(mesh)
        visual.appendChild(geometry)
        link.appendChild(visual)
def xml ( self , doc , link ) : _ , _ , Z , S = decompose44 ( self . trans ) z = np . mean ( Z ) meta = _URDFVisual . meta [ self . node . name ] if not meta . non_uniform_scale and not np . allclose ( Z , z ) : raise ValueError ( 'Non uniform scale not supported for node ' f'{self.node.name}' ) if not meta . shear and not np . allclose ( S , 0 ) : raise ValueError ( 'Scaling which induces shear is not supported ' f'for node {self.node.name}' ) fields = self . node . fields visual = doc . createElement ( 'visual' ) xyz , rpy = xyz_rpy ( self . trans ) origin = doc . createElement ( 'origin' ) origin . setAttribute ( 'xyz' , ' ' . join ( str ( a ) for a in xyz ) ) origin . setAttribute ( 'rpy' , ' ' . join ( str ( a ) for a in rpy ) ) visual . appendChild ( origin ) geometry = doc . createElement ( 'geometry' ) if self . node . name == 'Box' : size = [ float ( a ) for a in fields [ 'size' ] . split ( ) ] box = doc . createElement ( 'box' ) box . setAttribute ( 'size' , ' ' . join ( str ( a ) for a in Z * size ) ) geometry . appendChild ( box ) elif self . node . name == 'Cylinder' : cylinder = doc . createElement ( 'cylinder' ) cylinder . setAttribute ( 'radius' , str ( float ( fields [ 'radius' ] ) * z ) ) cylinder . setAttribute ( 'length' , str ( float ( fields [ 'height' ] ) * z ) ) geometry . appendChild ( cylinder ) elif self . node . name == 'Sphere' : sphere = doc . createElement ( 'sphere' ) sphere . setAttribute ( 'radius' , str ( float ( fields [ 'radius' ] ) * z ) ) geometry . appendChild ( sphere ) elif self . node . name == 'Mesh' : mesh = doc . createElement ( 'mesh' ) mesh . setAttribute ( 'filename' , str ( fields [ 'url' ] ) ) mesh . setAttribute ( 'scale' , ' ' . join ( str ( a ) for a in Z ) ) geometry . appendChild ( mesh ) visual . appendChild ( geometry ) link . appendChild ( visual )
Represent this visual element as xml
Represent this visual element as xml
"""Represent this visual element as xml""" # Extract scale and shear from transformation
self
doc
link