コード例 #1
0
    def createPolyDataFromPrimitive(geom):

        if geom.type == lcmdrake.lcmt_viewer_geometry_data.BOX:
            d = DebugData()
            d.addCube(dimensions=geom.float_data[0:3], center=[0,0,0])
            return d.getPolyData()

        elif geom.type == lcmdrake.lcmt_viewer_geometry_data.SPHERE:
            d = DebugData()
            d.addSphere(center=(0,0,0), radius=geom.float_data[0])
            return d.getPolyData()

        elif geom.type == lcmdrake.lcmt_viewer_geometry_data.CYLINDER:
            d = DebugData()
            d.addCylinder(center=(0,0,0), axis=(0,0,1), radius=geom.float_data[0], length=geom.float_data[1])
            return d.getPolyData()

        elif geom.type == lcmdrake.lcmt_viewer_geometry_data.CAPSULE:
            d = DebugData()
            radius = geom.float_data[0]
            length = geom.float_data[1]
            d.addCylinder(center=(0,0,0), axis=(0,0,1), radius=radius, length=length)
            d.addSphere(center=(0,0,length/2.0), radius=radius)
            d.addSphere(center=(0,0,-length/2.0), radius=radius)
            return d.getPolyData()

        raise Exception('Unsupported geometry type: %s' % geom.type)
コード例 #2
0
def setupStrings():
    d = DebugData()
    poles = [[-0.36, 0.5, 1.5], [-0.36, -0.5, 1.5], [0, 0.5, 1.5], [0, -0.5, 1.5], [0.36, 0.5, 1.5], [0.36, -0.5, 1.5]]
    for pole in poles:
        d.addCylinder(pole, [0, 0, 1], 3, radius=0.021)
    vis.updatePolyData(d.getPolyData(), "poles")

    d = DebugData()
    strings = [
        [-0.36, 0.5, 0.09, 0, -0.5, 1.77],
        [-0.36, 0.5, 0.74, -0.36, -0.5, 0.95],
        [-0.36, 0.5, 1.12, -0.36, -0.5, 1.68],
        [-0.36, 0.5, 1.33, 0.36, -0.5, 2.29],
        [-0.36, 0.5, 1.6, 0.36, -0.5, 1.62],
        [-0.36, 0.5, 1.74, 0.36, -0.5, 1.93],
        [-0.36, 0.5, 2.15, -0.36, -0.5, 1.46],
        [0, 0.5, 0.765, 0, -0.5, 0.795],
        [0, 0.5, 1.15, 0.36, -0.5, 1.15],
        [0, 0.5, 1.28, -0.36, -0.5, 0.11],
        [0, 0.5, 1.42, 0, -0.5, 1.42],
        [0, 0.5, 1.78, 0.36, -0.5, 0.12],
        [0, 0.5, 2.05, -0.36, -0.5, 1.835],
        [0.36, 0.5, 0.8, -0.36, -0.5, 1.11],
        [0.36, 0.5, 1.16, -0.36, -0.5, 1.47],
        [0.36, 0.5, 1.61, 0.36, -0.5, 1.19],
        [0.36, 0.5, 2.0, 0.36, -0.5, 2.1],
        [-0.36, 0.3, 0, -0.36, 0.3, 2.01],
        [0, -0.34, 0, 0, -0.34, 1.42],
        [0.36, 0, 0, 0.36, 0, 2.05],
    ]
    for string in strings:
        p1 = string[:3]
        p2 = string[3:]
        d.addLine(p1, p2, radius=0.001, color=[255, 0, 0])
    vis.updatePolyData(d.getPolyData(), "strings")
コード例 #3
0
def setupStrings():
    d = DebugData()
    poles = [[-.36,.5,1.5],[-.36,-.5,1.5],[0,.5,1.5],[0,-.5,1.5],[.36,.5,1.5],[.36,-.5,1.5]]
    for pole in poles:
        d.addCylinder(pole, [0,0,1], 3, radius=0.021)
    vis.updatePolyData(d.getPolyData(), 'poles')

    d = DebugData()
    strings = [
        [-.36, .5, .09, 0, -.5, 1.77],
        [-.36, .5, .74, -.36, -.5, .95],
        [-.36, .5, 1.12, -.36, -.5, 1.68],
        [-.36, .5, 1.33, .36, -.5, 2.29],
        [-.36, .5, 1.6, .36, -.5, 1.62],
        [-.36, .5, 1.74, .36, -.5, 1.93],
        [-.36, .5, 2.15, -.36, -.5, 1.46],
        [0, .5, .765, 0, -.5, .795],
        [0, .5, 1.15, .36, -.5, 1.15],
        [0, .5, 1.28, -.36, -.5, .11],
        [0, .5, 1.42, 0, -.5, 1.42],
        [0, .5, 1.78, .36, -.5, .12],
        [0, .5, 2.05, -.36, -.5, 1.835],
        [.36, .5, .8, -.36, -.5, 1.11],
        [.36, .5, 1.16, -.36, -.5, 1.47],
        [.36, .5, 1.61, .36, -.5, 1.19],
        [.36, .5, 2.0, .36, -.5, 2.1],
        [-.36, .3, 0, -.36, .3, 2.01],
        [0, -.34, 0, 0, -.34, 1.42],
        [.36, 0, 0, .36, 0, 2.05],
    ]
    for string in strings:
        p1 = string[:3]
        p2 = string[3:]
        d.addLine(p1,p2,radius=.001,color=[255,0,0])
    vis.updatePolyData(d.getPolyData(), 'strings')
コード例 #4
0
 def updateGeometryFromProperties(self):
     d = DebugData()
     length = self.getProperty('Length')
     d.addCylinder(center=(0, 0, 0),
                   axis=(0, 0, 1),
                   length=self.getProperty('Length'),
                   radius=self.getProperty('Radius'))
     self.setPolyData(d.getPolyData())
コード例 #5
0
 def updateGeometryFromProperties(self):
     d = DebugData()
     length = self.getProperty('Length')
     d.addCylinder(center=(0,0,0), axis=(0,0,1), length=self.getProperty('Length'), radius=self.getProperty('Radius'))
     self.setPolyData(d.getPolyData())