From: Shaina Chen Date: Sat, 30 Jan 2016 05:38:35 +0000 (-0800) Subject: Add set motor speed methods in defense arm and add potentiometer getter methods X-Git-Url: http://challenge-bot.com/repos/?p=3501%2Fstronghold-2016;a=commitdiff_plain;h=ae33aa8d932b24826d569c12433715b93a34a794 Add set motor speed methods in defense arm and add potentiometer getter methods --- diff --git a/src/org/usfirst/frc/team3501/robot/Constants.java b/src/org/usfirst/frc/team3501/robot/Constants.java index a62aea04..c11c758e 100644 --- a/src/org/usfirst/frc/team3501/robot/Constants.java +++ b/src/org/usfirst/frc/team3501/robot/Constants.java @@ -75,6 +75,9 @@ public class Constants { public static final int ARM_CHANNEL = 0; public static final int ARM_PORT = 0; public static final int HAND_PORT = 1; + public final static double FULL_RANGE = 270.0; // in degrees + public final static double OFFSET = -135.0; // in degrees + public final static double[] armPotValue = { 0.0, 45.0, 90.0 }; // 3 level } public static enum Direction { diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/DefenseArm.java b/src/org/usfirst/frc/team3501/robot/subsystems/DefenseArm.java index b54a02f2..069ea45f 100755 --- a/src/org/usfirst/frc/team3501/robot/subsystems/DefenseArm.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/DefenseArm.java @@ -10,60 +10,33 @@ public class DefenseArm extends Subsystem { // Defense arm related objects private AnalogPotentiometer defenseArmPotentiometer; private AnalogPotentiometer defenseHandPotentiometer; - private CANTalon defenseArmMotor; - private CANTalon defenseHandMotor; + private CANTalon defenseArm; + private CANTalon defenseHand; private double hookHeight; private double footHeight; // Defense arm specific constants that relate to the degrees per pulse value // for the potentiometers // private final static double PULSES_PER_ROTATION = 1; // in pulses - public final static double FULL_RANGE = 270.0; // in degrees - public final static double OFFSET = -135.0; // in degrees - public final static double[] armPotValue = { 0.0, 45.0, 90.0 }; // 3 level // array; - // do we want to use a hashmap?? - // angles at 0,45,90 (Potentiometer value readings) - // degrees - public DefenseArm() { defenseArmPotentiometer = new AnalogPotentiometer( - Constants.DefenseArm.ARM_CHANNEL, FULL_RANGE, OFFSET); + Constants.DefenseArm.ARM_CHANNEL, + Constants.DefenseArm.FULL_RANGE, + Constants.DefenseArm.OFFSET); - defenseArmMotor = new CANTalon(Constants.DefenseArm.ARM_PORT); - defenseHandMotor = new CANTalon(Constants.DefenseArm.HAND_PORT); + defenseArm = new CANTalon(Constants.DefenseArm.ARM_PORT); + defenseHand = new CANTalon(Constants.DefenseArm.HAND_PORT); } - /*** - * This method gets the height of the hook from the - * ground. The hook is attached to the end of the hand, which is attached to - * the arm. - * - * @return hookHeight gets height of hook from ground. The hook is attached to - * the end of the hand, which is attached the arm. The height is in - * inches. - * - */ - - public double getHookHeight() { - - return 0; + public double getArmPotAngle() { + return defenseArmPotentiometer.get(); } - /*** - * This method gets the height of the foot from the ground. The foot is - * attached to the end of the hand, which is attached to the arm. - * - * @return footHeight gets height of foot from ground. The foot is attached to - * the end of the hand, which is attached the arm. The height is in - * inches. - * - */ - - public double getFootHeight() { - return 0; + public double getHandPotAngle() { + return defenseHandPotentiometer.get(); } /*** @@ -76,8 +49,13 @@ public class DefenseArm extends Subsystem { * negative voltage makes the direction of the motor go backwards. */ - public void setArmMotorSpeed(double speed) { + public void setArmSpeed(double speed) { + if (speed > 1) + speed = 1; + else if (speed < -1) + speed = -1; + defenseArm.set(speed); } /*** @@ -90,7 +68,13 @@ public class DefenseArm extends Subsystem { * negative voltage makes the direction of the motor go backwards. */ - public void setHandMotorSpeed(double speed) { + public void setHandSpeed(double speed) { + if (speed > 1) + speed = 1; + else if (speed < -1) + speed = -1; + + defenseHand.set(speed); } @Override diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/Scaler.java b/src/org/usfirst/frc/team3501/robot/subsystems/Scaler.java index cbc7ff77..7f685fcb 100755 --- a/src/org/usfirst/frc/team3501/robot/subsystems/Scaler.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/Scaler.java @@ -8,7 +8,6 @@ import edu.wpi.first.wpilibj.DoubleSolenoid.Value; import edu.wpi.first.wpilibj.command.Subsystem; public class Scaler extends Subsystem { - // Scaler related objects private DoubleSolenoid piston; private CANTalon winch; @@ -16,10 +15,10 @@ public class Scaler extends Subsystem { piston = new DoubleSolenoid(Constants.Scaler.FORWARD_CHANNEL, Constants.Scaler.REVERSE_CHANNEL); winch = new CANTalon(Constants.Scaler.WINCH_MOTOR); + } - @Override - protected void initDefaultCommand() { + public void setPistonStatus(int status) { } @@ -34,9 +33,9 @@ public class Scaler extends Subsystem { public void lowerScissorLift() { piston.set(DoubleSolenoid.Value.kForward); } - + public void engageHook() { - + } public void disengageHook() { @@ -50,4 +49,9 @@ public class Scaler extends Subsystem { winch.set(speed); } + + @Override + protected void initDefaultCommand() { + + } }