本文整理汇总了Python中driver.Driver.turn_left方法的典型用法代码示例。如果您正苦于以下问题:Python Driver.turn_left方法的具体用法?Python Driver.turn_left怎么用?Python Driver.turn_left使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类driver.Driver
的用法示例。
在下文中一共展示了Driver.turn_left方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rGPIO
# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import turn_left [as 别名]
class rGPIO(object):
def __init__(self, logger):
self.logger = logger
logger.info("Starting GPIODaemon...")
self.driver = Driver()
logger.info("Initialized driver")
def handle_cmd(self, cmd):
# New handle command class that's simpler
cmd = cmd.strip()
self.logger.info("cmd: '%s'" % cmd)
return self._handle_cmd(cmd)
def _handle_cmd(self, internal_cmd):
# Internal cmd is the actual command (triggered by the user command).
# Any return value will be sent to the socket connection.
self.logger.info("execute> %s" % internal_cmd)
cmd_parts = internal_cmd.split(" ")
cmd = cmd_parts[0]
if cmd == "forward":
self.logger.info("in command forward")
self.driver.forward()
return "going forward"
elif cmd == "turn_left":
self.logger.info("in command turn_left")
self.driver.turn_left()
return "turn left"
elif cmd == "turn_right":
self.logger.info("in command turn_right")
self.driver.turn_right()
return "turning_right"
elif cmd == "stop":
self.logger.info("in command stop")
self.driver.stop()
return "stop"
elif cmd == "backward":
self.logger.info("in command backward")
self.driver.backward()
return "backwards"
else:
self.logger.warn("command '%s' not recognized", cmd)