fix stuff
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commandgroups / AutonGearThenBaselinePegCloseToBoiler.java
CommitLineData
fca066b6
CZ
1package org.usfirst.frc.team3501.robot.commandgroups;
2
3import org.usfirst.frc.team3501.robot.Constants.Direction;
4import org.usfirst.frc.team3501.robot.Robot;
5import org.usfirst.frc.team3501.robot.commands.driving.DriveDistance;
6import org.usfirst.frc.team3501.robot.commands.driving.TurnForAngle;
7
8import edu.wpi.first.wpilibj.command.CommandGroup;
9
10/**
11 * this is an auton strategy to cross the baseline and put a gear on a peg
12 * requires predetermined starting point anywhere except between 109.1767 inches
13 * and 205.7286 inches from the right side of the arena this program chooses
14 * which peg to go for based on the starting point
15 */
16public class AutonGearThenBaselinePegCloseToBoiler extends CommandGroup
17
18{
19
d64e0d69
CZ
20 private static final double ROBOT_LENGTH = 36.0;
21 private static final double ROBOT_WIDTH = 40.0;
fca066b6 22
d64e0d69
CZ
23 private static final double STRAIGHT_DIST_FROM_BOILER = 76.8;
24 private static final double DISTANCE_TO_RETRIEVAL_PEG = 114.3 + 17.625
25 - ((162 - (17.625 + 35.25) - 38.625) / Math.sqrt(3));
fca066b6
CZ
26 private static final double LENGTH_OF_PEG = 10.5;
27 private static final double PEG_EXTENDED_BOILER = 117.518;
d64e0d69 28 private static final double PEG_EXTENDED_RETRIEVAL_ZONE = (DISTANCE_TO_RETRIEVAL_PEG
fca066b6
CZ
29 * 2) / Math.sqrt(3);
30 private static final double DISTANCE_BETWEEN_BOILER_AND_RETRIEVAL_ZONE = 255.6765151902;
31 private static final double MOTOR_VALUE_TURN = 0.5;// this is probably not
32 // correct
33 private static final double MOTOR_VALUE_FORWARD = 0.5;// random
34 double distanceFromCorner; // This is the starting point
35 // from the right side of the
36 // arena in inches (can change)
37
38 /***
d64e0d69
CZ
39 *
40 * @param side
fca066b6
CZ
41 * which side to start on: "BLUE" for blue side and "RED" for red
42 * side
d64e0d69 43 * @param distanceFromcorner
fca066b6
CZ
44 * distance from the corner of the boiler
45 */
d64e0d69
CZ
46 public AutonGearThenBaselinePegCloseToBoiler(String side,
47 int distanceFromcorner) {
fca066b6 48 requires(Robot.getDriveTrain());
fca066b6 49
d64e0d69
CZ
50 if (side.equals("BOILER")) {
51 addSequential(new DriveDistance(
52 131.6 - (94.88 - ROBOT_WIDTH / 2 - distanceFromCorner) / Math.sqrt(3)
53 - ROBOT_LENGTH / 2,
54 5));
55 // addSequential(new DriveDistance(
56 // ((distanceFromCorner + (ROBOT_WIDTH / 2.0)) / Math.sqrt(3))
57 // + STRAIGHT_DIST_FROM_BOILER - (ROBOT_LENGTH / 2.0),
58 // MOTOR_VALUE_FORWARD));
fca066b6 59 // position robot for optimal gear placement
d64e0d69 60 addSequential(new TurnForAngle(60, Direction.RIGHT, 5));
fca066b6 61 // put gear on peg
d64e0d69
CZ
62 addSequential(new DriveDistance(
63 2 * (94.88 - ROBOT_WIDTH / 2 - distanceFromCorner) / Math.sqrt(3)
64 - ROBOT_LENGTH / 2 + 7,
65 5));
66 // addSequential(new DriveDistance(PEG_EXTENDED_BOILER
67 // - (((distanceFromCorner + (ROBOT_WIDTH / 2.0)) * 2) / Math.sqrt(3))
68 // - LENGTH_OF_PEG - (ROBOT_LENGTH / 2.0), MOTOR_VALUE_FORWARD));
fca066b6
CZ
69
70 // does not include drift distance
d64e0d69
CZ
71 } else if (side.equals("RETRIEVAL")) {
72 addSequential(new DriveDistance(
73 131.6 - (93.13 - ROBOT_WIDTH / 2 - distanceFromCorner) / Math.sqrt(3)
74 - ROBOT_LENGTH / 2,
75 5));
76 addSequential(new TurnForAngle(60, Direction.LEFT, 5));
77 addSequential(new DriveDistance(
78 2 * (93.13 - ROBOT_WIDTH / 2 - distanceFromCorner) / Math.sqrt(3)
79 - ROBOT_LENGTH / 2,
80 5));
81 // addSequential(new DriveDistance(
82 // ((distanceFromCorner + (ROBOT_WIDTH / 2.0)) / Math.sqrt(3))
83 // + DISTANCE_TO_RETRIEVAL_PEG - (ROBOT_LENGTH / 2.0),
84 // MOTOR_VALUE_FORWARD));
85 // addSequential(new TurnForAngle(60, Direction.RIGHT, MOTOR_VALUE_TURN));
86 // addSequential(new DriveDistance(PEG_EXTENDED_RETRIEVAL_ZONE
87 // - (((distanceFromCorner + (ROBOT_LENGTH / 2.0)) / Math.sqrt(3)) * 2)
88 // - LENGTH_OF_PEG - (ROBOT_LENGTH / 2.0), MOTOR_VALUE_FORWARD));
fca066b6 89 // does not include drift distance
fca066b6
CZ
90 }
91 }
92}