From 9d518a5ce692327a7bbcf60d352dd01d253affca Mon Sep 17 00:00:00 2001 From: Cindy Zhang Date: Tue, 16 Feb 2016 11:29:38 -0800 Subject: [PATCH] add dead reckoning time, spd, distance to pass defense commands and constants --- .../usfirst/frc/team3501/robot/Constants.java | 20 ++++++++++++++++ .../robot/commands/auton/PassLowBar.java | 21 +++++++++-------- .../robot/commands/auton/PassMoat.java | 20 ++++++++-------- .../robot/commands/auton/PassRampart.java | 21 +++++++++-------- .../robot/commands/auton/PassRockWall.java | 15 ++++++++---- .../commands/auton/PassRoughTerrain.java | 23 +++++++++---------- 6 files changed, 74 insertions(+), 46 deletions(-) diff --git a/src/org/usfirst/frc/team3501/robot/Constants.java b/src/org/usfirst/frc/team3501/robot/Constants.java index fc2c7124..287344af 100644 --- a/src/org/usfirst/frc/team3501/robot/Constants.java +++ b/src/org/usfirst/frc/team3501/robot/Constants.java @@ -74,6 +74,7 @@ public class Constants { public static boolean inverted = false; + public static final double PASS_DEFENSE_TIMEOUT = 10; // find this } public static class Scaler { @@ -123,6 +124,25 @@ public class Constants { public static class DeadReckoning { public static final double DEFAULT_SPEED = 0.5; + public static boolean isDeadReckoning; + + // 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 { diff --git a/src/org/usfirst/frc/team3501/robot/commands/auton/PassLowBar.java b/src/org/usfirst/frc/team3501/robot/commands/auton/PassLowBar.java index cbdaeef6..57259bba 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/auton/PassLowBar.java +++ b/src/org/usfirst/frc/team3501/robot/commands/auton/PassLowBar.java @@ -1,6 +1,8 @@ package org.usfirst.frc.team3501.robot.commands.auton; +import org.usfirst.frc.team3501.robot.Constants; import org.usfirst.frc.team3501.robot.commands.driving.DriveDistance; +import org.usfirst.frc.team3501.robot.commands.driving.DriveForTime; import edu.wpi.first.wpilibj.command.CommandGroup; @@ -22,16 +24,15 @@ import edu.wpi.first.wpilibj.command.CommandGroup; public class PassLowBar extends CommandGroup { - private final double DISTANCE = 4.0; - private final double DEFAULT_SPEED = 0.5; - public PassLowBar() { - // TODO: need to add sequential for retracting the arms and shooting hood - // once those commands are made - addSequential(new DriveDistance(DISTANCE, DEFAULT_SPEED)); - } - - public PassLowBar(double speed) { - addSequential(new DriveDistance(DISTANCE, speed)); + if (Constants.DeadReckoning.isDeadReckoning) { + addSequential(new DriveForTime(Constants.DeadReckoning.passLowBarTime, + Constants.DeadReckoning.passLowBarSpeed)); + } + else { + addSequential(new DriveDistance( + Constants.DeadReckoning.passLowBarDistance, + Constants.DriveTrain.PASS_DEFENSE_TIMEOUT)); + } } } diff --git a/src/org/usfirst/frc/team3501/robot/commands/auton/PassMoat.java b/src/org/usfirst/frc/team3501/robot/commands/auton/PassMoat.java index 1f465d95..f5b01c46 100755 --- a/src/org/usfirst/frc/team3501/robot/commands/auton/PassMoat.java +++ b/src/org/usfirst/frc/team3501/robot/commands/auton/PassMoat.java @@ -1,5 +1,7 @@ package org.usfirst.frc.team3501.robot.commands.auton; +import org.usfirst.frc.team3501.robot.Constants; +import org.usfirst.frc.team3501.robot.commands.driving.DriveDistance; import org.usfirst.frc.team3501.robot.commands.driving.DriveForTime; import edu.wpi.first.wpilibj.command.CommandGroup; @@ -25,17 +27,15 @@ import edu.wpi.first.wpilibj.command.CommandGroup; public class PassMoat extends CommandGroup { - private final double BEG_TIME = 0; - private final double MID_TIME = 0; - private final double END_TIME = 0; - private final double BEG_SPEED = 0; - private final double MID_SPEED = 0; - private final double END_SPEED = 0; - public PassMoat() { - addSequential(new DriveForTime(BEG_TIME, BEG_SPEED)); - addSequential(new DriveForTime(MID_TIME, MID_SPEED)); - addSequential(new DriveForTime(END_TIME, END_SPEED)); + if (Constants.DeadReckoning.isDeadReckoning) { + addSequential(new DriveForTime(Constants.DeadReckoning.passMoatTime, + Constants.DeadReckoning.passMoatSpeed)); + } + else { + addSequential(new DriveDistance(Constants.DeadReckoning.passMoatDistance, + Constants.DriveTrain.PASS_DEFENSE_TIMEOUT)); + } } } diff --git a/src/org/usfirst/frc/team3501/robot/commands/auton/PassRampart.java b/src/org/usfirst/frc/team3501/robot/commands/auton/PassRampart.java index 426063dc..95bc2a23 100755 --- a/src/org/usfirst/frc/team3501/robot/commands/auton/PassRampart.java +++ b/src/org/usfirst/frc/team3501/robot/commands/auton/PassRampart.java @@ -1,5 +1,7 @@ package org.usfirst.frc.team3501.robot.commands.auton; +import org.usfirst.frc.team3501.robot.Constants; +import org.usfirst.frc.team3501.robot.commands.driving.DriveDistance; import org.usfirst.frc.team3501.robot.commands.driving.DriveForTime; import edu.wpi.first.wpilibj.command.CommandGroup; @@ -24,16 +26,15 @@ public class PassRampart extends CommandGroup { public PassRampart() { - final double BEG_TIME = 0; - final double BEG_SPEED = 0; - final double MID_TIME = 0; - final double MID_SPEED = 0; - final double END_TIME = 0; - final double END_SPEED = 0; - - addSequential(new DriveForTime(BEG_TIME, BEG_SPEED)); - addSequential(new DriveForTime(MID_TIME, MID_SPEED)); - addSequential(new DriveForTime(END_TIME, END_SPEED)); + if (Constants.DeadReckoning.isDeadReckoning) { + addSequential(new DriveForTime(Constants.DeadReckoning.passRockWallTime, + Constants.DeadReckoning.passRockWallSpeed)); + } + else { + addSequential(new DriveDistance( + Constants.DeadReckoning.passRampartDistance, + Constants.DriveTrain.PASS_DEFENSE_TIMEOUT)); + } } diff --git a/src/org/usfirst/frc/team3501/robot/commands/auton/PassRockWall.java b/src/org/usfirst/frc/team3501/robot/commands/auton/PassRockWall.java index 2839df3c..4b4a088a 100755 --- a/src/org/usfirst/frc/team3501/robot/commands/auton/PassRockWall.java +++ b/src/org/usfirst/frc/team3501/robot/commands/auton/PassRockWall.java @@ -1,5 +1,7 @@ package org.usfirst.frc.team3501.robot.commands.auton; +import org.usfirst.frc.team3501.robot.Constants; +import org.usfirst.frc.team3501.robot.commands.driving.DriveDistance; import org.usfirst.frc.team3501.robot.commands.driving.DriveForTime; import edu.wpi.first.wpilibj.command.CommandGroup; @@ -22,11 +24,16 @@ import edu.wpi.first.wpilibj.command.CommandGroup; public class PassRockWall extends CommandGroup { - private final double time = 0, speed =0; - public PassRockWall() { - - addSequential(new DriveForTime(time, speed)); + if (Constants.DeadReckoning.isDeadReckoning) { + addSequential(new DriveForTime(Constants.DeadReckoning.passRockWallTime, + Constants.DeadReckoning.passRockWallSpeed)); + } + else { + addSequential(new DriveDistance( + Constants.DeadReckoning.passRockWallDistance, + Constants.DriveTrain.PASS_DEFENSE_TIMEOUT)); + } } } diff --git a/src/org/usfirst/frc/team3501/robot/commands/auton/PassRoughTerrain.java b/src/org/usfirst/frc/team3501/robot/commands/auton/PassRoughTerrain.java index 8851edf6..ad5054dc 100644 --- a/src/org/usfirst/frc/team3501/robot/commands/auton/PassRoughTerrain.java +++ b/src/org/usfirst/frc/team3501/robot/commands/auton/PassRoughTerrain.java @@ -1,5 +1,7 @@ package org.usfirst.frc.team3501.robot.commands.auton; +import org.usfirst.frc.team3501.robot.Constants; +import org.usfirst.frc.team3501.robot.commands.driving.DriveDistance; import org.usfirst.frc.team3501.robot.commands.driving.DriveForTime; import edu.wpi.first.wpilibj.command.CommandGroup; @@ -22,20 +24,17 @@ import edu.wpi.first.wpilibj.command.CommandGroup; */ public class PassRoughTerrain extends CommandGroup { - // TODO: test for the time - private final double BEG_TIME = 0; - private final double MID_TIME = 0; - private final double END_TIME = 0; - - private final double BEG_SPEED = 0; - private final double MID_SPEED = 0; - private final double END_SPEED = 0; - public PassRoughTerrain() { - addSequential(new DriveForTime(BEG_TIME, BEG_SPEED)); - addSequential(new DriveForTime(MID_TIME, MID_SPEED)); - addSequential(new DriveForTime(END_TIME, BEG_SPEED)); + if (Constants.DeadReckoning.isDeadReckoning) { + addSequential(new DriveForTime(Constants.DeadReckoning.passRockWallTime, + Constants.DeadReckoning.passRockWallSpeed)); + } + else { + addSequential(new DriveDistance( + Constants.DeadReckoning.passRoughTerrainDistance, + Constants.DriveTrain.PASS_DEFENSE_TIMEOUT)); + } } } -- 2.30.2