Move all constants in DeadReckoning to Auton class because it makes more sense
authorKevin Zhang <icestormf1@gmail.com>
Wed, 17 Feb 2016 23:47:24 +0000 (15:47 -0800)
committerMeryem Esa <meresa14@gmail.com>
Thu, 18 Feb 2016 22:07:21 +0000 (14:07 -0800)
src/org/usfirst/frc/team3501/robot/Constants.java
src/org/usfirst/frc/team3501/robot/commands/auton/AlignToScore.java
src/org/usfirst/frc/team3501/robot/commands/auton/PassLowBar.java
src/org/usfirst/frc/team3501/robot/commands/auton/PassMoat.java
src/org/usfirst/frc/team3501/robot/commands/auton/PassRampart.java
src/org/usfirst/frc/team3501/robot/commands/auton/PassRockWall.java
src/org/usfirst/frc/team3501/robot/commands/auton/PassRoughTerrain.java
src/org/usfirst/frc/team3501/robot/commands/driving/TurnForTime.java
src/org/usfirst/frc/team3501/robot/subsystems/DriveTrain.java

index 2d3cd43d6212cd6aab39d692699d78db05cf2646..7245d5fead8910eb4342f964e24a5efeed5609bf 100644 (file)
@@ -124,29 +124,6 @@ public class Constants {
     }
   }
 
     }
   }
 
