How to use the wpilib.Timer.delay function in wpilib

To help you get started, we’ve selected a few wpilib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github robotpy / pyfrc / samples / physics-4wheel / src / robot.py View on Github external
def operatorControl(self):
        '''Called when operation control mode is enabled'''
        
        while self.isOperatorControl() and self.isEnabled():
            
            self.robot_drive.tankDrive(self.lstick, self.rstick)

            wpilib.Timer.delay(0.04)
github robotpy / robotpy-wpilib-utilities / samples / navx_rotate_to_angle / robot.py View on Github external
if rotateToAngle:
                self.turnController.enable()
                currentRotationRate = self.rotateToAngleRate
            else:
                self.turnController.disable()
                currentRotationRate = self.stick.getTwist()
            
            # Use the joystick X axis for lateral movement,
            # Y axis for forward movement, and the current
            # calculated rotation rate (or joystick Z axis),
            # depending upon whether "rotate to angle" is active.
            self.myRobot.mecanumDrive_Cartesian(self.stick.getX(), self.stick.getY(), 
                                                currentRotationRate, self.ahrs.getAngle())
            
            wpilib.Timer.delay(0.005) # wait for a motor update time
github robotpy / pyfrc / samples / physics-mecanum / src / robot.py View on Github external
def disabled(self):
        '''Called when the robot is disabled'''
        while self.isDisabled():
            wpilib.Timer.delay(0.01)
github robotpy / pyfrc / samples / physics / src / robot.py View on Github external
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.arcadeDrive(-1.0, -.3)
            else:
                self.robot_drive.arcadeDrive(0, 0)
            
            wpilib.Timer.delay(0.01)
github robotpy / robotpy-wpilib / examples / examples / QuickVision / robot.py View on Github external
def operatorControl(self):
        while self.isOperatorControl() and self.isEnabled():
            wpilib.Timer.delay(0.02) # wait for a motor update time
github robotpy / robotpy-wpilib / examples / examples / MotorControl / robot.py View on Github external
def operatorControl(self):
        '''Runs the motor from a joystick.'''
        
        while self.isOperatorControl() and self.isEnabled():
            
            # Set the motor's output.
            # This takes a number from -1 (100% speed in reverse) to
            # +1 (100% speed going forward)
            
            self.motor.set(self.stick.getY())
            
            wpilib.Timer.delay(self.kUpdatePeriod)  # wait 5ms to the next update
github robotpy / robotpy-wpilib-utilities / robotpy_ext / common_drivers / navx / registerio_spi.py View on Github external
def read(self, first_address, count):
        
        data = [first_address, count]
        data.append(crc7(data))
        retcount = self.port.write(data)
        if retcount != len(data):
            raise IOError("Write error (%s != %s)" % (retcount, len(data)))
        
        Timer.delay(0.001)
        
        data = self.port.read(True, count + 1)
        if len(data) != count + 1:
            raise IOError("Read error (%s != %s)" % (len(data), count+1))
        
        crc = data[-1]
        data = data[:-1]
        
        if crc7(data) != crc:
            raise IOError("CRC error")
        
        return data
github robotpy / pyfrc / samples / physics-mecanum / src / robot.py View on Github external
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)
github robotpy / pyfrc / samples / physics / src / robot.py View on Github external
def disabled(self):
        '''Called when the robot is disabled'''
        while self.isDisabled():
            wpilib.Timer.delay(0.01)