fix command names and get rid of unused stuff
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / commands / auton / AlignToScore.java
CommitLineData
1fb6ed96 1package org.usfirst.frc.team3501.robot.commands.auton;
ff5c6dcc 2
dfcc1b21
CZ
3import org.usfirst.frc.team3501.robot.commands.driving.DriveDistance;
4import org.usfirst.frc.team3501.robot.commands.driving.TurnForAngle;
1696ae28 5
ff5c6dcc
ME
6import edu.wpi.first.wpilibj.command.CommandGroup;
7
8/**
9 * This command group will be used in autonomous. Based on what position the
10ca638d
ME
10 * robot is in, the robot will align with the goal. In the Software 2015-2016
11 * Google folder is a picture explaining each of the cases.
12 *
9d87dd2d
ME
13 * dependency on sensors: lidars, encoders, gyro
14 *
15 * dependency on subsystems: drivetrain
16 *
17 * dependency on other commands: TurnForAngle(), DriveForDistance()
ff5c6dcc
ME
18 *
19 * pre-condition: robot is flush against a defense at the specified position in
20 * the opponent's courtyard
21 *
22 * post-condition: the robot is parallel to one of the three goals and the
23 * shooter is facing that goal
24 *
25 */
26public class AlignToScore extends CommandGroup {
ff9a504f
ME
27 private final static double CENTER_OF_MASS_TO_ROBOT_FRONT = 0;
28 private final static double DIST_CASTLE_WALL_TO_SIDE_GOAL = 0;
29 private final static double DIST_CASTLE_WALL_TO_FRONT_GOAL = 0;
1696ae28 30
5e1e9b1e 31 private final double DEFAULT_SPEED = 0.5;
dfcc1b21 32 private final double maxTimeout = 5;
5e1e9b1e 33
af279fe0
ME
34 // in inches
35 // assuming that positive angle means turning right
36 // and negative angle means turning left
37
1696ae28 38 // constants for position 1: low bar
af279fe0
ME
39 private final double POS1_DIST1 = 109;
40 private final double POS1_TURN1 = 60;
5e1e9b1e
ME
41 private final double POS1_DIST2 = 0;
42
43 // constants for position 2
af279fe0
ME
44 private final double POS2_DIST1 = 140;
45 private final double POS2_TURN1 = 60;
4347c80d
ME
46 private final double POS2_DIST2 = 0;
47
5e1e9b1e 48 // constants for position 3
a2b9c4a9 49 private final double POS3_DIST1 = 0;
af279fe0
ME
50 private final double POS3_TURN1 = 90;
51 private final double POS3_DIST2 = 35.5;
52 private final double POS3_TURN2 = -90;
a2b9c4a9 53 private final double POS3_DIST3 = 0;
5e1e9b1e
ME
54
55 // constants for position 4
1696ae28 56 private final double POS4_DIST1 = 0;
af279fe0
ME
57 private final double POS4_TURN1 = -90;
58 private final double POS4_DIST2 = 18.5;
59 private final double POS4_TURN2 = 90;
1696ae28 60 private final double POS4_DIST3 = 0;
5e1e9b1e
ME
61
62 // constants for position 5
1696ae28 63 private final double POS5_DIST1 = 0;
1598df61
ME
64 private final double POS5_TURN1 = -90;
65 private final double POS5_DIST2 = 72.5;
66 private final double POS5_TURN2 = 90;
67 private final double POS5_DIST3 = 0;
ff5c6dcc 68
ff9a504f
ME
69 public double horizontalDistToGoal;
70
ff5c6dcc
ME
71 public AlignToScore(int position) {
72
0d4900b6 73 if (position == 1) {
5e1e9b1e 74
0d4900b6 75 // position 1 is always the low bar
ff5c6dcc 76
dfcc1b21
CZ
77 addSequential(new DriveDistance(POS1_DIST1, DEFAULT_SPEED));
78 addSequential(new TurnForAngle(POS1_TURN1, maxTimeout));
79 addSequential(new DriveDistance(POS1_DIST2, DEFAULT_SPEED));
ff9a504f 80 horizontalDistToGoal = 0;
0d4900b6 81 } else if (position == 2) {
a2b9c4a9 82
dfcc1b21
CZ
83 addSequential(new DriveDistance(POS2_DIST1, DEFAULT_SPEED));
84 addSequential(new TurnForAngle(POS2_TURN1, maxTimeout));
85 addSequential(new DriveDistance(POS2_DIST2, DEFAULT_SPEED));
ff9a504f 86 horizontalDistToGoal = 0;
a2b9c4a9 87
0d4900b6 88 } else if (position == 3) {
ff5c6dcc 89
dfcc1b21
CZ
90 addSequential(new DriveDistance(POS3_DIST1, DEFAULT_SPEED));
91 addSequential(new TurnForAngle(POS3_TURN1, maxTimeout));
92 addSequential(new DriveDistance(POS3_DIST2, DEFAULT_SPEED));
93 addSequential(new TurnForAngle(POS3_TURN2, maxTimeout));
94 addSequential(new DriveDistance(POS3_DIST3, DEFAULT_SPEED));
ff9a504f 95 horizontalDistToGoal = 0;
ff5c6dcc 96
0d4900b6 97 } else if (position == 4) {
ff5c6dcc 98
dfcc1b21
CZ
99 addSequential(new DriveDistance(POS4_DIST1, DEFAULT_SPEED));
100 addSequential(new TurnForAngle(POS4_TURN1, maxTimeout));
101 addSequential(new DriveDistance(POS4_DIST2, DEFAULT_SPEED));
102 addSequential(new TurnForAngle(POS4_TURN2, maxTimeout));
103 addSequential(new DriveDistance(POS4_DIST3, DEFAULT_SPEED));
ff9a504f 104 horizontalDistToGoal = 0;
ff5c6dcc 105
0d4900b6 106 } else if (position == 5) {
ff5c6dcc 107
dfcc1b21
CZ
108 addSequential(new DriveDistance(POS5_DIST1, DEFAULT_SPEED));
109 addSequential(new TurnForAngle(POS5_TURN1, maxTimeout));
110 addSequential(new DriveDistance(POS5_DIST2, DEFAULT_SPEED));
111 addSequential(new TurnForAngle(POS5_TURN2, maxTimeout));
112 addSequential(new DriveDistance(POS5_DIST3, DEFAULT_SPEED));
ff9a504f 113 horizontalDistToGoal = 0;
1598df61 114
ff5c6dcc
ME
115 }
116 }
1696ae28 117
93453536
CZ
118 // following commented out method is calculations for path of robot in auton
119 // after passing through defense using two lidars
120 /*
121 * public static double lidarCalculateAngleToTurn(int position,
122 * double horizontalDistToGoal) {
123 * double leftDist = Robot.driveTrain.getLeftLidarDistance();
124 * double rightDist = Robot.driveTrain.getRightLidarDistance();
125 *
126 * double errorAngle = Math.atan(Math.abs(leftDist - rightDist) / 2);
127 * double distToTower;
128 * // TODO: figure out if we do want to shoot into the side goal if we are
129 * // in position 1 or 2, or if we want to change that
130 * if (position == 1 || position == 2) {
131 * distToTower = Math
132 * .cos(CENTER_OF_MASS_TO_ROBOT_FRONT + (leftDist - rightDist) / 2)
133 * - DIST_CASTLE_WALL_TO_SIDE_GOAL;
134 * }
135 *
136 * // TODO: figure out if we do want to shoot into the font goal if we are
137 * // in position 3, 4, 5, or if we want to change that
138 * else {
139 * distToTower = Math
140 * .cos(CENTER_OF_MASS_TO_ROBOT_FRONT + (leftDist - rightDist) / 2)
141 * - DIST_CASTLE_WALL_TO_SIDE_GOAL;
142 * }
143 *
144 * double angleToTurn = Math.atan(distToTower / horizontalDistToGoal);
145 *
146 * return angleToTurn;
147 * }
148 */
ff5c6dcc 149}