本文整理汇总了Python中Robot.Robot.dropRobot方法的典型用法代码示例。如果您正苦于以下问题:Python Robot.dropRobot方法的具体用法?Python Robot.dropRobot怎么用?Python Robot.dropRobot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Robot.Robot
的用法示例。
在下文中一共展示了Robot.dropRobot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Robot import Robot [as 别名]
# 或者: from Robot.Robot import dropRobot [as 别名]
class Simulation:
def __init__(self):
'''Uses VPython to visualize, manipulate and simulate the Quadruped live.'''
self.bodies = []
self.cWorld = myWorld()
self.createUI(self.cWorld.world._getScene())
# terrain for future implementation
#self.myWorld = e.Heightmap(self.cWorld.world)
#self.Terrain = self.myWorld.makeWorld()
self.cRobot = Robot(self.cWorld.world, vpyode._bigSpace, 50)
self.cCtrl = ControlWindow(self.cWorld.world._getScene(), self.cRobot, self.cWorld)
self.cRobot.dropRobot()
self.dt = 1.0/const.framerate
self.refresh = 0
self.bodies.append(e.drop_object(self.cWorld.world, self.cRobot.center))
def startLoop(self):
itemcount = 0
count = random.uniform(1,50)
random.seed()
while(1):
visual.rate(const.framerate) # Frame rate
# check for events, drive actions; must be executed repeatedly in a loop
self.cCtrl.ctrls.interact()
# do multiple simulation steps per frame to prevent jittering due to
# 'small' collisions
n = 6
if itemcount < count:
itemcount += 1
self.bodies.append(e.drop_object(self.cWorld.world, self.cRobot.center))
itemcount+=1
if itemcount == 500:
itemcount = 0
for b in self.bodies:
for body in b.GetElementKeys():
b.RemoveElement(body)
self.bodies = []
for i in range(n):
# Simulation step
self.cWorld.world.step(self.dt/n)
# terrain for future implementation
#self.Terrain.UpdateDisplay()
if self.cRobot.bodyExists():
self.cRobot.refreshRobot(self.cCtrl.lBody)
if (self.cRobot.centerRobot):
self.cWorld.world._getScene().center = self.cRobot.center
for leg in self.cRobot.tibia:
leg.UpdateDisplay()
for leg in self.cRobot.femur:
leg.UpdateDisplay()
for b in self.bodies:
b.UpdateDisplay()
def setupWindow(self, scene):
scene.title = 'Quadruped Simulation'
scene.height = const.windowHeight
scene.width = const.windowWidth
scene.autoscale = 0
scene.forward = (-5,-5,-5)
scene.background = (0.0,0.0,0.0)
self.createFloor()
self.createArrows()
def createFloor(self):
Grid.grid(500)
def createArrows(self):
''' Create arrow coordinates '''
visual.arrow(pos=(0,0,0), axis=(1,0,0), radius=1, color=(0,0,1), length=3)
visual.arrow(pos=(0,0,0), axis=(0,1,0), radius=1, color=(1,0,0), length=3)
visual.arrow(pos=(0,0,0), axis=(0,0,1), radius=1, color=(0,1,0), length=3)
visual.controls.label(pos = (3,0,0), text='x',box=False, opacity=0.0)
visual.controls.label(pos = (0,3,0), text='y',box=False, opacity=0.0)
visual.controls.label(pos = (0,0,3), text='z',box=False, opacity=0.0)
def createUI(self, scene):
'''Setup window and controls'''
self.setupWindow(scene)
#.........这里部分代码省略.........