本文整理匯總了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()