def __init__(self): super().__init__() self.dog = self.GetWatchdog() self.stick1 = wpilib.Joystick(1) self.stick2 = wpilib.Joystick(2) self.stick3 = wpilib.Joystick(3) self.leftArmStick = wpilib.KinectStick(1) self.rightArmStick = wpilib.KinectStick(2) self.motor1 = wpilib.CANJaguar(1) self.motor2 = wpilib.CANJaguar(2) self.leftArm = wpilib.Servo(1) self.rightArm = wpilib.Servo(2) self.leftLeg = wpilib.Servo(3) self.rightLeg = wpilib.Servo(4) self.spinner = wpilib.Servo(5) self.compressor = wpilib.Compressor(1, 1) self.compressor.Start() self.relayMotor = wpilib.Relay(2) self.solenoid1 = wpilib.Solenoid(1) self.solenoid2 = wpilib.Solenoid(2)
def __init__(self): super().__init__() print("Matt the fantastic ultimate wonderful humble person") wpilib.SmartDashboard.init() #self.digitalInput=wpilib.DigitalInput(4) self.CANJaguar = wpilib.CANJaguar(1) self.gyro = wpilib.Gyro(1) self.joystick = wpilib.Joystick(1) self.joystick2 = wpilib.Joystick(2) self.jaguar = wpilib.Jaguar(1) self.accelerometer = wpilib.ADXL345_I2C(1, wpilib.ADXL345_I2C.kRange_2G) self.solenoid = wpilib.Solenoid(7) self.solenoid2 = wpilib.Solenoid(8) self.p = 1 self.i = 0 self.d = 0 wpilib.SmartDashboard.PutBoolean('Soleinoid 1', False) wpilib.SmartDashboard.PutBoolean('Soleinoid 2', False) #self.pid = wpilib.PIDController(self.p, self.i, self.d, self.gyro, self.jaguar) self.sensor = wpilib.AnalogChannel(5) self.ballthere = False
def __init__ (self): ''' Constructor. ''' super().__init__() print("Team 1418 robot code for 2014") ################################################################# # THIS CODE IS SHARED BETWEEN THE MAIN ROBOT AND THE ELECTRICAL # # TEST CODE. WHEN CHANGING IT, CHANGE BOTH PLACES! # ################################################################# wpilib.SmartDashboard.init() # Joysticks self.joystick1 = wpilib.Joystick(1) self.joystick2 = wpilib.Joystick(2) # Motors self.lf_motor = wpilib.Jaguar(1) self.lf_motor.label = 'lf_motor' self.lr_motor = wpilib.Jaguar(2) self.lr_motor.label = 'lr_motor' self.rr_motor = wpilib.Jaguar(3) self.rr_motor.label = 'rr_motor' self.rf_motor = wpilib.Jaguar(4) self.rf_motor.label = 'rf_motor' self.winch_motor = wpilib.CANJaguar(5) self.winch_motor.label = 'winch' self.intake_motor = wpilib.Jaguar(6) self.intake_motor.label = 'intake' # Catapult gearbox control self.gearbox_solenoid=wpilib.DoubleSolenoid(2, 1) self.gearbox_solenoid.label = 'gearbox' # Arm up/down control self.vent_bottom_solenoid = wpilib.Solenoid(3) self.vent_bottom_solenoid.label = 'vent bottom' self.fill_bottom_solenoid = wpilib.Solenoid(4) self.fill_bottom_solenoid.label = 'fill bottom' self.fill_top_solenoid = wpilib.Solenoid(5) self.fill_top_solenoid.label = 'fill top' self.vent_top_solenoid = wpilib.Solenoid(6) self.vent_top_solenoid.label = 'vent top' self.pass_solenoid = wpilib.Solenoid(7) self.pass_solenoid.label = 'pass' self.robot_drive = wpilib.RobotDrive(self.lr_motor, self.rr_motor, self.lf_motor, self.rf_motor) self.robot_drive.SetSafetyEnabled(False) self.robot_drive.SetInvertedMotor(wpilib.RobotDrive.kFrontLeftMotor, True) self.robot_drive.SetInvertedMotor(wpilib.RobotDrive.kRearLeftMotor, True) # Sensors self.gyro = wpilib.Gyro(1) self.ultrasonic_sensor = wpilib.AnalogChannel(3) self.ultrasonic_sensor.label = 'Ultrasonic' self.arm_angle_sensor = wpilib.AnalogChannel(4) self.arm_angle_sensor.label = 'Arm angle' self.ball_sensor = wpilib.AnalogChannel(6) self.ball_sensor.label = 'Ball sensor' self.accelerometer = wpilib.ADXL345_I2C(1, wpilib.ADXL345_I2C.kRange_2G) self.compressor = wpilib.Compressor(1,1) ################################################################# # END SHARED CODE # ################################################################# # # Initialize robot components here # self.drive = drive.Drive(self.robot_drive, self.ultrasonic_sensor,self.gyro) self.initSmartDashboard() self.pushTimer=wpilib.Timer() self.catapultTimer=wpilib.Timer() self.catapult=catapult.Catapult(self.winch_motor,self.gearbox_solenoid,self.pass_solenoid,self.arm_angle_sensor,self.ball_sensor,self.catapultTimer) self.intakeTimer=wpilib.Timer() self.intake=intake.Intake(self.vent_top_solenoid,self.fill_top_solenoid,self.fill_bottom_solenoid,self.vent_bottom_solenoid,self.intake_motor,self.intakeTimer) self.pulldowntoggle=False self.components = { 'drive': self.drive, 'catapult': self.catapult, 'intake': self.intake } self.control_loop_wait_time = 0.025 self.autonomous = AutonomousModeManager(self.components)
try: import wpilib except ImportError: import fake_wpilib as wpilib #pas import wpilib lstick = wpilib.Joystick(1) motor = wpilib.CANJaguar(8) analog = wpilib.AnalogChannel(1) class MotorOutput(wpilib.PIDOutput): def __init__(self, motor): super().__init__() self.motor = motor def PIDWrite(self, output): self.motor.Set(output) class AnalogSource(wpilib.PIDSource): def __init__(self, analog): super().__init__() self.analog = analog def PIDGet(self): return analog.GetVoltage()
import wpilib lstick = wpilib.Joystick(1) rstick = wpilib.Joystick(2) stick3 = wpilib.Joystick(3) shifter1 = wpilib.Solenoid(7, 1) shifter2 = wpilib.Solenoid(7, 2) leftFrontMotor = wpilib.CANJaguar(2) leftRearMotor = wpilib.CANJaguar(7) rightFrontMotor = wpilib.CANJaguar(4) rightRearMotor = wpilib.CANJaguar(6) compressor = wpilib.Compressor(8, 1) drive = wpilib.RobotDrive(leftFrontMotor, leftRearMotor, rightFrontMotor, rightRearMotor) def checkRestart(): if lstick.GetRawButton(10): raise RuntimeError("Restart") def disabled(): while wpilib.IsDisabled(): checkRestart() wpilib.Wait(0.01)
import wpilib from DualSpeedController import DualSpeedController from EncoderSource import EncoderSource from WinchOutput import WinchOutput # Joysticks lstick = wpilib.Joystick(1) rstick = wpilib.Joystick(2) stick3 = wpilib.Joystick(3) # Motors and drive system leftFrontMotor = wpilib.CANJaguar(2) leftRearMotor = wpilib.CANJaguar(7) leftMotor = DualSpeedController(leftFrontMotor, leftRearMotor, 1) rightFrontMotor = wpilib.CANJaguar(4) rightRearMotor = wpilib.CANJaguar(6) rightMotor = DualSpeedController(rightFrontMotor, rightRearMotor, 2) kickerMotor1 = wpilib.CANJaguar(5) kickerMotor2 = wpilib.CANJaguar(8) kickerMotor = DualSpeedController(kickerMotor1, kickerMotor2, 3) intakeMotor = wpilib.CANJaguar(3) drive = wpilib.RobotDrive(leftMotor, rightMotor) # Pneumatics shifter1 = wpilib.Solenoid(7, 1) shifter2 = wpilib.Solenoid(7, 2) ratchet1 = wpilib.Solenoid(7, 3) ratchet2 = wpilib.Solenoid(7, 4) compressor = wpilib.Compressor(8, 1)
def __init__(self): ''' initialize things''' super().__init__() print("Electrical test program -- don't use for competition!") ################################################################# # THIS CODE IS SHARED BETWEEN THE MAIN ROBOT AND THE ELECTRICAL # # TEST CODE. WHEN CHANGING IT, CHANGE BOTH PLACES! # ################################################################# wpilib.SmartDashboard.init() # Joysticks self.joystick1 = wpilib.Joystick(1) self.joystick2 = wpilib.Joystick(2) # Motors self.lf_motor = wpilib.Jaguar(1) self.lr_motor = wpilib.Jaguar(2) self.rr_motor = wpilib.Jaguar(3) self.rf_motor = wpilib.Jaguar(4) self.winch_motor = wpilib.CANJaguar(5) self.intake_motor = wpilib.Jaguar(6) # Catapult gearbox control self.gearbox_in_solenoid = wpilib.Solenoid(1) self.gearbox_out_solenoid = wpilib.Solenoid(2) # Arm up/down control self.vent_bottom_solenoid = wpilib.Solenoid(3) self.fill_bottom_solenoid = wpilib.Solenoid(4) self.fill_top_solenoid = wpilib.Solenoid(5) self.vent_top_solenoid = wpilib.Solenoid(6) self.solenoid6 = wpilib.Solenoid(7) self.ball_nudge_solenoid = wpilib.Solenoid(8) self.robot_drive = wpilib.RobotDrive(self.lr_motor, self.rr_motor, self.lf_motor, self.rf_motor) self.robot_drive.SetSafetyEnabled(False) self.robot_drive.SetInvertedMotor(wpilib.RobotDrive.kFrontLeftMotor, True) self.robot_drive.SetInvertedMotor(wpilib.RobotDrive.kRearLeftMotor, True) # Sensors self.gyro = wpilib.Gyro(1) self.ultrasonic_sensor = wpilib.AnalogChannel(3) self.arm_angle_sensor = wpilib.AnalogChannel(4) self.ball_sensor = wpilib.AnalogChannel(6) self.accelerometer = wpilib.ADXL345_I2C(1, wpilib.ADXL345_I2C.kRange_2G) self.compressor = wpilib.Compressor(1, 1) self.compressor.Start()