本文整理汇总了Python中car.Car.reset_motors方法的典型用法代码示例。如果您正苦于以下问题:Python Car.reset_motors方法的具体用法?Python Car.reset_motors怎么用?Python Car.reset_motors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类car.Car
的用法示例。
在下文中一共展示了Car.reset_motors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import reset_motors [as 别名]
def main(argv):
try:
opts, args = getopt.getopt(argv, "ht:d", ["help", "tests="])
except getopt.GetoptError:
usage()
sys.exit(2)
tests = ["direction", "power", "rates"]
# configure gpio mode
gpio.setmode(gpio.BOARD)
for opt, arg in opts:
if opt in ("-h", "--help"):
usage()
sys.exit()
elif opt in ("-t", "--tests"):
tests = string.split(arg)
print 'Running tests %s' % tests
car = Car()
if "direction" in tests:
print '.Diagnostics: motor control & powering'
print 'steer_left'
car.steer_left()
time.sleep(1)
print 'steer_right'
car.steer_right()
time.sleep(1)
car.reset_motors()
if "power" in tests:
print 'go_forward'
car.go_forward()
time.sleep(1)
print 'go_backward'
car.go_backward()
time.sleep(1)
car.reset_motors()
if "rates" in tests:
print '.Diagnostics: motor servo rate'
car.set_speed(2)
time.sleep(1)
car.set_speed(3)
time.sleep(1)
car.set_speed(4)
time.sleep(1)
# Finally reset the motors again.
car.reset_motors()