/** * Shifts the gearboxes up or down. * * @param shiftType whether to shift up or down */ public void shift(ShiftType shiftType) { logger.info(String.format("Shifting, type=%s, shifter state=%s", shiftType.toString(), shiftingSolenoid.get().toString())); if (pcmPresent) { if (shiftType == ShiftType.TOGGLE) { if (shiftingSolenoid.get() == DoubleSolenoid.Value.kReverse) { shiftingSolenoid.set(DoubleSolenoid.Value.kForward); SmartDashboard.putBoolean("Drive_Shift", true); } else { shiftingSolenoid.set(DoubleSolenoid.Value.kReverse); SmartDashboard.putBoolean("Drive_Shift", false); } } else if (shiftType == ShiftType.UP) { shiftingSolenoid.set(DoubleSolenoid.Value.kForward); SmartDashboard.putBoolean("Drive_Shift", true); } else { shiftingSolenoid.set(DoubleSolenoid.Value.kReverse); SmartDashboard.putBoolean("Drive_Shift", false); } } }
public Robot() { stick = new Joystick(0); driveLeftFront = new Victor(LEFT_FRONT_DRIVE); driveLeftRear = new Victor(LEFT_REAR_DRIVE); driveRightFront = new Victor(RIGHT_FRONT_DRIVE); driveRightRear = new Victor(RIGHT_REAR_DRIVE); enhancedDriveLeft = new Victor(ENHANCED_LEFT_DRIVE); enhancedDriveRight = new Victor(ENHANCED_RIGHT_DRIVE); gearBox = new DoubleSolenoid(GEAR_BOX_PART1, GEAR_BOX_PART2); climber1 = new Victor(CLIMBER_PART1); climber2 = new Victor(CLIMBER_PART2); vexSensorBackLeft = new Ultrasonic(0, 1); vexSensorBackRight = new Ultrasonic(2, 3); vexSensorFrontLeft = new Ultrasonic(4, 5); vexSensorFrontRight = new Ultrasonic(6, 7); Skylar = new RobotDrive(driveLeftFront, driveLeftRear, driveRightFront, driveRightRear); OptimusPrime = new RobotDrive(enhancedDriveLeft, enhancedDriveRight); }
private HardwareAdaptor(){ pdp = new PowerDistributionPanel(); comp = new Compressor(); shifter = new DoubleSolenoid(SolenoidMap.SHIFTER_FORWARD, SolenoidMap.SHIFTER_REVERSE); navx = new AHRS(CoprocessorMap.NAVX_PORT); dtLeftEncoder = new Encoder(EncoderMap.DT_LEFT_A, EncoderMap.DT_LEFT_B, EncoderMap.DT_LEFT_INVERTED); S_DTLeft.linkEncoder(dtLeftEncoder); dtRightEncoder = new Encoder(EncoderMap.DT_RIGHT_A, EncoderMap.DT_RIGHT_B, EncoderMap.DT_RIGHT_INVERTED); S_DTRight.linkEncoder(dtRightEncoder); dtLeft = S_DTLeft.getInstance(); dtRight = S_DTRight.getInstance(); S_DTWhole.linkDTSides(dtLeft, dtRight); dtWhole = S_DTWhole.getInstance(); arduino = S_Arduino.getInstance(); }
@Override public void update(Commands commands, RobotState robotState) { switch (commands.wantedSpatulaState) { case UP: mOutput = DoubleSolenoid.Value.kReverse; mState = SpatulaState.UP; break; case DOWN: mOutput = DoubleSolenoid.Value.kForward; mState = SpatulaState.DOWN; break; } mDv.updateValue(mOutput.toString() == "kReverse" ? "UP" : "DOWN"); DashboardManager.getInstance().publishKVPair(mDv); }
@Test public void testOutput() { Commands commands = Robot.getCommands(); Flippers flippers = Flippers.getInstance(); Flippers.FlipperSignal desired = new Flippers.FlipperSignal(DoubleSolenoid.Value.kForward, DoubleSolenoid.Value.kForward); commands.wantedFlipperSignal = desired; flippers.update(commands, Robot.getRobotState()); assertThat("Spatula not up", flippers.getFlipperSignal(), equalTo(desired)); desired = new Flippers.FlipperSignal(DoubleSolenoid.Value.kForward, DoubleSolenoid.Value.kReverse); commands.wantedFlipperSignal = desired; flippers.update(commands, Robot.getRobotState()); assertThat("Spatula not up", flippers.getFlipperSignal(), equalTo(desired)); desired = new Flippers.FlipperSignal(DoubleSolenoid.Value.kReverse, DoubleSolenoid.Value.kForward); commands.wantedFlipperSignal = desired; flippers.update(commands, Robot.getRobotState()); assertThat("Spatula not up", flippers.getFlipperSignal(), equalTo(desired)); desired = new Flippers.FlipperSignal(DoubleSolenoid.Value.kReverse, DoubleSolenoid.Value.kReverse); commands.wantedFlipperSignal = desired; flippers.update(commands, Robot.getRobotState()); assertThat("Spatula not up", flippers.getFlipperSignal(), equalTo(desired)); }
/** * Default constructor. * * @param otherShiftables All objects that should be shifted when this component's piston is. * @param piston The piston that shifts. * @param startingGear The gear to start in. Can be null, and if it is, the starting gear is gotten from the * piston's position. */ @JsonCreator public ShiftComponent(@NotNull @JsonProperty(required = true) List<Shiftable> otherShiftables, @NotNull @JsonProperty(required = true) MappedDoubleSolenoid piston, @Nullable Shiftable.gear startingGear) { this.otherShiftables = otherShiftables; this.piston = piston; if (startingGear != null) { this.currentGear = startingGear.getNumVal(); } else { //Get the starting gear from the piston's position if it's not provided this.currentGear = piston.get() == DoubleSolenoid.Value.kForward ? Shiftable.gear.LOW.getNumVal() : Shiftable.gear.HIGH.getNumVal(); } //Set all the shiftables to the starting gear. for (Shiftable shiftable : otherShiftables) { shiftable.setGear(currentGear); } }
public static void changeIntakePosition(){ if(CMap.auxJoystick.getTrigger()){ if(!intakeBeenPressed){ if(intakePosition == "up"){ intakePosition = "down"; System.out.println("Intake Position set to " + intakePosition + " at " + CMap.teleopTimer.get() + " seconds."); } else if(intakePosition == "down"){ intakePosition = "up"; } } intakeBeenPressed = true; } else { intakeBeenPressed = false; } if(intakePosition == "up"){ CMap.intakeSolenoid.set(DoubleSolenoid.Value.kReverse); } else if(intakePosition == "down"){ CMap.intakeSolenoid.set(DoubleSolenoid.Value.kForward); } }
ShooterControl(Encoder encoder, SpeedController pullBackSpeedController, double speedControllerMaxRpm, DigitalInput limitSwitch, DoubleSolenoid gearControl, Servo latchServo, Relay angleControl) { m_latchReleaseServo = latchServo; m_currentState = SHOOTER_CONTROL_STATE_WAIT; m_encoder = encoder; m_pullBackSpeedController = pullBackSpeedController; m_angleControl = angleControl; m_speedControllerMaxRpm = speedControllerMaxRpm; m_limitSwitch = limitSwitch; m_pullBackEncoderRpm = new EncoderRPM(); m_pullBackEncoderRpm.Init(m_pullBackSpeedController, m_encoder, (-1)*m_speedControllerMaxRpm, m_speedControllerMaxRpm, 0.05, 100, m_limitSwitch); m_releaseFromMidptEncoderRpm = new EncoderRPM(); m_releaseFromMidptEncoderRpm.Init(m_pullBackSpeedController, m_encoder,(-1)*m_speedControllerMaxRpm/4,m_speedControllerMaxRpm,0.05, 3); m_gearControl = gearControl; m_latchReleased = false; m_gearReleased = false; m_isPulledBack = false; }
private void HandleStateRelease() { if (!m_gearReleased) { // set the gear in neutral m_gearControl.set(DoubleSolenoid.Value.kForward); m_gearReleased = true; } if(!m_latchReleased) { //release the latch m_latchReleaseServo.set(1); Timer.delay(0.5); m_latchReleased = true; } m_isPulledBack = false; m_currentState = SHOOTER_CONTROL_STATE_WAIT; }
public Winch() { winchMotor = new CANTalon(RobotMap.WINCH_MOTOR); winchBrake = new DoubleSolenoid(RobotMap.WINCH_STOPPER_CHANNEL_A, RobotMap.WINCH_STOPPER_CHANNEL_B); this.winchMotor.enableBrakeMode(false); this.winchMotor.changeControlMode(TalonControlMode.Voltage); this.putBrakeOff(); }
public void toggleManipulator() { Value solenoidVal = manipulatorSolenoid.get(); if (solenoidVal == Value.kForward) { manipulatorSolenoid.set(DoubleSolenoid.Value.kReverse); } else { manipulatorSolenoid.set(DoubleSolenoid.Value.kForward); manipulatorMotor.set(0.5); } }
/** * * @param value sets the solenoid state */ public void setLock(boolean value){ if(value){ sol.set(DoubleSolenoid.Value.kForward); }else{ sol.set(DoubleSolenoid.Value.kReverse); } SmartDashboard.putBoolean("Winch Cylinder", value); }
/** * Creates CAN Pnuematics Control Module object * * @param newdoubleSolenoid * the CAN Pnuematics Control Module associated with this object * @param newCanId * the ID of the CAN object */ public CANObject (final DoubleSolenoid newdoubleSolenoid, int newCanId) { doubleSolenoid = newdoubleSolenoid; canId = newCanId; typeId = 3; // if(useDebug == true) // { // System.out.println("The Double Solenoid is " + doubleSolenoid); // System.out.println("The canId of the DoubleSolenoid is " + canId); // System.out.println("The type Id of the DoubleSolenoid is " + typeId); // } }
/** * Checks if the CAN Device is a Pnuematic Control Module * * @return Returns Pnuematic Control Module if type ID is 3, if not returns null */ public DoubleSolenoid getdoubleSolenoid () { if (typeId == 3) { return doubleSolenoid; } return null; }
public static void init() { // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS compressor = new Compressor(); driveTrainLeftFront = new CANTalon(1); LiveWindow.addActuator("DriveTrain", "LeftFront", driveTrainLeftFront); driveTrainRightFront = new CANTalon(3); LiveWindow.addActuator("DriveTrain", "RightFront", driveTrainRightFront); driveTrainLeftRear = new CANTalon(2); driveTrainLeftRear.changeControlMode(TalonControlMode.Follower); driveTrainLeftRear.set(driveTrainLeftFront.getDeviceID()); LiveWindow.addActuator("DriveTrain", "LeftRear", driveTrainLeftRear); driveTrainRightRear = new CANTalon(4); driveTrainRightRear.changeControlMode(TalonControlMode.Follower); driveTrainRightRear.set(driveTrainRightFront.getDeviceID()); driveTrainRightRear.reverseOutput(false); LiveWindow.addActuator("DriveTrain", "RightRear", driveTrainRightRear); driveTrainLeftFront.setInverted(true); driveTrainRightFront.setInverted(true); driveTrainLeftRear.setInverted(true); driveTrainRightRear.setInverted(true); driveTrainRobotDrive41 = new RobotDrive(driveTrainRightFront, driveTrainLeftFront); driveTrainRobotDrive41.setSafetyEnabled(true); driveTrainRobotDrive41.setExpiration(0.1); driveTrainRobotDrive41.setSensitivity(0.5); driveTrainRobotDrive41.setMaxOutput(1.0); climbMotor = new CANTalon(5); LiveWindow.addActuator("Climbing", "Motor", climbMotor); lightsLightEnable = new Relay(0); LiveWindow.addActuator("Lights", "LightEnable", lightsLightEnable); gearIntakeRamp = new DoubleSolenoid(1, 0); LiveWindow.addActuator("GearIntake", "IntakeRamp", gearIntakeRamp); // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS }
public void teleopInit() { DriveEncoders.intializeEncoders(); GearScore.gearScoreDoor.set(DoubleSolenoid.Value.kForward); setBrakeMode(true); InterfaceFlip.isFlipped = false; // This makes sure that the autonomous stops running when // teleop starts running. If you want the autonomous to // continue until interrupted by another command, remove // this line or comment it out. if (autonomousCommand != null) autonomousCommand.cancel(); }
public GearScore() { super(); gearScorePusher = new DoubleSolenoid(3, 4); LiveWindow.addActuator("GearScore", "Pusher", gearScorePusher); gearScoreDoor = new DoubleSolenoid(6, 5); LiveWindow.addActuator("GearScore", "Door", gearScoreDoor); }
public void setHighGear(boolean enabled) { _isGearOn = enabled; _gearShifter1.set(enabled ? DoubleSolenoid.Value.kForward : DoubleSolenoid.Value.kReverse); _gearShifter2.set(enabled ? DoubleSolenoid.Value.kForward : DoubleSolenoid.Value.kReverse); // _gearShifter3.set(enabled ? DoubleSolenoid.Value.kForward // : DoubleSolenoid.Value.kReverse); }
/** * Locks the climber ratchet so we don't fall off after the match ends. */ public void engageClimberRatchet() { SmartDashboard.putBoolean("Climber_Engaged", true); climberSolenoid.set(DoubleSolenoid.Value.kForward); isClimberLocked = true; // just in case setHoldPositionEnabled(false); }
/** * Toggle current drive gear * * @param gear Gear to shift to */ public static void shift(SubsystemStates.DriveGear gear) { switch (gear) { case LOW: Robot.adaptor.shifter.set(DoubleSolenoid.Value.kForward); SubsystemStates.driveGear = SubsystemStates.DriveGear.LOW; break; case HIGH: Robot.adaptor.shifter.set(DoubleSolenoid.Value.kReverse); SubsystemStates.driveGear = SubsystemStates.DriveGear.HIGH; break; } }
public void toggle() { if (get() == DoubleSolenoid.Value.kOff) { defaultPosition(isTrigger); } else if (get() == DoubleSolenoid.Value.kReverse) { forward(); } else if (get() == DoubleSolenoid.Value.kForward) { reverse(); } }
public Shooter() { isCocked = false; motor = new Spark(RobotMap.ShooterMap.PWM_MOTOR); motor.setInverted(RobotMap.ShooterMap.INV_MOTOR); solenoid = new DoubleSolenoid(RobotMap.ShooterMap.SOL_FORWARD, RobotMap.ShooterMap.SOL_REVERSE); }
public void setSol(int direction) { if (direction == 1) { solenoid.set(DoubleSolenoid.Value.kForward); } else if (direction == 0) { solenoid.set(DoubleSolenoid.Value.kOff); } else if (direction == -1) { solenoid.set(DoubleSolenoid.Value.kReverse); } }
/** * Set the solenoid forward or reverse. * * @param direction * the direction to set the solenoid, in 1 or -1. 1 will set to * high gear, -1 to low gear. */ public void setSol(int direction) { if (direction == -1) { // Set drive in low gear solenoid.set(DoubleSolenoid.Value.kReverse); setGear(0); } else if (direction == 1) { // Set drive in high gear solenoid.set(DoubleSolenoid.Value.kForward); setGear(1); } else { return; } }
/** * Toggle the state of the piston. */ @Override protected void execute() { if (subsystem.getSolenoidPosition().equals(DoubleSolenoid.Value.kForward)) { subsystem.setSolenoid(DoubleSolenoid.Value.kReverse); } else { subsystem.setSolenoid(DoubleSolenoid.Value.kForward); } }
/** * Shifts the piston to the given gear. * * @param gear The gear to shift to */ protected void shiftPiston(int gear) { if (gear == Shiftable.gear.LOW.getNumVal()) { //Switch to the low gear pos piston.set(DoubleSolenoid.Value.kForward); } else { //If we want to switch to high gear and the low gear pos is reverse, switch to forward piston.set(DoubleSolenoid.Value.kReverse); } }
public void toggleAManipulators() { Value solenoidVal = aManipulatorSolenoid.get(); if (solenoidVal == Value.kReverse) { aManipulatorSolenoid.set(DoubleSolenoid.Value.kForward); } else { aManipulatorSolenoid.set(DoubleSolenoid.Value.kReverse); } }
public Intake() { Actuator = new DoubleSolenoid(RobotMap.Solenoid.IntakeSolenoidForwards, RobotMap.Solenoid.IntakeSolenoidBackwards); IntakeCIM = new Victor(RobotMap.Pwm.MainIntakeVictor); IntakeCIM2 = new Victor(RobotMap.Pwm.CrossIntakeVictor); }
public static void init() { // BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS driveTrainLeftMotor = new Talon(0); LiveWindow.addActuator("DriveTrain", "LeftMotor", (Talon) driveTrainLeftMotor); driveTrainRightMotor = new Talon(1); LiveWindow.addActuator("DriveTrain", "RightMotor", (Talon) driveTrainRightMotor); driveTrainRobotDrive = new RobotDrive(driveTrainLeftMotor, driveTrainRightMotor); driveTrainRobotDrive.setSafetyEnabled(true); driveTrainRobotDrive.setExpiration(0.1); driveTrainRobotDrive.setSensitivity(0.5); driveTrainRobotDrive.setMaxOutput(1.0); intakeintakeMotor = new Talon(2); LiveWindow.addActuator("Intake", "intakeMotor", (Talon) intakeintakeMotor); pneumaticSystemCompressor = new Compressor(0); pneumaticSystemDoubleSolenoidPusher = new DoubleSolenoid(0, 0, 1); LiveWindow.addActuator("Pneumatic System", "DoubleSolenoidPusher", pneumaticSystemDoubleSolenoidPusher); sensorBaseUltraSonicMaxbotix = new AnalogInput(0); LiveWindow.addSensor("SensorBase", "UltraSonicMaxbotix", sensorBaseUltraSonicMaxbotix); // END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS }
public Gearbox(SpeedController motor1, SpeedController motor2, SpeedController motor3, Encoder encoder, DoubleSolenoid shifter) { m_motor1 = motor1; m_motor2 = motor2; m_motor3 = motor3; m_encoder = encoder; m_shifter = shifter; }
public void compress(boolean in) { if(in) { m_compress.set(DoubleSolenoid.Value.kForward); m_compression = m_compressLeft.getVoltage() + m_compressRight.getVoltage(); } else { m_compress.set(DoubleSolenoid.Value.kReverse); } }
public void initDefaultCommand() { // Set the default command for a subsystem here. //setDefaultCommand(new MySpecialCommand()); testDS=new DoubleSolenoid(1,2); testDS.set(DoubleSolenoid.Value.kOff); LiveWindow.addActuator("Pneumatics", "testDS", testDS); }
public void setDS(boolean on) { if(on) { testDS.set(DoubleSolenoid.Value.kForward); } else{ testDS.set(DoubleSolenoid.Value.kReverse); } }
private void HandleStatePullback() { double currentTime = Timer.getFPGATimestamp(); // assume pullback should finish within 5 seconds if (m_pullBackEncoderRpm.isEnabled() && (currentTime - m_pullBackStartTime <= 5)) { Logger.PrintLine("ShooterEncoder: calling m_pullBackEncoderRpm.PeriodicFunc", Logger.LOGGER_MESSAGE_LEVEL_DEBUG); m_pullBackEncoderRpm.PeriodicFunc(); } else { m_pullBackEncoderRpm.Stop(); if (m_pullBackEncoderRpm.isEnabled()) { Logger.PrintLine("ShooterEncoder: HandleStatePullback Timed out, moving to slow release state", Logger.LOGGER_MESSAGE_LEVEL_ERROR); // the pullback ncoder rpm object is still enabled (i.e. the // limit switch did not fire and we timed out. As a safty measure // do a slow release m_currentState = SHOOTER_CONTROL_STATE_SLOW_RELEASE; // engage the gear m_gearControl.set(DoubleSolenoid.Value.kReverse); Timer.delay(0.3); m_latchReleased = false; m_pullBackStartTime = Timer.getFPGATimestamp(); } else { // lock the latch m_latchReleaseServo.set(0); Timer.delay(0.3); m_isPulledBack = true; m_currentState = SHOOTER_CONTROL_STATE_WAIT; } } }
private void HandleStateReleaseFromMidPoint() { if(!m_latchReleased) { // release the latch m_latchReleaseServo.set(1); m_latchReleased = true; } Timer.delay(0.4); //engage the gear m_gearControl.set(DoubleSolenoid.Value.kReverse); m_isPulledBack = false; m_currentState = SHOOTER_CONTROL_STATE_WAIT; /*if(m_releaseFromMidptEncoderRpm.isEnabled()) { m_releaseFromMidptEncoderRpm.PeriodicFunc(); } else { if (!m_gearReleased) { // set the gear in neutral m_gearControl.set(DoubleSolenoid.Value.kForward); m_gearReleased = true; } m_isPulledBack = false; m_currentState = SHOOTER_CONTROL_STATE_WAIT; }*/ }
IntakeControl(SpeedController speedController, boolean speedControllerReversed, DoubleSolenoid angleControl) { m_speedController = speedController; m_angleControl = angleControl; if (speedControllerReversed) { m_speedControllerDirectionMult = -1; } else { m_speedControllerDirectionMult = 1; } }
public void ChangeAngle() { if(m_angleControl.get() == DoubleSolenoid.Value.kReverse) { Logger.PrintLine("IntrakeControl.ChangeAngle kForward", Logger.LOGGER_MESSAGE_LEVEL_DEBUG); m_angleControl.set(DoubleSolenoid.Value.kForward); } else { Logger.PrintLine("IntrakeControl.ChangeAngle kReverse", Logger.LOGGER_MESSAGE_LEVEL_DEBUG); m_angleControl.set(DoubleSolenoid.Value.kReverse); } }