コード例 #1
0
 def loadSDF(self, filename):
     sdf = pysdf.SDF(file=filename)
     for model in sdf.world.models:
         for link in model.links:
             if hasattr(link, 'submodels'):
                 if len(link.submodels) > 0:
                     print model.name + ' - This is an articulated object - SKIPPING!'
                     break
             for col in link.collisions:
                 t1 = transformUtils.getTransformFromNumpy(model.pose)
                 t2 = transformUtils.getTransformFromNumpy(link.pose)
                 t3 = transformUtils.getTransformFromNumpy(col.pose)
                 t = t1
                 t.PreMultiply()
                 t.Concatenate(t2)
                 t.PreMultiply()
                 t.Concatenate(t3)
                 p = transformUtils.poseFromTransform(t)
                 name = model.name
                 if len(link.name) > 0 and link.name != model.name:
                     name += '-' + link.name
                 if len(col.name) > 0 and len(link.collisions) > 1:
                     name += '-' + col.name
                 if col.geometry_type == 'mesh':
                     print 'Mesh geometry is unsupported - SKIPPING!'
                 if col.geometry_type == 'image':
                     print 'image geometry is unsupported - SKIPPING!'
                 if col.geometry_type == 'height_map':
                     print 'Height map geometry is unsupported - SKIPPING!'
                 if col.geometry_type == 'plane':
                     print 'Plane geometry is unsupported - SKIPPING!'
                 if col.geometry_type == 'sphere':
                     print 'Sphere geometry is unsupported - SKIPPING!'
                 if col.geometry_type == 'box':
                     desc = dict(classname='BoxAffordanceItem',
                                 Name=name,
                                 uuid=newUUID(),
                                 pose=p,
                                 Color=[0.8, 0.8, 0.8],
                                 Dimensions=map(
                                     float,
                                     col.geometry_data['size'].split(' ')))
                     self.affordanceManager.newAffordanceFromDescription(
                         desc)
                 if col.geometry_type == 'cylinder':
                     desc = dict(classname='CylinderAffordanceItem',
                                 Name=name,
                                 uuid=newUUID(),
                                 pose=p,
                                 Color=[0.8, 0.8, 0.8],
                                 Radius=float(col.geometry_data['radius']),
                                 Length=float(col.geometry_data['length']))
                     self.affordanceManager.newAffordanceFromDescription(
                         desc)
コード例 #2
0
ファイル: visualization.py プロジェクト: wxmerkt/director
    def shadowOn(self):

        if self.shadowActor:
            return

        mat =  [[1, 0, -1,  0],
                [0, 1, -1,  0],
                [0, 0,  0,  0],
                [0, 0,  0,  1]]

        shadowT = transformUtils.getTransformFromNumpy(mat)

        baseTransform = self.actor.GetUserTransform()
        if baseTransform:
            shadowT.PreMultiply()
            shadowT.Concatenate(baseTransform)

        self.shadowActor = vtk.vtkActor()
        self.shadowActor.SetMapper(self.mapper)
        self.shadowActor.SetUserTransform(shadowT)
        self.shadowActor.GetProperty().LightingOff()
        self.shadowActor.GetProperty().SetColor(0, 0, 0)

        for view in self.views:
            view.renderer().AddActor(self.shadowActor)
コード例 #3
0
ファイル: sceneloader.py プロジェクト: simalpha/director
 def loadSDF(self, filename):
     sdf = pysdf.SDF(file=filename)
     for model in sdf.world.models:
         for link in model.links:
           if hasattr(link, 'submodels'):
             if len(link.submodels)>0:
               print model.name+' - This is an articulated object - SKIPPING!'
               break
           for col in link.collisions:   
             t1=transformUtils.getTransformFromNumpy(model.pose)
             t2=transformUtils.getTransformFromNumpy(link.pose)
             t3=transformUtils.getTransformFromNumpy(col.pose)
             t=t1
             t.PreMultiply()
             t.Concatenate(t2)  
             t.PreMultiply()
             t.Concatenate(t3)
             p = transformUtils.poseFromTransform(t)
             name = model.name;
             if len(link.name)>0 and link.name != model.name:
                 name+='-'+link.name
             if len(col.name)>0 and len(link.collisions)>1:
                 name+='-'+col.name
             if col.geometry_type=='mesh':
                 print 'Mesh geometry is unsupported - SKIPPING!'
             if col.geometry_type=='image':
                 print 'image geometry is unsupported - SKIPPING!'
             if col.geometry_type=='height_map':
                 print 'Height map geometry is unsupported - SKIPPING!'
             if col.geometry_type=='plane':
                 print 'Plane geometry is unsupported - SKIPPING!'
             if col.geometry_type=='sphere':
                 print 'Sphere geometry is unsupported - SKIPPING!'
             if col.geometry_type=='box':
                 desc = dict(classname='BoxAffordanceItem', Name=name, uuid=newUUID(), pose=p, Color=[0.8, 0.8, 0.8], Dimensions=map(float, col.geometry_data['size'].split(' ')))
                 self.affordanceManager.newAffordanceFromDescription(desc)
             if col.geometry_type=='cylinder':
                 desc = dict(classname='CylinderAffordanceItem', Name=name, uuid=newUUID(), pose=p, Color=[0.8, 0.8, 0.8], Radius=float(col.geometry_data['radius']), Length = float(col.geometry_data['length']))
                 self.affordanceManager.newAffordanceFromDescription(desc)            
コード例 #4
0
def testEulerBotpy():
    '''
    Test some quaternion and euler conversions with botpy
    '''

    quat = transformations.random_quaternion()
    rpy = transformations.euler_from_quaternion(quat)

    rpy2 = botpy.quat_to_roll_pitch_yaw(quat)
    quat2 = botpy.roll_pitch_yaw_to_quat(rpy)

    mat = transformations.quaternion_matrix(quat)
    frame = transformUtils.getTransformFromNumpy(mat)
    rpy3 = transformUtils.rollPitchYawFromTransform(frame)

    print quat, quat2
    print rpy, rpy2, rpy3

    assert isQuatEqual(quat, quat2)
    assert np.allclose(rpy, rpy2)
    assert np.allclose(rpy2, rpy3)