--- /dev/null
+package org.usfirst.frc.team3501.robot.commandgroups;
+
+import org.usfirst.frc.team3501.robot.Constants.Direction;
+import org.usfirst.frc.team3501.robot.Robot;
+import org.usfirst.frc.team3501.robot.commands.driving.DriveDistance;
+import org.usfirst.frc.team3501.robot.commands.driving.TurnForAngle;
+
+import edu.wpi.first.wpilibj.command.CommandGroup;
+
+/**
+ * this is an auton strategy to cross the baseline and put a gear on a peg
+ * requires predetermined starting point anywhere except between 109.1767 inches
+ * and 205.7286 inches from the right side of the arena this program chooses
+ * which peg to go for based on the starting point
+ */
+public class AutonGearThenBaselinePegCloseToBoiler extends CommandGroup
+
+{
+
+ private static final double ROBOT_LENGTH = 40.0;
+ private static final double ROBOT_WIDTH = 36.0;
+
+ private static final double DISTANCE_TO_PEG_EXTENDED_BOILER = 73.1657;
+ private static final double DISTANCE_TO_PEG_EXTENDED_RETRIEVAL_ZONE = 114.3
+ + 17.625 - ((162 - (17.625 + 35.25) - 38.625) / Math.sqrt(3));
+ private static final double FIRST_LIMIT_LENGTH = 75.649;
+ private static final double SECOND_LIMIT_LENGTH = 162.8289106736;
+ private static final double LENGTH_OF_PEG = 10.5;
+ private static final double PEG_EXTENDED_BOILER = 117.518;
+ private static final double PEG_EXTENDED_RETRIEVAL_ZONE = (DISTANCE_TO_PEG_EXTENDED_RETRIEVAL_ZONE
+ * 2) / Math.sqrt(3);
+ private static final double DISTANCE_BETWEEN_BOILER_AND_RETRIEVAL_ZONE = 255.6765151902;
+ private static final double MOTOR_VALUE_TURN = 0.5;// this is probably not
+ // correct
+ private static final double MOTOR_VALUE_FORWARD = 0.5;// random
+ double distanceFromCorner; // This is the starting point
+ // from the right side of the
+ // arena in inches (can change)
+
+ /***
+ *
+ * @param team
+ * which side to start on: "BLUE" for blue side and "RED" for red
+ * side
+ * @param distanceFromBoilerCorner
+ * distance from the corner of the boiler
+ */
+ public AutonGearThenBaselinePegCloseToBoiler(String team,
+ int distanceFromBoilerCorner) {
+
+ this.distanceFromCorner = distanceFromBoilerCorner;
+ requires(Robot.getDriveTrain());
+ if (distanceFromBoilerCorner >= 0
+ && distanceFromBoilerCorner < FIRST_LIMIT_LENGTH) {
+ // boiler peg path
+
+ // drive straight into extended line of peg
+ addSequential(
+ new DriveDistance(
+ ((distanceFromCorner + (ROBOT_WIDTH / 2.0)) / Math.sqrt(3))
+ + DISTANCE_TO_PEG_EXTENDED_BOILER - (ROBOT_LENGTH / 2.0),
+ MOTOR_VALUE_FORWARD));
+ // position robot for optimal gear placement
+ addSequential(new TurnForAngle(60, Direction.LEFT, MOTOR_VALUE_TURN));
+ // put gear on peg
+ addSequential(new DriveDistance(PEG_EXTENDED_BOILER
+ - (((distanceFromCorner + (ROBOT_WIDTH / 2.0)) * 2)
+ / Math.sqrt(3))
+ - LENGTH_OF_PEG - (ROBOT_LENGTH / 2.0),
+ MOTOR_VALUE_FORWARD));
+
+ // does not include drift distance
+ } else if (distanceFromBoilerCorner > SECOND_LIMIT_LENGTH
+ && distanceFromBoilerCorner <= DISTANCE_BETWEEN_BOILER_AND_RETRIEVAL_ZONE) // mirror
+ // of
+ // right
+ // peg
+ // path
+ {
+ this.distanceFromCorner = DISTANCE_BETWEEN_BOILER_AND_RETRIEVAL_ZONE
+ - distanceFromBoilerCorner;
+ // Turning DISTANCE_FROM_BOILER_WALL into starting point from left side by
+ // reversing it
+ addSequential(
+ new DriveDistance(
+ ((distanceFromCorner + (ROBOT_WIDTH / 2.0)) / Math.sqrt(3))
+ + DISTANCE_TO_PEG_EXTENDED_RETRIEVAL_ZONE
+ - (ROBOT_LENGTH / 2.0),
+ MOTOR_VALUE_FORWARD));
+ addSequential(new TurnForAngle(60, Direction.RIGHT, MOTOR_VALUE_TURN));
+ addSequential(new DriveDistance(PEG_EXTENDED_RETRIEVAL_ZONE
+ - (((distanceFromCorner + (ROBOT_LENGTH / 2.0)) / Math.sqrt(3)) * 2)
+ - LENGTH_OF_PEG - (ROBOT_LENGTH / 2.0),
+ MOTOR_VALUE_FORWARD));
+ // does not include drift distance
+ } else {
+ System.out.println(
+ "DO NOT START HERE!!! MOVE CLOSER TO A WALL OR LOSE ALL AUTON POINTS!!");
+ }
+ }
+}