-  public static class DeadReckoning {
-    public static final double DEFAULT_SPEED = 0.5;
-    public static boolean isUsingTimeToPassDefense = true;
-
-    // dead reckoning time and speed constants for driving through defenses
-    public static double passRockWallTime = 0;
-    public static double passRockWallSpeed = 0;
-    public static double passRockWallDistance = 0;
-    public static double passLowBarTime = 0;
-    public static double passLowBarSpeed = 0;
-    public static double passLowBarDistance = 0;
-    public static double passMoatTime = 0;
-    public static double passMoatSpeed = 0;
-    public static double passMoatDistance = 0;
-    public static double passRampartTime = 0;
-    public static double passRampartSpeed = 0;
-    public static double passRampartDistance = 0;
-    public static double passRoughTerrainTime = 0;
-    public static double passRoughTerrainSpeed = 0;
-    public static double passRoughTerrainDistance = 0;
-
-  }
-
   public static class IntakeArm {
     public static final int ROLLER_PORT = 0;
     public static final int ARM_PORT = 1;
   public static class IntakeArm {
     public static final int ROLLER_PORT = 0;
     public static final int ARM_PORT = 1;
@@ -249,6 +226,28 @@ public class Constants {
     public static final double POS5_TURN1_TIME = 60;
     public static final double POS5_TURN_MAXSPEED = 0.5;
     public static final double POS5_DIST2_TIME = 0;
     public static final double POS5_TURN1_TIME = 60;
     public static final double POS5_TURN_MAXSPEED = 0.5;
     public static final double POS5_DIST2_TIME = 0;
+
+    // Passing Defenses Constants
+
+    public static final double DEFAULT_SPEED = 0.5;
+    public static boolean isUsingTimeToPassDefense = true;
+
+    // dead reckoning time and speed constants for driving through defenses
+    public static double passRockWallTime = 0;
+    public static double passRockWallSpeed = 0;
+    public static double passRockWallDistance = 0;
+    public static double passLowBarTime = 0;
+    public static double passLowBarSpeed = 0;
+    public static double passLowBarDistance = 0;
+    public static double passMoatTime = 0;
+    public static double passMoatSpeed = 0;
+    public static double passMoatDistance = 0;
+    public static double passRampartTime = 0;
+    public static double passRampartSpeed = 0;
+    public static double passRampartDistance = 0;
+    public static double passRoughTerrainTime = 0;
+    public static double passRoughTerrainSpeed = 0;
+    public static double passRoughTerrainDistance = 0;
   }
 
   public enum Direction {
   }
 
   public enum Direction {
index f2c577ced14c79e9bd1888f9b32b173d26de1169..6d0b9ede6cc1b0688cf466af57967bdd717cebe3 100644 (file)
@@ -39,7 +39,7 @@ public class AlignToScore extends CommandGroup {
   public double horizontalDistToGoal;
 
   public AlignToScore(int position) {
   public double horizontalDistToGoal;
 
   public AlignToScore(int position) {
-    if (Constants.DeadReckoning.isUsingTimeToPassDefense) {
+    if (Constants.Auton.isUsingTimeToPassDefense) {
       if (position == 1) {
         addSequential(new DriveForTime(Constants.Auton.POS1_DIST1_TIME,
             Constants.Auton.POS1_DRIVE_MAXSPEED));
       if (position == 1) {
         addSequential(new DriveForTime(Constants.Auton.POS1_DIST1_TIME,
             Constants.Auton.POS1_DRIVE_MAXSPEED));
@@ -146,7 +146,7 @@ public class AlignToScore extends CommandGroup {
    * double horizontalDistToGoal) {
    * double leftDist = Robot.driveTrain.getLeftLidarDistance();
    * double rightDist = Robot.driveTrain.getRightLidarDistance();
    * double horizontalDistToGoal) {
    * double leftDist = Robot.driveTrain.getLeftLidarDistance();
    * double rightDist = Robot.driveTrain.getRightLidarDistance();
-   *
+   * 
    * double errorAngle = Math.atan(Math.abs(leftDist - rightDist) / 2);
    * double distToTower;
    * // TODO: figure out if we do want to shoot into the side goal if we are
    * double errorAngle = Math.atan(Math.abs(leftDist - rightDist) / 2);
    * double distToTower;
    * // TODO: figure out if we do want to shoot into the side goal if we are
@@ -156,7 +156,7 @@ public class AlignToScore extends CommandGroup {
    * .cos(CENTER_OF_MASS_TO_ROBOT_FRONT + (leftDist - rightDist) / 2)
    * - DIST_CASTLE_WALL_TO_SIDE_GOAL;
    * }
    * .cos(CENTER_OF_MASS_TO_ROBOT_FRONT + (leftDist - rightDist) / 2)
    * - DIST_CASTLE_WALL_TO_SIDE_GOAL;
    * }
-   *
+   * 
    * // TODO: figure out if we do want to shoot into the font goal if we are
    * // in position 3, 4, 5, or if we want to change that
    * else {
    * // TODO: figure out if we do want to shoot into the font goal if we are
    * // in position 3, 4, 5, or if we want to change that
    * else {
@@ -164,9 +164,9 @@ public class AlignToScore extends CommandGroup {
    * .cos(CENTER_OF_MASS_TO_ROBOT_FRONT + (leftDist - rightDist) / 2)
    * - DIST_CASTLE_WALL_TO_SIDE_GOAL;
    * }
    * .cos(CENTER_OF_MASS_TO_ROBOT_FRONT + (leftDist - rightDist) / 2)
    * - DIST_CASTLE_WALL_TO_SIDE_GOAL;
    * }
-   *
+   * 
    * double angleToTurn = Math.atan(distToTower / horizontalDistToGoal);
    * double angleToTurn = Math.atan(distToTower / horizontalDistToGoal);
-   *
+   * 
    * return angleToTurn;
    * }
    */
    * return angleToTurn;
    * }
    */
index 49b085d09e6a8ecf11ecd47cd325da75dd5267b3..8f35a25cd393b9275d317cec4ac5f67a0101e557 100644 (file)
@@ -25,13 +25,13 @@ import edu.wpi.first.wpilibj.command.CommandGroup;
 public class PassLowBar extends CommandGroup {
 
   public PassLowBar() {
 public class PassLowBar extends CommandGroup {
 
   public PassLowBar() {
-    if (Constants.DeadReckoning.isUsingTimeToPassDefense) {
-      addSequential(new DriveForTime(Constants.DeadReckoning.passLowBarTime,
-          Constants.DeadReckoning.passLowBarSpeed));
+    if (Constants.Auton.isUsingTimeToPassDefense) {
+      addSequential(new DriveForTime(Constants.Auton.passLowBarTime,
+          Constants.Auton.passLowBarSpeed));
     }
     else {
       addSequential(new DriveDistance(
     }
     else {
       addSequential(new DriveDistance(
-          Constants.DeadReckoning.passLowBarDistance,
+          Constants.Auton.passLowBarDistance,
           Constants.DriveTrain.PASS_DEFENSE_TIMEOUT));
     }
   }
           Constants.DriveTrain.PASS_DEFENSE_TIMEOUT));
     }
   }
index f9331077a8a0b9da6c2f0162374d75d63f237d1f..3539d970e858dd67952d5229779626d1a16fcff7 100755 (executable)
@@ -28,12 +28,12 @@ import edu.wpi.first.wpilibj.command.CommandGroup;
 public class PassMoat extends CommandGroup {
 
   public PassMoat() {
 public class PassMoat extends CommandGroup {
 
   public PassMoat() {
-    if (Constants.DeadReckoning.isUsingTimeToPassDefense) {
-      addSequential(new DriveForTime(Constants.DeadReckoning.passMoatTime,
-          Constants.DeadReckoning.passMoatSpeed));
+    if (Constants.Auton.isUsingTimeToPassDefense) {
+      addSequential(new DriveForTime(Constants.Auton.passMoatTime,
+          Constants.Auton.passMoatSpeed));
     }
     else {
     }
     else {
-      addSequential(new DriveDistance(Constants.DeadReckoning.passMoatDistance,
+      addSequential(new DriveDistance(Constants.Auton.passMoatDistance,
           Constants.DriveTrain.PASS_DEFENSE_TIMEOUT));
     }
 
           Constants.DriveTrain.PASS_DEFENSE_TIMEOUT));
     }
 
index 21c128958e51b2ac09da94b5b3f21c98d4268378..30051460e11e157ac509de7cf81bda5d12543b47 100755 (executable)
@@ -26,13 +26,13 @@ public class PassRampart extends CommandGroup {
 
   public PassRampart() {
 
 
   public PassRampart() {
 
-    if (Constants.DeadReckoning.isUsingTimeToPassDefense) {
-      addSequential(new DriveForTime(Constants.DeadReckoning.passRockWallTime,
-          Constants.DeadReckoning.passRockWallSpeed));
+    if (Constants.Auton.isUsingTimeToPassDefense) {
+      addSequential(new DriveForTime(Constants.Auton.passRockWallTime,
+          Constants.Auton.passRockWallSpeed));
     }
     else {
       addSequential(new DriveDistance(
     }
     else {
       addSequential(new DriveDistance(
-          Constants.DeadReckoning.passRampartDistance,
+          Constants.Auton.passRampartDistance,
           Constants.DriveTrain.PASS_DEFENSE_TIMEOUT));
     }
 
           Constants.DriveTrain.PASS_DEFENSE_TIMEOUT));
     }
 
index ea87ca29ba5aa6e23a3cc22e9f2e92c752b72853..a0b6690c22049849c20ef8deaa07438a15c346a3 100755 (executable)
@@ -25,13 +25,13 @@ import edu.wpi.first.wpilibj.command.CommandGroup;
 public class PassRockWall extends CommandGroup {
 
   public PassRockWall() {
 public class PassRockWall extends CommandGroup {
 
   public PassRockWall() {
-    if (Constants.DeadReckoning.isUsingTimeToPassDefense) {
-      addSequential(new DriveForTime(Constants.DeadReckoning.passRockWallTime,
-          Constants.DeadReckoning.passRockWallSpeed));
+    if (Constants.Auton.isUsingTimeToPassDefense) {
+      addSequential(new DriveForTime(Constants.Auton.passRockWallTime,
+          Constants.Auton.passRockWallSpeed));
     }
     else {
       addSequential(new DriveDistance(
     }
     else {
       addSequential(new DriveDistance(
-          Constants.DeadReckoning.passRockWallDistance,
+          Constants.Auton.passRockWallDistance,
           Constants.DriveTrain.PASS_DEFENSE_TIMEOUT));
     }
 
           Constants.DriveTrain.PASS_DEFENSE_TIMEOUT));
     }
 
index 2ddddf4389b5c469bc84bfbc67f77db7a54b8ea4..e3d64dde31246f1030c8ae80830e33b87b239650 100644 (file)
@@ -26,13 +26,13 @@ public class PassRoughTerrain extends CommandGroup {
 
   public PassRoughTerrain() {
 
 
   public PassRoughTerrain() {
 
-    if (Constants.DeadReckoning.isUsingTimeToPassDefense) {
-      addSequential(new DriveForTime(Constants.DeadReckoning.passRockWallTime,
-          Constants.DeadReckoning.passRockWallSpeed));
+    if (Constants.Auton.isUsingTimeToPassDefense) {
+      addSequential(new DriveForTime(Constants.Auton.passRockWallTime,
+          Constants.Auton.passRockWallSpeed));
     }
     else {
       addSequential(new DriveDistance(
     }
     else {
       addSequential(new DriveDistance(
-          Constants.DeadReckoning.passRoughTerrainDistance,
+          Constants.Auton.passRoughTerrainDistance,
           Constants.DriveTrain.PASS_DEFENSE_TIMEOUT));
     }
 
           Constants.DriveTrain.PASS_DEFENSE_TIMEOUT));
     }
 
index 21f200c87b24eb63e1652aea3273fa2180bd87f1..368d10459f2289f94a406ff3ecc1ece79653592b 100755 (executable)
@@ -1,6 +1,6 @@
 package org.usfirst.frc.team3501.robot.commands.driving;
 
 package org.usfirst.frc.team3501.robot.commands.driving;
 
-import org.usfirst.frc.team3501.robot.Constants.DeadReckoning;
+import org.usfirst.frc.team3501.robot.Constants;
 import org.usfirst.frc.team3501.robot.Constants.Direction;
 import org.usfirst.frc.team3501.robot.Robot;
 
 import org.usfirst.frc.team3501.robot.Constants.Direction;
 import org.usfirst.frc.team3501.robot.Robot;
 
@@ -36,7 +36,7 @@ public class TurnForTime extends Command {
   }
 
   public TurnForTime(double seconds, Direction direction) {
   }
 
   public TurnForTime(double seconds, Direction direction) {
-    this(seconds, direction, DeadReckoning.DEFAULT_SPEED);
+    this(seconds, direction, Constants.Auton.DEFAULT_SPEED);
   }
 
   @Override
   }
 
   @Override
index 96f1d1150fd5d87a2d5e5531f8515fcf10302e4f..9852848e1c1a49fac411fe0ae876f1ffe302d51b 100644 (file)
@@ -227,10 +227,16 @@ public class DriveTrain extends PIDSubsystem {
   }
 
   /*
   }
 
   /*
-   * Checks the drive mode
+   * Checks the drive mode <<<<<<< 9728080f491e9fb09795494349dba1297f447c0f
    *
    * @return the current state of the robot in each state Average distance from
    * both sides of tank drive for Encoder Mode Angle from the gyro in GYRO_MODE
    *
    * @return the current state of the robot in each state Average distance from
    * both sides of tank drive for Encoder Mode Angle from the gyro in GYRO_MODE
+   * =======
+   *
+   * @return the current state of the robot in each state Average distance from
+   * both sides of tank drive for Encoder Mode Angle from the gyro in GYRO_MODE
+   * >>>>>>> Move all constants in DeadReckoning to Auton class because it makes
+   * more sense
    */
   private double sensorFeedback() {
     if (DRIVE_MODE == Constants.DriveTrain.ENCODER_MODE)
    */
   private double sensorFeedback() {
     if (DRIVE_MODE == Constants.DriveTrain.ENCODER_MODE)
@@ -360,4 +366,8 @@ public class DriveTrain extends PIDSubsystem {
     leftGearPiston.set(gear);
     rightGearPiston.set(gear);
   }
     leftGearPiston.set(gear);
     rightGearPiston.set(gear);
   }
+
+  public void toggleTimeDeadReckoning() {
+    Constants.Auton.isUsingTimeToPassDefense = !Constants.Auton.isUsingTimeToPassDefense;
+  }
 }
 }