Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, robot):
self.robot = robot
# Configure drive motors
self.frontLeftCIM = wpilib.Victor(1)
self.frontRightCIM = wpilib.Victor(2)
self.backLeftCIM = wpilib.Victor(3)
self.backRightCIM = wpilib.Victor(4)
wpilib.LiveWindow.addActuator("DriveTrain", "Front Left CIM", self.frontLeftCIM)
wpilib.LiveWindow.addActuator("DriveTrain", "Front Right CIM", self.frontRightCIM)
wpilib.LiveWindow.addActuator("DriveTrain", "Back Left CIM", self.backLeftCIM)
wpilib.LiveWindow.addActuator("DriveTrain", "Back Right CIM", self.backRightCIM)
# Configure the RobotDrive to reflect the fact that all our motors are
# wired backwards and our drivers sensitivity preferences.
self.drive = wpilib.RobotDrive(self.frontLeftCIM, self.frontRightCIM, self.backLeftCIM, self.backRightCIM)
self.drive.setSafetyEnabled(True)
self.drive.setExpiration(.1)
self.drive.setSensitivity(.5)
self.drive.setMaxOutput(1.0)
self.drive.setInvertedMotor(wpilib.RobotDrive.MotorType.kFrontLeft, True)
self.drive.setInvertedMotor(wpilib.RobotDrive.MotorType.kFrontRight, True)
self.drive.setInvertedMotor(wpilib.RobotDrive.MotorType.kRearLeft, True)
self.drive.setInvertedMotor(wpilib.RobotDrive.MotorType.kRearRight, True)
def __init__(self):
super().__init__()
self.motor = wpilib.Victor(7)
self.contact = wpilib.DigitalInput(5)
# Let's show everything on the LiveWindow
wpilib.LiveWindow.addActuator("Claw", "Motor", self.motor)
wpilib.LiveWindow.addActuator("Claw", "Limit Switch", self.contact)
def __init__(self, robot):
super().__init__()
self.robot = robot
# Configure Devices
self.hotGoalSensor = wpilib.DigitalInput(8)
self.piston1 = wpilib.DoubleSolenoid(0, 3, 4)
self.piston2 = wpilib.DoubleSolenoid(0, 5, 6)
self.latchPiston = wpilib.Solenoid(0, 2)
self.piston1ReedSwitchFront = wpilib.DigitalInput(9)
self.piston1ReedSwitchBack = wpilib.DigitalInput(11)
# Put everything to the LiveWindow for testing.
wpilib.LiveWindow.addSensor("Shooter", "Hot Goal Sensor",
self.hotGoalSensor)
wpilib.LiveWindow.addSensor("Shooter", "Piston1 Reed Switch Front",
self.piston1ReedSwitchFront)
wpilib.LiveWindow.addSensor("Shooter", "Piston1 Reed Switch Back",
self.piston1ReedSwitchBack)
wpilib.LiveWindow.addActuator("Shooter", "Latch Piston",
self.latchPiston)
def testPeriodic(self):
"""This function is called periodically during test mode."""
wpilib.LiveWindow.run()
def testPeriodic(self):
"""This function is called periodically during test mode."""
wpilib.LiveWindow.run()
def __init__(self, robot):
# Configure devices
self.rollerMotor = wpilib.Victor(6)
self.ballDetector = wpilib.DigitalInput(10)
self.openDetector = wpilib.DigitalInput(6)
self.piston = wpilib.Solenoid(0, 1)
self.robot = robot
# Put everything to the LiveWindow for testing.
wpilib.LiveWindow.addActuator("Collector", "Roller Motor", self.rollerMotor)
wpilib.LiveWindow.addSensor("Collector", "Ball Detector", self.ballDetector)
wpilib.LiveWindow.addSensor("Collector", "Claw Open Detector", self.openDetector)
wpilib.LiveWindow.addActuator("Collector", "Piston", self.piston)
super().__init__()
self.robot = robot
# Configure Devices
self.hotGoalSensor = wpilib.DigitalInput(8)
self.piston1 = wpilib.DoubleSolenoid(0, 3, 4)
self.piston2 = wpilib.DoubleSolenoid(0, 5, 6)
self.latchPiston = wpilib.Solenoid(0, 2)
self.piston1ReedSwitchFront = wpilib.DigitalInput(9)
self.piston1ReedSwitchBack = wpilib.DigitalInput(11)
# Put everything to the LiveWindow for testing.
wpilib.LiveWindow.addSensor("Shooter", "Hot Goal Sensor",
self.hotGoalSensor)
wpilib.LiveWindow.addSensor("Shooter", "Piston1 Reed Switch Front",
self.piston1ReedSwitchFront)
wpilib.LiveWindow.addSensor("Shooter", "Piston1 Reed Switch Back",
self.piston1ReedSwitchBack)
wpilib.LiveWindow.addActuator("Shooter", "Latch Piston",
self.latchPiston)
self.ahrs = AHRS.create_spi()
#self.ahrs = AHRS.create_i2c()
turnController = wpilib.PIDController(self.kP, self.kI, self.kD, self.kF, self.ahrs, output=self)
turnController.setInputRange(-180.0, 180.0)
turnController.setOutputRange(-1.0, 1.0)
turnController.setAbsoluteTolerance(self.kToleranceDegrees)
turnController.setContinuous(True)
self.turnController = turnController
# Add the PID Controller to the Test-mode dashboard, allowing manual */
# tuning of the Turn Controller's P, I and D coefficients. */
# Typically, only the P value needs to be modified. */
wpilib.LiveWindow.addActuator("DriveSystem", "RotateController", turnController)
def __init__(self):
super().__init__()
self.motor = wpilib.Victor(7)
self.contact = wpilib.DigitalInput(5)
# Let's show everything on the LiveWindow
wpilib.LiveWindow.addActuator("Claw", "Motor", self.motor)
wpilib.LiveWindow.addActuator("Claw", "Limit Switch", self.contact)
def __init__(self, robot):
self.robot = robot
# Configure drive motors
self.frontLeftCIM = wpilib.Victor(1)
self.frontRightCIM = wpilib.Victor(2)
self.backLeftCIM = wpilib.Victor(3)
self.backRightCIM = wpilib.Victor(4)
wpilib.LiveWindow.addActuator("DriveTrain", "Front Left CIM", self.frontLeftCIM)
wpilib.LiveWindow.addActuator("DriveTrain", "Front Right CIM", self.frontRightCIM)
wpilib.LiveWindow.addActuator("DriveTrain", "Back Left CIM", self.backLeftCIM)
wpilib.LiveWindow.addActuator("DriveTrain", "Back Right CIM", self.backRightCIM)
# Configure the RobotDrive to reflect the fact that all our motors are
# wired backwards and our drivers sensitivity preferences.
self.drive = wpilib.RobotDrive(self.frontLeftCIM, self.frontRightCIM, self.backLeftCIM, self.backRightCIM)
self.drive.setSafetyEnabled(True)
self.drive.setExpiration(.1)
self.drive.setSensitivity(.5)
self.drive.setMaxOutput(1.0)
self.drive.setInvertedMotor(wpilib.RobotDrive.MotorType.kFrontLeft, True)
self.drive.setInvertedMotor(wpilib.RobotDrive.MotorType.kFrontRight, True)
self.drive.setInvertedMotor(wpilib.RobotDrive.MotorType.kRearLeft, True)
self.drive.setInvertedMotor(wpilib.RobotDrive.MotorType.kRearRight, True)
# Configure encoders
self.rightEncoder = wpilib.Encoder(1, 2,
reverseDirection=True,