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


Python wpilib.run函数代码示例

本文整理汇总了Python中wpilib.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: operatorControl

            Scheduler.getInstance().run()
            self.log()
            wpilib.Timer.delay(.005)

    def operatorControl(self):
        joystick = self.oi.getStick()

        while self.isOperatorControl() and self.isEnabled():
            self.log()
            Scheduler.getInstance().run()
            wpilib.Timer.delay(.005)

    def disabled(self):
        """Stuff to do whilst disabled."""

        while self.isDisabled():
            self.log()
            wpilib.Timer.delay(.005)

    def test(self):
        """No tests"""
        pass

    def log(self):
        """It's big, it's heavy, it's wood."""
        #SOMEDAY WE WILL FIGURE OUT LOGGING. I PROMISE.
        self.drivetrain.log()

if __name__ == "__main__":
    wpilib.run(OctoBot)
开发者ID:DenfeldRobotics4009,项目名称:octobot,代码行数:30,代码来源:robot.py

示例2: _tickDrive

        wpi.LiveWindow.run()

    def _tickDrive(self, joystickToUse):
        """
        Sets motor speeds and the like.
        Callable from both teleop and autonomous modes.
        """

        lDriveSpd = DriveManager.getDriveLeft(joystick=joystickToUse)
        self.lMotor0.set(lDriveSpd)
        self.lMotor1.set(lDriveSpd)

        rDriveSpd = DriveManager.getDriveRight(joystick=joystickToUse)
        self.rMotor0.set(rDriveSpd)
        self.rMotor1.set(rDriveSpd)

        ballMotorSpd = BallManager.getIntakeSpeed(joystick=joystickToUse)
        self.ballMotor.set(ballMotorSpd)

        leverSpd = BallManager.getEjectLeverSpeed(joystick=joystickToUse,
                                                  limit=self.leverLimit)
        self.ejectLever.set(leverSpd)

        armSpd = ArmManager.getArmSpeed(joystick=joystickToUse,
                                        upLimit=self.armUpperLimit,
                                        downLimit=self.armLowerLimit)
        self.armMotor.set(armSpd)

if __name__ == "__main__":
    wpi.run(LoRida)
开发者ID:4688,项目名称:frc2016,代码行数:30,代码来源:robot.py

示例3: abs

                if self.drivetrain.navX is not None:
                    angle = self.drivetrain.navX.getYaw()
                    angleDiff = (angle + 180) % 360 - 180  # How far the angle is from 0 TODO verify my math
                    if abs(angleDiff) > 10:  # TODO check if 10 is a good deadzone
                        kp = 0.03  # Proportional constant for how much to turn based on angle offset
                        forcedTurn = -angle*kp
                    else:
                        forcedTurn = None  # They were in the deadzone, and gyro is center, so force no turn at all

            if abs(self.mainDriverStick.getZ()) < 0.05 and self.wasTurning:  # We were turning, now we've stopped
                self.wasTurning = False

                Timer(0.75, lambda: self.drivetrain.navX.zero()).start()  # Zero the gyro in 0.75 seconds. Need to tune the time.

            if forcedTurn is not None:
                self.drivetrain.arcadeDrive(self.mainDriverStick, rotateAxis=2, invertTurn=True, rotateValue=forcedTurn)  # 2 is horizontal on the right stick
            else:
                self.drivetrain.arcadeDrive(self.mainDriverStick, invertTurn=True, rotateAxis=2)  # 2 is horizontal on the right stick

            if not TEST_BENCH:
                self.drivetrain.arcadeStrafe(self.mainDriverStick)
                self.lifter.arcadeDrive(self.copilotStick)

            wpilib.Timer.delay(.005)  # give time for the motor to update

if __name__ == "__main__":
    import codecs
    import sys
    sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
    wpilib.run(FlashRobot)
开发者ID:mstojcevich,项目名称:pyFlash,代码行数:30,代码来源:robot.py

示例4: teleopPeriodic

        logging.write_message("\nYOU MAY CONTROL ME FOR NOW BUT I WILL RETURN\n")

    def teleopPeriodic(self):
        # drive.drive.drive.drive.drive()
        self.drive.drive(self.drive_type)

        ## to catch button presses
        # to shoot, press A


