Add set motor speed methods in defense arm and add potentiometer getter methods
authorShaina Chen <shaina.sierra@gmail.com>
Sat, 30 Jan 2016 05:38:35 +0000 (21:38 -0800)
committerShaina Chen <shaina.sierra@gmail.com>
Fri, 5 Feb 2016 04:20:53 +0000 (20:20 -0800)
src/org/usfirst/frc/team3501/robot/Constants.java
src/org/usfirst/frc/team3501/robot/subsystems/DefenseArm.java
src/org/usfirst/frc/team3501/robot/subsystems/Scaler.java

index a62aea04a6ea8255f48ae7d46b94199cda2973c2..c11c758e9836db71a2c002dd9d8c97e093cb2b00 100644 (file)
@@ -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 {
index b54a02f291616aba166a078a7833a5c9887a6a32..069ea45fd34734dda4d53bf5c2c37fe42825d105 100755 (executable)
@@ -10,60 +10,33 @@ public class DefenseArm extends Subsystem {
   // Defense arm related objects\r
   private AnalogPotentiometer defenseArmPotentiometer;\r
   private AnalogPotentiometer defenseHandPotentiometer;\r
-  private CANTalon defenseArmMotor;\r
-  private CANTalon defenseHandMotor;\r
+  private CANTalon defenseArm;\r
+  private CANTalon defenseHand;\r
   private double hookHeight;\r
   private double footHeight;\r
 \r
   // Defense arm specific constants that relate to the degrees per pulse value\r
   // for the potentiometers\r
   // private final static double PULSES_PER_ROTATION = 1; // in pulses\r
-  public final static double FULL_RANGE = 270.0; // in degrees\r
-  public final static double OFFSET = -135.0; // in degrees\r
-  public final static double[] armPotValue = { 0.0, 45.0, 90.0 }; // 3 level\r
 \r
   // array;\r
 \r
-  // do we want to use a hashmap??\r
-  // angles at 0,45,90 (Potentiometer value readings)\r
-  // degrees\r
-\r
   public DefenseArm() {\r
     defenseArmPotentiometer = new AnalogPotentiometer(\r
-        Constants.DefenseArm.ARM_CHANNEL, FULL_RANGE, OFFSET);\r
+        Constants.DefenseArm.ARM_CHANNEL,\r
+        Constants.DefenseArm.FULL_RANGE,\r
+        Constants.DefenseArm.OFFSET);\r
 \r
-    defenseArmMotor = new CANTalon(Constants.DefenseArm.ARM_PORT);\r
-    defenseHandMotor = new CANTalon(Constants.DefenseArm.HAND_PORT);\r
+    defenseArm = new CANTalon(Constants.DefenseArm.ARM_PORT);\r
+    defenseHand = new CANTalon(Constants.DefenseArm.HAND_PORT);\r
   }\r
 \r
-  /***\r
-   * This method gets the height of the hook from the\r
-   * ground. The hook is attached to the end of the hand, which is attached to\r
-   * the arm.\r
-   *\r
-   * @return hookHeight gets height of hook from ground. The hook is attached to\r
-   *         the end of the hand, which is attached the arm. The height is in\r
-   *         inches.\r
-   *\r
-   */\r
-\r
-  public double getHookHeight() {\r
-\r
-    return 0;\r
+  public double getArmPotAngle() {\r
+    return defenseArmPotentiometer.get();\r
   }\r
 \r
-  /***\r
-   * This method gets the height of the foot from the ground. The foot is\r
-   * attached to the end of the hand, which is attached to the arm.\r
-   *\r
-   * @return footHeight gets height of foot from ground. The foot is attached to\r
-   *         the end of the hand, which is attached the arm. The height is in\r
-   *         inches.\r
-   *\r
-   */\r
-\r
-  public double getFootHeight() {\r
-    return 0;\r
+  public double getHandPotAngle() {\r
+    return defenseHandPotentiometer.get();\r
   }\r
 \r
   /***\r
@@ -76,8 +49,13 @@ public class DefenseArm extends Subsystem {
    *          negative voltage makes the direction of the motor go backwards.\r
    */\r
 \r
-  public void setArmMotorSpeed(double speed) {\r
+  public void setArmSpeed(double speed) {\r
+    if (speed > 1)\r
+      speed = 1;\r
+    else if (speed < -1)\r
+      speed = -1;\r
 \r
+    defenseArm.set(speed);\r
   }\r
 \r
   /***\r
@@ -90,7 +68,13 @@ public class DefenseArm extends Subsystem {
    *          negative voltage makes the direction of the motor go backwards.\r
    */\r
 \r
-  public void setHandMotorSpeed(double speed) {\r
+  public void setHandSpeed(double speed) {\r
+    if (speed > 1)\r
+      speed = 1;\r
+    else if (speed < -1)\r
+      speed = -1;\r
+\r
+    defenseHand.set(speed);\r
   }\r
 \r
   @Override\r
index cbc7ff77362b816e7c31957dde339db0a0437079..7f685fcb5ec2ef0518cd54508104da5fcf5b9552 100755 (executable)
@@ -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() {
+
+  }
 }