本文整理汇总了Python中Move.Move.executeCommand方法的典型用法代码示例。如果您正苦于以下问题:Python Move.executeCommand方法的具体用法?Python Move.executeCommand怎么用?Python Move.executeCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Move.Move
的用法示例。
在下文中一共展示了Move.executeCommand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MotionInterface
# 需要导入模块: from Move import Move [as 别名]
# 或者: from Move.Move import executeCommand [as 别名]
class MotionInterface(object):
def __init__(self, mode=1):
self._Height = 75
self._Length = 65
self._DefaultPulse = 375
self._Multiplier = 1
self._currentModeInt = mode
pulses = self.calculatePulse(self._Height, self._Length)
self._Legs = [
Leg([0x41, 0x41, 0x41], [0, 1, 2], [375, pulses[0], pulses[1]], [0, 0, 0]), #leg 1
Leg([0x40, 0x40, 0x40], [0, 1, 2], [375, pulses[0], pulses[1]], True, [0, 0, 0]), #leg 2
Leg([0x41, 0x41, 0x41], [4, 5, 6], [375, pulses[0], pulses[1]], [0, 0, 0]), #leg 3
Leg([0x40, 0x40, 0x40], [4, 5, 6], [375, pulses[0], pulses[1]], True, [0, 0, 0]), #leg 4
Leg([0x41, 0x41, 0x41], [8, 9, 10], [375, pulses[0], pulses[1]], [0, 0, 0]), #leg 5
Leg([0x40, 0x40, 0x40], [8, 9, 10], [375, pulses[0], pulses[1]], True, [0, 0, 0]), #leg 6
]
self._CurrentCommand = 10
self._Exit = False
self._Semaphore = threading.Semaphore(1)
self._ExitSemaphore = threading.Semaphore(1)
self.SleepTime = 0.0005
if mode == 1:
self._CurrentMode = Move(self)
if mode == 2:
self._CurrentMode = FingerControl(self)
if mode == 3:
self._CurrentMode = SpiderGap(self)
if mode == 4:
self._CurrentMode = Dance(self)
if mode == 5:
self._CurrentMode = BalloonRace(self)
if mode == 6:
self._CurrentMode = Move(self)
if mode == 7:
self._CurrentMode = Move(self)
if mode == 8:
self._CurrentMode = Dance2(self)
if mode == 9:
self._CurrentMode = SpiderGap2(self)
def get_CurrentCommand(self):
self._Semaphore.acquire()
try:
if self._CurrentCommand is None:
self._Semaphore.release()
return 10
else:
temp = self._CurrentCommand
self._Semaphore.release()
return temp
except:
return 10
def set_CurrentCommand(self, _CurrentCommand):
self._Semaphore.acquire()
self._CurrentCommand = _CurrentCommand
self._Semaphore.release()
return "Command " + str(_CurrentCommand) + " has been received"
def runThread(self):
self._ExitSemaphore.acquire()
while self.isExited() == False:
self._CurrentMode.executeCommand(self.get_CurrentCommand())
self._ExitSemaphore.release()
time.sleep(0.001)
def exit(self):
self._ExitSemaphore.acquire()
self._Exit = True
self._CurrentMode.exit()
self._ExitSemaphore.release()
def getSemaphore(self):
return self._Semaphore
def getExitSemaphore(self):
return self._ExitSemaphore
def isExited(self):
return self._Exit
def setHeight(self, height):
try:
height = int(height)
except:
height = self._Height
if height < 40:
self._Height = 40
elif height > 150:
self._Height = 150
else:
self._Height = height
self.set_CurrentCommand(9)
def getHeight(self):
#.........这里部分代码省略.........