#        if XboxButtons.A.poll():
#            Shooter.shoot(config.shoot_mtr, config.suck_mtr, config.shoot_sole)
# returns the wheels to the default position
#        if XboxButtons.X.poll():
#            self.drive.default()
# to suck, press B
#        if XboxButtons.B.poll():
#            Shooter.suck(config.shoot_mtr, config.suck_mtr, config.shoot_sole)
#        else:
#            Shooter.suck_stop(config.shoot_mtr, config.suck_mtr)
# raise/lower the arm
#        if XboxButtons.Y.poll():
#            Shooter.toggle_arm(config.drop_sole)
# to toggle logging to the Driver Station
#  press the Select button
#        if XboxButtons.Start.poll():
#            config.LOGGING = not config.LOGGING

if __name__ == "__main__":
    wpi.run(Myrobot)
开发者ID:ROBOMonkeys,项目名称:frc2016,代码行数:30,代码来源:robot.py

示例5: autonomous

    def autonomous(self):
        '''Called when autonomous mode is enabled'''
        
        timer = wpilib.Timer()
        timer.start()
        
        while self.isAutonomous() and self.isEnabled():
            
            if timer.get() < 2.0:
                self.robot_drive.mecanumDrive_Cartesian(0, -1, 1, 0)
            else:
                self.robot_drive.mecanumDrive_Cartesian(0, 0, 0, 0)
            
            wpilib.Timer.delay(0.01)

    def operatorControl(self):
        '''Called when operation control mode is enabled'''

        while self.isOperatorControl() and self.isEnabled():
            
            self.robot_drive.mecanumDrive_Cartesian(self.lstick.getX(), self.lstick.getY(), self.rstick.getX(), 0)

            wpilib.Timer.delay(0.04)


if __name__ == '__main__':
    
    wpilib.run(MyRobot,
               physics_enabled=True)

开发者ID:sarosenb,项目名称:pyfrc,代码行数:29,代码来源:robot.py

示例6: OperatorControl

        
        self.GetWatchdog().SetEnabled(False)
        while self.IsAutonomous() and self.IsEnabled():
            wpilib.Wait(0.01)

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

        while self.IsOperatorControl() and self.IsEnabled():
            dog.Feed()

            # Move a motor with a Joystick
            self.motor.Set(self.lstick.GetY())

            wpilib.Wait(0.04)

def run():
    
    robot = MyRobot()
    robot.StartCompetition()
    
    return robot


if __name__ == '__main__':
    wpilib.run()

开发者ID:RoboticsTeam4904,项目名称:2014-Code,代码行数:28,代码来源:robot.py

示例7: doAllElse

            self.loopCalls = 0

    def doAllElse(self):
        if not (abs(self.goalPosition - self.Talon.getEncPosition()) > 4000):
            self.goalPosition += self.Joystick.getY() * -1 * self.maxVelocity
        self.Talon.set(self.goalPosition)
        #self.Talon.set(self.Joystick.getY() * 10)

    def printAll(self):
        for i in range(0,5):
            print()
        print("Selection Number: " + str(self.PIDNumber) + "     P=0, I=1, D=2, F=3")
        print("P: " + str(self.Talon.getP()) + " I: " + str(self.Talon.getI()) + " D: " + str(self.Talon.getD()) + " F: " + str(self.Talon.getF()))
        print("Speed: " + str(self.Talon.getEncVelocity()))
        #print("Position Actual: " + str(self.Talon.getPosition()))
        #print("Position   Goal: " + str(self.goalPosition))
        print("Time Until Button: " + str(self.buttonAllowedTime - self.loopCalls))

    def changePID(self, number):
        if self.PIDNumber == 0:
            self.Talon.setP(self.Talon.getP() * number)
        elif self.PIDNumber == 1:
            self.Talon.setI(self.Talon.getI() * number)
        elif self.PIDNumber == 2:
            self.Talon.setD(self.Talon.getD() * number)
        elif self.PIDNumber == 3:
            self.Talon.setF(self.Talon.getF() * number)

if __name__ == "__main__":
    wpilib.run(Tester)
开发者ID:Seamonsters-2605,项目名称:CompetitionBot2016,代码行数:30,代码来源:robot.py

