本文整理汇总了Python中motor.Motor.set_throttle方法的典型用法代码示例。如果您正苦于以下问题:Python Motor.set_throttle方法的具体用法?Python Motor.set_throttle怎么用?Python Motor.set_throttle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类motor.Motor
的用法示例。
在下文中一共展示了Motor.set_throttle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from motor import Motor [as 别名]
# 或者: from motor.Motor import set_throttle [as 别名]
class ZMQMotor:
def __init__(self, address, pin, maxthrottle=200, minthrottle=500, name="motor"):
self.name = name
self.address = address
self.server = ZMQServer(address)
self.motor = Motor(pin, minthrottle, maxthrottle)
self.motor.setmin()
self.quit = False
self.engage()
def engage(self):
self.mainloop()
def mainloop(self):
while not self.quit:
try:
message = self.server.receive()
self.process_msg(message)
self.reply(message)
time.sleep(1)
except ZMQError as e:
pass
self.destroy()
def process_msg(self, message):
match = THROTTLE_REGEX.match(message)
print "Received message: " + message
if message == "laputanmachine":
self.quit=True
elif match:
throttle = int(match.group('throttle'))
self.motor.set_throttle(throttle)
else:
print message
def reply(self, message):
self.server.reply(message)
def destroy(self):
self.motor.stop()
self.server.destroy()
示例2: Motor
# 需要导入模块: from motor import Motor [as 别名]
# 或者: from motor.Motor import set_throttle [as 别名]
#standard modules
import sys
import time
#my modules
from motor import Motor
import util
m = Motor(17, 500, 200)
m.set_throttle(m.minthrottle)
r = raw_input("Press a key to continue")
curthrottle=500
while(curthrottle > 350):
curthrottle = util.intlerp(curthrottle, 340, 0.1)
print curthrottle
m.set_throttle(curthrottle)
time.sleep(0.2)
while(curthrottle < 450):
curthrottle = util.intlerp(curthrottle, 460, 0.1)
print curthrottle
m.set_throttle(curthrottle)
time.sleep(0.2)
m.set_throttle(500)
m.stop()