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


Python Drive.stop方法代码示例

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


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

示例1: MyRobot

# 需要导入模块: from drive import Drive [as 别名]
# 或者: from drive.Drive import stop [as 别名]
class MyRobot(wpilib.SimpleRobot):
    def __init__(self):
        super().__init__()
        self.loader = Loader()
        self.shooter = Shooter()
        self.drive = Drive(config.robotDrive, config.leftJoy, config.hsButton,
                           config.alignButton)
        self.componets = [ self.loader, self.shooter, self.drive ]

    def RobotInit(self):
        wpilib.Wait(0.25)
        shooterEncoder.Start()

    def Disabled(self):
        while wpilib.IsDisabled():
            CheckRestart()
            wpilib.Wait(0.01)

    def Autonomous(self):
        while wpilib.IsAutonomous() and wpilib.IsEnabled():
            CheckRestart()
            wpilib.Wait(0.01)

    def OperatorControl(self):
        dog = self.GetWatchdog()
        dog.SetEnabled(True)
        dog.SetExpiration(0.25)

        self.drive.stop()
        shooterMotor.Set(0)
        tipperMotor.Set(0)
        rollerMotor.Set(0)

        while self.IsOperatorControl() and self.IsEnabled():
            dog.Feed()
            CheckRestart()
            for componet in self.componets:
                componet.tick()

            #Teleop Code
            #if not self.drive.aligning :
            #    self.drive.arcadeDrive(leftJoy.GetRawButton(halfSpeed))
            shooterMotor.Set(rightJoy.GetY())

            ## Alignment
            #if leftJoy.GetRawButton(allignButton) :
            #    if not self.drive.aligning:
            #        self.drive.aligning = True
            #        robotDrive.StopMotor()
            #    self.drive.align()
            #else:
            #    self.drive.aligning = False

            ## Tipper Up and Down
            if rightJoy.GetRawButton(tipperUp):
                tipperMotor.Set(-1)
            elif rightJoy.GetRawButton(tipperDown):
                tipperMotor.Set(1)
            else:
                tipperMotor.Set(0)

            ## Roller Up and Down
            if rightJoy.GetRawButton(rollerUpButton):
                rollerMotor.Set(-1)
            elif rightJoy.GetRawButton(rollerDownButton):
                rollerMotor.Set(1)
            else:
                rollerMotor.Set(0)

            ## Loading
            if rightJoy.GetRawButton(feederButton):
                self.loader.load()

            ## Shooting
            if rightJoy.GetRawButton(latchButton):
                self.shooter.unlatch()

            ## Debug & Tuning

            wpilib.Wait(0.01)
开发者ID:HappyFox,项目名称:2012_basket_ball_robot,代码行数:82,代码来源:robot.py


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