示例8: str

				 clock = -100

			#output to dashboard
			self.smartDs.putString("DB/String 0", "Left 1: " + str(wheelSpeed[0])[0:4])			 
			self.smartDs.putString("DB/String 1", "Left 2: " + str(wheelSpeed[2])[0:4])
			self.smartDs.putString("DB/String 2", "Right 1: " + str(wheelSpeed[1]*(-1))[0:4])   
			self.smartDs.putString("DB/String 3", "digR: " + str(self.leftSwitch.get())[0:5])
			self.smartDs.putString("DB/String 4", "At Pos: " + str(self.Vator.atPos()))
			
			self.smartDs.putString("DB/String 5", "liftVolt: " + str(self.Vator.getSpeed())[0:5])
			self.smartDs.putString("DB/String 6", "currentPos: " + str(self.Vator._encd.get())[0:5])
			self.smartDs.putString("DB/String 7", "wantPos: " + str(self.Vator.getPos())[0:5])
			
			#give motors value
			self.motorBackLeft.set(wheelSpeed[0]*motorGain)
			self.motorFrontLeft.set(wheelSpeed[2]*motorGain)
			self.motorBackRight.set(wheelSpeed[1]*(-1)*motorGain)
			self.motorFrontRight.set( wheelSpeed[3]*(-1)*motorGain)
			self.Vator.updateClause()
			self.feeders.updateClause()
			self.stick.updateClause()
			self.stick2.updateClause()
			self.cop.updateClause()
			
			#zero out value
			wheelSpeed = [0,0,0,0]
			wp.Timer.delay(0.005)   # wait 5ms to avoid hogging CPU cycles

if __name__ == '__main__':
	wp.run(MyRobot)
开发者ID:TheDragons,项目名称:2015,代码行数:30,代码来源:robot_good.py

示例9: Kooz2014

# For more information, check the LICENSE file in the root directory of
# this project.
#

import wpilib

import drive
import lifter
import shooter

class Kooz2014 (wpilib.IterativeRobot):        
    def robotInit (self):
        self.drive = drive.Drive()
        self.lifter = lifter.Lifter()
        self.shooter = shooter.Shooter()
        
        self.drive.setBrakeEnabled (True)
        self.shooter.setBrakeEnabled (True)
    
        self.drive.setSafetyEnabled (True)
        self.lifter.setSafetyEnabled (True)
        self.shooter.setSafetyEnabled (True)

    def teleopPeriodic (self):
        self.drive.moveWithJoystick (wpilib.Joystick (0))
        self.lifter.moveWithJoystick (wpilib.Joystick (1))
        self.shooter.moveWithJoystick (wpilib.Joystick (1))
        
if (__name__ == "__main__"):
    wpilib.run (Kooz2014)
开发者ID:WinT-3794,项目名称:KZ-2014-Python,代码行数:30,代码来源:robot.py

示例10: disabled

        joystick = self.oi.getStick()

        #Logging loop
        while self.isOperatorControl() and self.isEnabled():
            self.log()
            Scheduler.getInstance().run()
            wpilib.Timer.delay(.005) #don't burn up the cpu

    def disabled(self):
        """Code to run when disabled."""

        #Stop the drivetrain for safety's sake:
        self.drivetrain.driveManual(0,0,0)

        #Logging loop
        while self.isDisabled():
            self.log()
            wpilib.Timer.delay(.005) #don't burn up the cpu

    def test(self):
        """Code for testing."""
        pass

    def log(self):
        """I know it doesn't log but if it does eventually it'll go here."""
        #Log the things:
        self.drivetrain.log()

if __name__ == "__main__":
    wpilib.run(DosPointOh)
开发者ID:DenfeldRobotics4009,项目名称:2016_Dos_Point_Oh,代码行数:30,代码来源:robot.py

示例11: operatorControl

            self.log()
            wpilib.Timer.delay(.005) #don't burn up the cpu

    def operatorControl(self):
        """Teleop stuff goes in here"""

        #self.drivetrain.drive.setSafetyEnabled(True) - enables safety things for manual control
        joystick = self.oi.getStick()

        while self.isOperatorControl() and self.isEnabled():
            self.log()
            Scheduler.getInstance().run()
            wpilib.Timer.delay(.005) #don't burn up the cpu

    def disabled(self):
        """When the robot is disabled, this code runs"""
        while self.isDisabled():
            self.log()
            wpilib.Timer.delay(.005)

    def test(self):
        """Testing things would go here"""
        pass #There's no tests, so just pass

    def log(self):
        """Logging stuff goes here"""
        #self.subsystem.log()

