Add getters/setters for the pistons
authorRohan Rodrigues <rohanrodrigues19@gmail.com>
Sun, 19 Feb 2017 22:03:01 +0000 (14:03 -0800)
committerCindy Zhang <cindyzyx9@gmail.com>
Sat, 25 Feb 2017 18:46:32 +0000 (10:46 -0800)
src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java

index bf743b1a3195139d8ec59c73f4d5f713087458e3..a3242d9bdd1acecc2770ea3cd41d73766923dae2 100644 (file)
@@ -7,6 +7,8 @@ import org.usfirst.frc.team3501.robot.utils.PIDController;
 
 import com.ctre.CANTalon;
 
 
 import com.ctre.CANTalon;
 
+import edu.wpi.first.wpilibj.DoubleSolenoid;
+import edu.wpi.first.wpilibj.DoubleSolenoid.Value;
 import edu.wpi.first.wpilibj.command.Subsystem;
 
 public class Shooter extends Subsystem {
 import edu.wpi.first.wpilibj.command.Subsystem;
 
 public class Shooter extends Subsystem {
@@ -25,12 +27,17 @@ public class Shooter extends Subsystem {
   private double targetShootingSpeed = DEFAULT_SHOOTING_SPEED;
   private double currentShooterMotorValue = 0;
 
   private double targetShootingSpeed = DEFAULT_SHOOTING_SPEED;
   private double currentShooterMotorValue = 0;
 
+  private final DoubleSolenoid piston;
+
   private Shooter() {
     flyWheel1 = new CANTalon(Constants.Shooter.FLY_WHEEL1);
     flyWheel2 = new CANTalon(Constants.Shooter.FLY_WHEEL2);
     indexWheel = new CANTalon(Constants.Shooter.INDEX_WHEEL);
 
     hallEffect = new HallEffectSensor(Constants.Shooter.HALL_EFFECT_PORT, 1);
   private Shooter() {
     flyWheel1 = new CANTalon(Constants.Shooter.FLY_WHEEL1);
     flyWheel2 = new CANTalon(Constants.Shooter.FLY_WHEEL2);
     indexWheel = new CANTalon(Constants.Shooter.INDEX_WHEEL);
 
     hallEffect = new HallEffectSensor(Constants.Shooter.HALL_EFFECT_PORT, 1);
+
+    piston = new DoubleSolenoid(Constants.DriveTrain.MODULE_NUMBER,
+        Constants.Shooter.PISTON_FORWARD, Constants.Shooter.PISTON_REVERSE);
   }
 
   /**
   }
 
   /**
@@ -140,4 +147,20 @@ public class Shooter extends Subsystem {
     this.wheelController.setSetPoint(this.targetShootingSpeed);
     this.currentShooterMotorValue = 0;
   }
     this.wheelController.setSetPoint(this.targetShootingSpeed);
     this.currentShooterMotorValue = 0;
   }
+
+  public Value getPistonValue() {
+    return piston.get();
+  }
+
+  public void setHighGear() {
+    changeGear(Constants.Shooter.HIGH_GEAR);
+  }
+
+  public void setLowGear() {
+    changeGear(Constants.Shooter.LOW_GEAR);
+  }
+
+  private void changeGear(DoubleSolenoid.Value gear) {
+    piston.set(gear);
+  }
 }
 }