X-Git-Url: http://challenge-bot.com/repos/?a=blobdiff_plain;f=src%2Forg%2Fusfirst%2Ffrc%2Fteam3501%2Frobot%2Fsubsystems%2FShooter.java;h=f547ab0ee84fa2ae9399eb75898534218615ba07;hb=a56412b727a0e8168a8e4b46fddf1eaad6028f80;hp=3b91bfe03c451333cdcdd8ef2035071b71a6af3a;hpb=005821c6ab7767f9a871091e4f0b096038a2d83f;p=3501%2Fstronghold-2016 diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java index 3b91bfe0..f547ab0e 100755 --- a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java @@ -1,8 +1,7 @@ package org.usfirst.frc.team3501.robot.subsystems; import org.usfirst.frc.team3501.robot.Constants; -import org.usfirst.frc.team3501.robot.Lidar; -import org.usfirst.frc.team3501.robot.MathLib; +import org.usfirst.frc.team3501.robot.sensors.Lidar; import edu.wpi.first.wpilibj.CANTalon; import edu.wpi.first.wpilibj.CounterBase.EncodingType; @@ -35,8 +34,6 @@ public class Shooter extends Subsystem { encoder = new Encoder(Constants.Shooter.ENCODER_PORT_A, Constants.Shooter.ENCODER_PORT_B, false, EncodingType.k4X); - - lidar = new Lidar(Constants.Shooter.LIDAR_I2C_PORT); } /*** @@ -52,15 +49,12 @@ public class Shooter extends Subsystem { } public void setSpeed(double speed) { - speed = MathLib.constrain(speed, -1, 1); - shooter.set(speed); - } - - // This getDistance() will return the distance using the lidar from the - // desired target during match. This distance is returned in units of - // CENTIMETERS. - public double getDistance() { - return lidar.getDistance(); + if (speed > 1.0) + shooter.set(1.0); + else if (speed < -1.0) + shooter.set(-1.0); + else + shooter.set(speed); } public void stop() { @@ -71,6 +65,17 @@ public class Shooter extends Subsystem { return encoder.getRate(); } + /* + * We are going to map a lidar distance to a shooter speed that will be set to + * the shooter. This function does not yet exist so we will just use y=x but + * when testing commences we shall create the function + */ + public double getShooterSpeed() { + double distanceToGoal = lidar.getDistance(); + double shooterSpeed = distanceToGoal; // Function to be determined + return shooterSpeed; + } + // Use negative # for decrement. Positive for increment. public void changeSpeed(double change) { @@ -79,7 +84,7 @@ public class Shooter extends Subsystem { } // Punch Commands - public void punch() { + public void extendPunch() { punch.set(Constants.Shooter.punch); } @@ -87,15 +92,11 @@ public class Shooter extends Subsystem { punch.set(Constants.Shooter.retract); } - public boolean isHoodOpen() { - return hood.get() == Constants.Shooter.open; - } - - public void openHood() { + public void raiseHood() { hood.set(Constants.Shooter.open); } - public void closeHood() { + public void lowerHood() { hood.set(Constants.Shooter.closed); }