当前位置: 首页>>代码示例>>Python>>正文


Python Driver.forward方法代码示例

本文整理汇总了Python中driver.Driver.forward方法的典型用法代码示例。如果您正苦于以下问题:Python Driver.forward方法的具体用法?Python Driver.forward怎么用?Python Driver.forward使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在driver.Driver的用法示例。


在下文中一共展示了Driver.forward方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: rGPIO

# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import forward [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)
开发者ID:bb23,项目名称:bb23,代码行数:54,代码来源:gpiomanager.py

示例2: Driver

# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import forward [as 别名]
from driver import Driver


if (__name__ == "__main__"):
        robot1 = Driver() 
        while(True):
            robot1.forward()
            time.sleep(.2)
            robot1.right()
            time.sleep(1)
            robot1.backward()
            time.sleep(.2)
            robot1.backRight()
            time.sleep(1)
            robot1.forward()
            time.sleep(.2)
            robot1.right()
            time.sleep(1)
            robot1.backward()
            time.sleep(.2)
            robot1.backRight()
            time.sleep(1)
            robot1.stop()
            robot1.forward()
            time.sleep(.2)
            robot1.left()
            time.sleep(1)
            robot1.backward()
            time.sleep(.2)
            robot1.backLeft()
            time.sleep(1)
开发者ID:SlightlyCyborg,项目名称:Random-Files,代码行数:33,代码来源:play_with_driver.py


注:本文中的driver.Driver.forward方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。