From 2c52cb6ef31a26d971f85a61f38550cb036c99d2 Mon Sep 17 00:00:00 2001 From: Kaitlyn Date: Wed, 3 Feb 2016 18:33:49 -0800 Subject: [PATCH] add encoder to shooter --- src/org/usfirst/frc/team3501/robot/Constants.java | 5 +++++ .../usfirst/frc/team3501/robot/subsystems/Shooter.java | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/org/usfirst/frc/team3501/robot/Constants.java b/src/org/usfirst/frc/team3501/robot/Constants.java index e20ecc9c..db5fbb44 100644 --- a/src/org/usfirst/frc/team3501/robot/Constants.java +++ b/src/org/usfirst/frc/team3501/robot/Constants.java @@ -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; } diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java index 3e6b7f60..ec373175 100755 --- a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java @@ -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; -- 2.30.2