add encoder to shooter
authorKaitlyn <kaitlyn@10.17.72.18>
Thu, 4 Feb 2016 02:33:49 +0000 (18:33 -0800)
committerKaitlyn <kaitlyn@10.17.72.18>
Thu, 4 Feb 2016 02:33:49 +0000 (18:33 -0800)
src/org/usfirst/frc/team3501/robot/Constants.java
src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java

index e20ecc9c5ce6d91889e5958b99b0e76d1d6748f4..db5fbb44b023a31a2f4563ea6a09b93f06985b97 100644 (file)
@@ -49,9 +49,14 @@ public class Constants {
     public static final int PUNCH_FORWARD_PORT = 0;
     public static final int PUNCH_REVERSE_PORT = 1;
     public static final int ANGLE_ADJUSTER_PORT = 0;
+
     public static final DoubleSolenoid.Value punch = DoubleSolenoid.Value.kForward;
     public static final DoubleSolenoid.Value retract = DoubleSolenoid.Value.kReverse;
 
+    // Encoder port
+    public static final int ENCODER_PORT_A = 0;
+    public static final int ENCODER_PORT_B = 0;
+
     public static enum State {
       RUNNING, STOPPED;
     }
index 3e6b7f6015457a8e2f97441387642d9a395febe0..ec3731752bad3f43df0175fb9106d76b2821de0b 100755 (executable)
@@ -3,19 +3,25 @@ package org.usfirst.frc.team3501.robot.subsystems;
 import org.usfirst.frc.team3501.robot.Constants;
 
 import edu.wpi.first.wpilibj.CANTalon;
+import edu.wpi.first.wpilibj.CounterBase.EncodingType;
 import edu.wpi.first.wpilibj.DoubleSolenoid;
+import edu.wpi.first.wpilibj.Encoder;
 import edu.wpi.first.wpilibj.command.Subsystem;
 
 public class Shooter extends Subsystem {
   private CANTalon shooter;
   private CANTalon angleAdjuster;
   private DoubleSolenoid punch;
+  private Encoder encoder;
 
   public Shooter() {
     shooter = new CANTalon(Constants.Shooter.PORT);
     angleAdjuster = new CANTalon(Constants.Shooter.ANGLE_ADJUSTER_PORT);
     punch = new DoubleSolenoid(Constants.Shooter.PUNCH_FORWARD_PORT,
         Constants.Shooter.PUNCH_REVERSE_PORT);
+
+    encoder = new Encoder(Constants.Shooter.ENCODER_PORT_A,
+        Constants.Shooter.ENCODER_PORT_B, false, EncodingType.k4X);
   }
 
   public double getCurrentSetPoint() {
@@ -35,6 +41,10 @@ public class Shooter extends Subsystem {
     this.setSpeed(0.0);
   }
 
+  public double getSpeed() {
+    return encoder.getRate();
+  }
+
   // Use negative # for decrement. Positive for increment.
   public void changeSpeed(double change) {
     double newSpeed = getCurrentSetPoint() + change;