本文整理汇总了Python中vtkAll.vtkTransform函数的典型用法代码示例。如果您正苦于以下问题:Python vtkTransform函数的具体用法?Python vtkTransform怎么用?Python vtkTransform使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkTransform函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeDebugRegions
def makeDebugRegions(self):
stepWidth = (15 + 3/8.0) * 0.0254
stepLength = (15 + 5/8.0) * 0.0254
stepHeight = (5 + 5/8.0) * 0.0254
stepPoints = np.array([
[-stepLength/2.0, -stepWidth/2.0, 0.0],
[-stepLength/2.0, stepWidth/2.0, 0.0],
[stepLength/2.0, stepWidth/2.0, 0.0],
[stepLength/2.0, -stepWidth/2.0, 0.0]
])
t = vtk.vtkTransform()
t.Translate(0.0, 0.0, 0.0)
t.RotateZ(4.5)
for i in xrange(len(stepPoints)):
stepPoints[i] = np.array(t.TransformPoint(stepPoints[i]))
stepOffset = np.array([stepLength, 0.0, stepHeight])
numSteps = 5
goalFrame = transformUtils.frameFromPositionAndRPY([0.4, 0.0, 0.1], [0,0,0])
vis.showFrame(goalFrame, 'goal frame', scale=0.2)
rpySeed = np.radians(goalFrame.GetOrientation())
for i in xrange(numSteps):
step = stepPoints + (i+1)*stepOffset
self.convertStepToSafeRegion(step, rpySeed)
self.footstepsPanel.onNewWalkingGoal(goalFrame)
示例2: applyFrameTransform
def applyFrameTransform(x, y, z, yaw):
if lastEditedFrame is not None and lastEditedFrame.getProperty("Edit"):
t = vtk.vtkTransform()
t.Concatenate(lastEditedFrame.transform)
t.RotateZ(yaw)
t.Translate(x, y, z)
lastEditedFrame.copyFrame(t)
示例3: getNextDoubleSupportPose
def getNextDoubleSupportPose(self, lfootTransform, rfootTransform):
vis.updateFrame(lfootTransform, 'lfootTransform', visible=True, scale=0.2)
vis.updateFrame(rfootTransform, 'rfootTransform', visible=True, scale=0.2)
startPose = self.robotStateJointController.getPose('EST_ROBOT_STATE')
startPoseName = 'stride_start'
self.ikPlanner.addPose(startPose, startPoseName)
constraints = []
# lock everything except the feet, constrain the feet
constraints.append(self.ikPlanner.createQuasiStaticConstraint())
constraints.append(self.ikPlanner.createMovingBackPostureConstraint())
constraints.append(self.ikPlanner.createMovingBasePostureConstraint(startPoseName))
constraints.append(self.ikPlanner.createLockedLeftArmPostureConstraint(startPoseName))
constraints.append(self.ikPlanner.createLockedRightArmPostureConstraint(startPoseName))
nullFrame = vtk.vtkTransform()
positionConstraint, orientationConstraint = self.ikPlanner.createPositionOrientationConstraint(self.ikPlanner.rightFootLink, rfootTransform, nullFrame)
positionConstraint.tspan = [1.0, 1.0]
orientationConstraint.tspan = [1.0, 1.0]
constraints.append(positionConstraint)
constraints.append(orientationConstraint)
positionConstraint, orientationConstraint = self.ikPlanner.createPositionOrientationConstraint(self.ikPlanner.leftFootLink, lfootTransform, nullFrame)
positionConstraint.tspan = [1.0, 1.0]
orientationConstraint.tspan = [1.0, 1.0]
constraints.append(positionConstraint)
constraints.append(orientationConstraint)
constraintSet = ikplanner.ConstraintSet(self.ikPlanner, constraints, 'stride_end', startPoseName)
nextDoubleSupportPose, info = constraintSet.runIk()
return nextDoubleSupportPose
示例4: updateFrame
def updateFrame(self):
norm = np.linalg.norm(np.array([self.thetadot, self.phidot, self.yawdot, self.Xdot, self.Ydot, self.Zdot]))
dt = 0.01 #self.timer.elapsed
if self.baseFrame is not None:
cameraFocus = np.asarray(self.camera.GetFocalPoint())
cameraInterp = cameraFocus + (self.cameraTarget - cameraFocus)*0.02
self.camera.SetFocalPoint(cameraInterp)
if self.cameraMode is not True:
if self.baseFrame is not None and norm > 0.1:
t = vtk.vtkTransform()
t.Concatenate(self.baseFrame.transform)
t.RotateZ(-self.thetadot * dt * self.speedMultiplier)
t.RotateX(self.phidot * dt * self.speedMultiplier)
t.RotateY(self.yawdot * dt * self.speedMultiplier)
t.Translate(self.Xdot * dt * self.speedMultiplier, self.Ydot * dt * self.speedMultiplier, self.Zdot * dt * self.speedMultiplier)
self.baseFrame.copyFrame(t)
else:
self.camera.Elevation(self.Zdot * self.speedMultiplier)
self.camera.Azimuth(self.Xdot * self.speedMultiplier)
self.camera.Zoom(1.0 + self.phidot/1000.0)
self.view.render()
示例5: getTransformFromNumpy
def getTransformFromNumpy(mat):
'''
Given a numpy 4x4 array, return a vtkTransform.
'''
assert mat.shape == (4,4)
t = vtk.vtkTransform()
t.SetMatrix(mat.flatten())
return t
示例6: computeFootstepPlanSafeRegions
def computeFootstepPlanSafeRegions(self, blocks, robotPose, standingFootName):
print 'planning with safe regions. %d blocks.' % len(blocks)
folder = om.getOrCreateContainer('Safe terrain regions')
om.removeFromObjectModel(folder)
footsteps = []
for i, block in enumerate(blocks):
corners = block.getCorners()
rpy = np.radians(block.cornerTransform.GetOrientation())
#rpy = [0.0, 0.0, 0.0]
self.convertStepToSafeRegion(corners, rpy)
lastBlock = blocks[-1]
goalFrame = transformUtils.copyFrame(lastBlock.cornerTransform)
goalOffset = vtk.vtkTransform()
goalOffset.Translate(0.3, lastBlock.rectWidth/2.0, 0.0)
goalFrame.PreMultiply()
goalFrame.Concatenate(goalOffset)
goalPosition = np.array(goalFrame.GetPosition())
if len(blocks) > 1:
goalFrame = transformUtils.copyFrame(blocks[-2].cornerTransform)
goalFrame.Translate(goalPosition - np.array(goalFrame.GetPosition()))
vis.updateFrame(goalFrame, 'footstep plan goal', scale=0.2)
request = self.footstepsPanel.driver.constructFootstepPlanRequest(robotPose, goalFrame)
assert standingFootName in (self.ikPlanner.leftFootLink, self.ikPlanner.rightFootLink)
if standingFootName == self.ikPlanner.rightFootLink:
leadingFoot = lcmdrc.footstep_plan_params_t.LEAD_RIGHT
else:
leadingFoot = lcmdrc.footstep_plan_params_t.LEAD_LEFT
request.params.leading_foot = leadingFoot
request.params.max_forward_step = 0.5
request.params.nom_forward_step = 0.12
request.params.nom_step_width = 0.22
request.params.max_num_steps = 8 #2*len(blocks)
plan = self.footstepsPanel.driver.sendFootstepPlanRequest(request, waitForResponse=True)
if not plan:
return []
#print 'received footstep plan with %d steps.' % len(plan.footsteps)
footsteps = []
for i, footstep in enumerate(plan.footsteps):
footstepTransform = self.transformFromFootstep(footstep)
footsteps.append(Footstep(footstepTransform, footstep.is_right_foot))
return footsteps[2:]
示例7: concatenateTransforms
def concatenateTransforms(transformList):
'''
Given a list of vtkTransform objects, returns a new vtkTransform
which is a concatenation of the whole list using vtk post multiply.
See documentation for vtkTransform::PostMultiply.
'''
result = vtk.vtkTransform()
result.PostMultiply()
for t in transformList:
result.Concatenate(t)
return result
示例8: __init__
def __init__(self):
pose = transformUtils.poseFromTransform(vtk.vtkTransform())
self.pointcloud = ioUtils.readPolyData(director.getDRCBaseDir() + '/software/models/rehearsal_pointcloud.vtp')
self.pointcloudPD = vis.showPolyData(self.pointcloud, 'coursemodel', parent=None)
segmentation.makeMovable(self.pointcloudPD, transformUtils.transformFromPose(array([0, 0, 0]), array([ 1.0, 0. , 0. , 0.0])))
self.originFrame = self.pointcloudPD.getChildFrame()
t = transformUtils.transformFromPose(array([-4.39364111, -0.51507392, -0.73125563]), array([ 0.93821625, 0. , 0. , -0.34604951]))
self.valveWalkFrame = vis.updateFrame(t, 'ValveWalk', scale=0.2,visible=True, parent=self.pointcloudPD)
t = transformUtils.transformFromPose(array([-3.31840048, 0.36408685, -0.67413123]), array([ 0.93449475, 0. , 0. , -0.35597691]))
self.drillPreWalkFrame = vis.updateFrame(t, 'DrillPreWalk', scale=0.2,visible=True, parent=self.pointcloudPD)
t = transformUtils.transformFromPose(array([-2.24553758, -0.52990939, -0.73255338]), array([ 0.93697004, 0. , 0. , -0.34940972]))
self.drillWalkFrame = vis.updateFrame(t, 'DrillWalk', scale=0.2,visible=True, parent=self.pointcloudPD)
t = transformUtils.transformFromPose(array([-2.51306835, -0.92994004, -0.74173541 ]), array([-0.40456572, 0. , 0. , 0.91450893]))
self.drillWallWalkFarthestSafeFrame = vis.updateFrame(t, 'DrillWallWalkFarthestSafe', scale=0.2,visible=True, parent=self.pointcloudPD)
t = transformUtils.transformFromPose(array([-2.5314524 , -0.27401861, -0.71302976]), array([ 0.98691519, 0. , 0. , -0.16124022]))
self.drillWallWalkBackFrame = vis.updateFrame(t, 'DrillWallWalkBack', scale=0.2,visible=True, parent=self.pointcloudPD)
t = transformUtils.transformFromPose(array([-1.16122318, 0.04723203, -0.67493468]), array([ 0.93163145, 0. , 0. , -0.36340451]))
self.surprisePreWalkFrame = vis.updateFrame(t, 'SurprisePreWalk', scale=0.2,visible=True, parent=self.pointcloudPD)
t = transformUtils.transformFromPose(array([-0.5176186 , -1.00151554, -0.70650799]), array([ 0.84226497, 0. , 0. , -0.53906374]))
self.surpriseWalkFrame = vis.updateFrame(t, 'SurpriseWalk', scale=0.2,visible=True, parent=self.pointcloudPD)
t = transformUtils.transformFromPose(array([-0.69100097, -0.43713269, -0.68495922]), array([ 0.98625075, 0. , 0. , -0.16525575]))
self.surpriseWalkBackFrame = vis.updateFrame(t, 'SurpriseWalkBack', scale=0.2,visible=True, parent=self.pointcloudPD)
t = transformUtils.transformFromPose(array([ 0.65827322, -0.08028796, -0.77370834]), array([ 0.94399977, 0. , 0. , -0.3299461 ]))
self.terrainPreWalkFrame = vis.updateFrame(t, 'TerrainPreWalk', scale=0.2,visible=True, parent=self.pointcloudPD)
t = transformUtils.transformFromPose(array([ 5.47126425, -0.09790393, -0.70504679]), array([ 1., 0., 0., 0.]))
self.stairsPreWalkFrame = vis.updateFrame(t, 'StairsPreWalk', scale=0.2,visible=True, parent=self.pointcloudPD)
self.frameSync = vis.FrameSync()
self.frameSync.addFrame(self.originFrame)
self.frameSync.addFrame(self.pointcloudPD.getChildFrame(), ignoreIncoming=True)
self.frameSync.addFrame(self.valveWalkFrame, ignoreIncoming=True)
self.frameSync.addFrame(self.drillPreWalkFrame, ignoreIncoming=True)
self.frameSync.addFrame(self.drillWalkFrame, ignoreIncoming=True)
self.frameSync.addFrame(self.drillWallWalkFarthestSafeFrame, ignoreIncoming=True)
self.frameSync.addFrame(self.drillWallWalkBackFrame, ignoreIncoming=True)
self.frameSync.addFrame(self.surprisePreWalkFrame, ignoreIncoming=True)
self.frameSync.addFrame(self.surpriseWalkFrame, ignoreIncoming=True)
self.frameSync.addFrame(self.surpriseWalkBackFrame, ignoreIncoming=True)
self.frameSync.addFrame(self.terrainPreWalkFrame, ignoreIncoming=True)
self.frameSync.addFrame(self.stairsPreWalkFrame, ignoreIncoming=True)
示例9: createUtorsoGazeConstraints
def createUtorsoGazeConstraints(self, tspan):
constraints = []
g = ik.WorldGazeDirConstraint()
g.linkName = 'utorso'
g.targetFrame = vtk.vtkTransform()
axes = transformUtils.getAxesFromTransform(self.polaris.leftFootEgressOutsideFrame.transform)
g.targetAxis = axes[0]
g.bodyAxis = [1,0,0]
g.coneThreshold = self.coneThreshold
g.tspan = tspan
constraints.append(g)
g = ik.WorldGazeDirConstraint()
g.linkName = 'utorso'
g.targetFrame = vtk.vtkTransform()
g.targetAxis = [0,0,1]
g.bodyAxis = [0,0,1]
g.coneThreshold = self.coneThreshold
g.tspan = tspan
constraints.append(g)
return constraints
示例10: getTransformFromNumpy
def getTransformFromNumpy(mat):
'''
Given a numpy 4x4 array, return a vtkTransform.
'''
m = vtk.vtkMatrix4x4()
for r in xrange(4):
for c in xrange(4):
m.SetElement(r, c, mat[r][c])
t = vtk.vtkTransform()
t.SetMatrix(m)
return t
示例11: onStartMappingButton
def onStartMappingButton(self):
msg = map_command_t()
msg.timestamp = getUtime()
msg.command = 0
lcmUtils.publish('KINECT_MAP_COMMAND', msg)
utime = self.queue.getCurrentImageTime('KINECT_RGB')
self.cameraToLocalInit = vtk.vtkTransform()
self.queue.getTransform('KINECT_RGB', 'local', utime, self.cameraToLocalInit)
vis.updateFrame(self.cameraToLocalInit, 'initial cam' )
print "starting mapping", utime
print self.cameraToLocalInit.GetPosition()
print self.cameraToLocalInit.GetOrientation()
示例12: frameFromPositionAndRPY
def frameFromPositionAndRPY(position, rpy):
'''
rpy specified in degrees
'''
rpy = [math.radians(deg) for deg in rpy]
angle, axis = botpy.roll_pitch_yaw_to_angle_axis(rpy)
t = vtk.vtkTransform()
t.PostMultiply()
t.RotateWXYZ(math.degrees(angle), axis)
t.Translate(position)
return t
示例13: getTransformFromAxes
def getTransformFromAxes(xaxis, yaxis, zaxis):
t = vtk.vtkTransform()
m = vtk.vtkMatrix4x4()
axes = np.array([xaxis, yaxis, zaxis]).transpose().copy()
vtk.vtkMath.Orthogonalize3x3(axes, axes)
for r in xrange(3):
for c in xrange(3):
m.SetElement(r, c, axes[r][c])
t.SetMatrix(m)
return t
示例14: transformFromPose
def transformFromPose(position, quaternion):
'''
Returns a vtkTransform
'''
rotationMatrix = np.zeros((3,3))
vtk.vtkMath.QuaternionToMatrix3x3(quaternion, rotationMatrix)
mat = np.eye(4)
mat[:3,:3] = rotationMatrix
mat[:3,3] = position
t = vtk.vtkTransform()
t.SetMatrix(mat.flatten())
return t
示例15: addTorus
def addTorus(self, radius, thickness, resolution=30):
q = vtk.vtkSuperquadricSource()
q.SetToroidal(1)
q.SetSize(radius)
q.SetThetaResolution(resolution)
# thickness doesnt seem to match to Eucliean units. 0 is none. 1 is full. .1 is a good valve
q.SetThickness(thickness)
q.Update()
# rotate Torus so that the hole axis (internally y), is set to be z, which we use for valves
transform = vtk.vtkTransform()
transform.RotateWXYZ(90,1,0,0)
transformFilter=vtk.vtkTransformPolyDataFilter()
transformFilter.SetTransform(transform)
transformFilter.SetInputConnection(q.GetOutputPort())
transformFilter.Update()
self.addPolyData(transformFilter.GetOutput())