if __name__ == "__main__":
    wpilib.run(RobotName)
开发者ID:DenfeldRobotics4009,项目名称:python-framework,代码行数:30,代码来源:robot.py

示例12: FlatMountainBot

#!/usr/bin/env python3

import wpilib
from os.path import dirname, abspath
from yeti.robots import YetiRobot


class FlatMountainBot(YetiRobot):
    config_dir = abspath(dirname(__file__))

if __name__ == "__main__":
    wpilib.run(FlatMountainBot)

开发者ID:computer-whisperer,项目名称:Alpinista-Python-2015,代码行数:12,代码来源:robot.py

示例13: autonomousPeriodic

    def autonomousPeriodic(self):
        pass

    def teleopInit(self):
        pass

    def teleopPeriodic(self):
        self.PR.printAll()
        current = self.PDP.getCurrent(0)
        self.MeccanumDrive.update(self.Joystick.getDirection(), self.Joystick.getMagnitude(), self.Joystick.getTurn(), self.Joystick.shouldStartBraking(), self.Joystick.getDriving())
        self.Joystick.updateDrivingState() #updates the WasDriving property to whether you were driving this call
        if (self.StrafeJoystick.getRawButton(3)):
            self.Lift.set(.5)
        elif (self.StrafeJoystick.getRawButton(2)):
            self.Lift.set(-.5)
        else:
            self.Lift.set(0)
        pass

    def testInit(self):
        pass

    def testPeriodic(self):
        pass

    def disabledInit(self):
        pass

if __name__ == "__main__":
    wpilib.run(Buttercraft)
开发者ID:Seamonsters-2605,项目名称:CodeDev2016,代码行数:30,代码来源:robot.py

示例14: array

        # run the optimization
        options["lims"] = array([[-1, 1],
                                 [-1, 1]])

        start_time = time.time()
        self.x, self.u, L, Vx, Vxx, cost = ilqg.ilqg(lambda x, u: dynamics_func(x, u), cost_func, x0, u0, options)
        self.i = 0
        print(self.x[-1])
        print("ilqg took {} seconds".format(time.time() - start_time))
        cost_graph(self.x)
        self.drive = wpilib.RobotDrive(0, 1)
        self.joystick = wpilib.Joystick(0)

    def autonomousInit(self):
        self.autostart = time.time()

    def autonomousPeriodic(self):
        time_elapsed = time.time() - self.autostart
        if time_elapsed < self.u.shape[0]*.1:
            self.drive.tankDrive(self.u[time_elapsed//.1, 0], -self.u[time_elapsed//.1, 1])
        else:
            self.drive.tankDrive(0, 0)

    def teleopPeriodic(self):
        self.drive.arcadeDrive(self.joystick)


if __name__ == "__main__":
    wpilib.run(IlqgRobot)
开发者ID:computer-whisperer,项目名称:integrated-dynamics,代码行数:29,代码来源:robot.py

示例15: check_restart

        dog.SetExpiration(0.25)

        while self.IsOperatorControl() and self.IsEnabled():
            dog.Feed()
            check_restart()

            precision_button = (controller.GetRawButton(5) or controller.GetRawButton(6))
            x = precision_mode(controller.GetRawAxis(1), precision_button)
            y = precision_mode(controller.GetRawAxis(2), precision_button)
            rotation = precision_mode(controller.GetRawAxis(4), precision_button)
            drive.MecanumDrive_Cartesian(x, y, rotation)

            solenoid_button = controller.GetRawButton(1)
            solenoid_in.Set(solenoid_button)
            solenoid_out.Set(not solenoid_button)

            rack.Set(precision_mode(controller.GetRawAxis(5), True))

            wheel_button = controller.GetRawButton(2)
            wheel.Set(1 if wheel_button else 0)

            wpilib.Wait(0.01)

def run():
    cubert = Cubert()
    cubert.StartCompetition()
    return cubert

if __name__ == "__main__":
    wpilib.run(min_version='2014.4.0')
开发者ID:DenfeldRobotics4009,项目名称:CubertPy,代码行数:30,代码来源:robot.py


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