blob: 673368a5b16a4c8344d30b35d330dfdbf2c62fbd [file] [log] [blame]
Austin Schuh47017412013-03-10 11:50:46 -07001#include "stdio.h"
2
3#include "aos/aos_core.h"
4#include "aos/common/control_loop/Timing.h"
5#include "aos/common/time.h"
Austin Schuh6be011a2013-03-19 10:07:02 +00006#include "aos/common/util/trapezoid_profile.h"
Austin Schuh47017412013-03-10 11:50:46 -07007#include "frc971/autonomous/auto.q.h"
Austin Schuh6be011a2013-03-19 10:07:02 +00008#include "aos/common/messages/RobotState.q.h"
9#include "frc971/constants.h"
10#include "frc971/control_loops/drivetrain/drivetrain.q.h"
Austin Schuh47017412013-03-10 11:50:46 -070011#include "frc971/control_loops/wrist/wrist_motor.q.h"
12#include "frc971/control_loops/index/index_motor.q.h"
13#include "frc971/control_loops/shooter/shooter_motor.q.h"
14#include "frc971/control_loops/angle_adjust/angle_adjust_motor.q.h"
15
16using ::aos::time::Time;
17
18namespace frc971 {
19namespace autonomous {
20
Brian Silverman3b89ed82013-03-22 18:59:16 -070021static double left_initial_position, right_initial_position;
22
Austin Schuh6be011a2013-03-19 10:07:02 +000023bool ShouldExitAuto() {
24 ::frc971::autonomous::autonomous.FetchLatest();
25 bool ans = !::frc971::autonomous::autonomous->run_auto;
26 if (ans) {
27 LOG(INFO, "Time to exit auto mode\n");
28 }
29 return ans;
30}
31
Austin Schuh47017412013-03-10 11:50:46 -070032void SetShooterVelocity(double velocity) {
Austin Schuh6be011a2013-03-19 10:07:02 +000033 LOG(INFO, "Setting shooter velocity to %f\n", velocity);
Austin Schuh47017412013-03-10 11:50:46 -070034 control_loops::shooter.goal.MakeWithBuilder()
35 .velocity(velocity).Send();
36}
37
Austin Schuh6be011a2013-03-19 10:07:02 +000038void SetWristGoal(double goal) {
39 LOG(INFO, "Setting wrist to %f\n", goal);
40 control_loops::wrist.goal.MakeWithBuilder()
41 .goal(goal).Send();
42}
43
44void SetAngle_AdjustGoal(double goal) {
45 LOG(INFO, "Setting angle adjust to %f\n", goal);
46 control_loops::angle_adjust.goal.MakeWithBuilder()
47 .goal(goal).Send();
48}
49
50void StartIndex() {
51 LOG(INFO, "Starting index\n");
52 control_loops::index_loop.goal.MakeWithBuilder()
Austin Schuh47017412013-03-10 11:50:46 -070053 .goal_state(2).Send();
54}
55
Austin Schuh6be011a2013-03-19 10:07:02 +000056void PreloadIndex() {
57 LOG(INFO, "Preloading index\n");
58 control_loops::index_loop.goal.MakeWithBuilder()
Austin Schuh47017412013-03-10 11:50:46 -070059 .goal_state(3).Send();
60}
61
Austin Schuh6be011a2013-03-19 10:07:02 +000062void ShootIndex() {
63 LOG(INFO, "Shooting index\n");
64 control_loops::index_loop.goal.MakeWithBuilder()
Austin Schuh47017412013-03-10 11:50:46 -070065 .goal_state(4).Send();
66}
67
Brian Silvermanb8d389f2013-03-19 22:54:06 -070068void ResetIndex() {
69 LOG(INFO, "Resetting index\n");
70 control_loops::index_loop.goal.MakeWithBuilder()
71 .goal_state(5).Send();
72}
73
74void WaitForIndexReset() {
75 LOG(INFO, "Waiting for the indexer to reset\n");
76 control_loops::index_loop.status.FetchLatest();
77
78 // Fetch a couple index status packets to make sure that the indexer has run.
79 for (int i = 0; i < 5; ++i) {
80 LOG(DEBUG, "Fetching another index status packet\n");
81 control_loops::index_loop.status.FetchNextBlocking();
82 if (ShouldExitAuto()) return;
83 }
84 LOG(INFO, "Indexer is now reset.\n");
85}
86
Austin Schuh6be011a2013-03-19 10:07:02 +000087void WaitForWrist() {
88 LOG(INFO, "Waiting for the wrist\n");
89 control_loops::wrist.status.FetchLatest();
90
91 while (!control_loops::wrist.status.get()) {
92 LOG(WARNING, "No previous wrist packet, trying to fetch again\n");
93 control_loops::wrist.status.FetchNextBlocking();
94 }
95
96 while (!control_loops::wrist.status->done) {
97 control_loops::wrist.status.FetchNextBlocking();
98 LOG(DEBUG, "Got a new wrist status packet\n");
99 if (ShouldExitAuto()) return;
100 }
101 LOG(INFO, "Done waiting for the wrist\n");
102}
Austin Schuh6be011a2013-03-19 10:07:02 +0000103void WaitForIndex() {
104 LOG(INFO, "Waiting for the indexer to be ready to intake\n");
105 control_loops::index_loop.status.FetchLatest();
106
107 while (!control_loops::index_loop.status.get()) {
108 LOG(WARNING, "No previous index packet, trying to fetch again\n");
109 control_loops::index_loop.status.FetchNextBlocking();
110 }
111
112 while (!control_loops::index_loop.status->ready_to_intake) {
113 control_loops::index_loop.status.FetchNextBlocking();
114 if (ShouldExitAuto()) return;
115 }
116 LOG(INFO, "Indexer ready to intake\n");
117}
118
119void WaitForAngle_Adjust() {
120 LOG(INFO, "Waiting for the angle adjuster to finish\n");
121 control_loops::angle_adjust.status.FetchLatest();
122
123 while (!control_loops::angle_adjust.status.get()) {
124 LOG(WARNING, "No previous angle adjust packet, trying to fetch again\n");
125 control_loops::angle_adjust.status.FetchNextBlocking();
126 }
127
128 while (!control_loops::angle_adjust.status->done) {
129 control_loops::angle_adjust.status.FetchNextBlocking();
130 if (ShouldExitAuto()) return;
131 }
132 LOG(INFO, "Angle adjuster done\n");
133}
134
Austin Schuh47017412013-03-10 11:50:46 -0700135void WaitForShooter() {
Austin Schuh6be011a2013-03-19 10:07:02 +0000136 LOG(INFO, "Waiting for the shooter to spin up\n");
Austin Schuh47017412013-03-10 11:50:46 -0700137 control_loops::shooter.status.FetchLatest();
Austin Schuh6be011a2013-03-19 10:07:02 +0000138
139 while (!control_loops::shooter.status.get()) {
140 LOG(WARNING, "No previous shooteracket, trying to fetch again\n");
Austin Schuh47017412013-03-10 11:50:46 -0700141 control_loops::shooter.status.FetchNextBlocking();
142 }
Austin Schuh47017412013-03-10 11:50:46 -0700143
Austin Schuh6be011a2013-03-19 10:07:02 +0000144 while (!control_loops::shooter.status->ready) {
145 control_loops::shooter.status.FetchNextBlocking();
146 if (ShouldExitAuto()) return;
Austin Schuh47017412013-03-10 11:50:46 -0700147 }
Austin Schuh6be011a2013-03-19 10:07:02 +0000148 LOG(INFO, "Shooter ready to shoot\n");
Austin Schuh47017412013-03-10 11:50:46 -0700149}
150
Austin Schuh6be011a2013-03-19 10:07:02 +0000151void ShootNDiscs(int n) {
152 LOG(INFO, "Waiting until %d discs have been shot\n", n);
153 control_loops::index_loop.status.FetchLatest();
154
155 while (!control_loops::index_loop.status.get()) {
156 LOG(WARNING, "No previous index_loop packet, trying to fetch again\n");
157 control_loops::index_loop.status.FetchNextBlocking();
158 }
159
160 int final_disc_count = control_loops::index_loop.status->shot_disc_count + n;
161 LOG(DEBUG, "Disc count should be %d when done\n", final_disc_count);
162 while (final_disc_count > control_loops::index_loop.status->shot_disc_count) {
163 control_loops::index_loop.status.FetchNextBlocking();
164 if (ShouldExitAuto()) return;
165 }
166 LOG(INFO, "Shot %d discs\n", n);
Austin Schuh47017412013-03-10 11:50:46 -0700167}
168
Austin Schuh6be011a2013-03-19 10:07:02 +0000169void StopDrivetrain() {
170 LOG(INFO, "Stopping the drivetrain\n");
Austin Schuh47017412013-03-10 11:50:46 -0700171 control_loops::drivetrain.goal.MakeWithBuilder()
Brian Silverman3b89ed82013-03-22 18:59:16 -0700172 .control_loop_driving(true)
Brian Silvermance86bac2013-03-31 19:07:24 -0700173 .left_goal(left_initial_position)
174 .left_velocity_goal(0)
175 .right_goal(right_initial_position)
176 .right_velocity_goal(0)
177 .quickturn(false)
178 .Send();
179}
180
181void ResetDrivetrain() {
182 LOG(INFO, "resetting the drivetrain\n");
183 control_loops::drivetrain.goal.MakeWithBuilder()
184 .control_loop_driving(false)
Austin Schuh6be011a2013-03-19 10:07:02 +0000185 .highgear(false)
186 .steering(0.0)
187 .throttle(0.0)
Austin Schuh6be011a2013-03-19 10:07:02 +0000188 .Send();
189}
190
Brian Silvermaned2cbde2013-03-31 01:56:14 -0700191void SetDriveGoal(double yoffset, double maximum_velocity = 1.5) {
Austin Schuh6be011a2013-03-19 10:07:02 +0000192 LOG(INFO, "Going to move %f\n", yoffset);
193
194 // Measured conversion to get the distance right.
Austin Schuh6be011a2013-03-19 10:07:02 +0000195 ::aos::util::TrapezoidProfile profile(::aos::time::Time::InMS(10));
196 ::Eigen::Matrix<double, 2, 1> driveTrainState;
197 const double goal_velocity = 0.0;
198 const double epsilon = 0.01;
199
Austin Schuhfae53362013-03-23 04:39:48 +0000200 profile.set_maximum_acceleration(2.0);
Brian Silvermaned2cbde2013-03-31 01:56:14 -0700201 profile.set_maximum_velocity(maximum_velocity);
Austin Schuh6be011a2013-03-19 10:07:02 +0000202
Austin Schuh6be011a2013-03-19 10:07:02 +0000203 while (true) {
Brian Silverman7f09f972013-03-22 23:11:39 -0700204 ::aos::time::PhasedLoop10MS(5000); // wait until next 10ms tick
Austin Schuh6be011a2013-03-19 10:07:02 +0000205 driveTrainState = profile.Update(yoffset, goal_velocity);
206
Brian Silverman3b89ed82013-03-22 18:59:16 -0700207 if (::std::abs(driveTrainState(0, 0) - yoffset) < epsilon) break;
Austin Schuh6be011a2013-03-19 10:07:02 +0000208 if (ShouldExitAuto()) return;
209
210 LOG(DEBUG, "Driving left to %f, right to %f\n",
211 driveTrainState(0, 0) + left_initial_position,
212 driveTrainState(0, 0) + right_initial_position);
213 control_loops::drivetrain.goal.MakeWithBuilder()
214 .control_loop_driving(true)
215 .highgear(false)
216 .left_goal(driveTrainState(0, 0) + left_initial_position)
217 .right_goal(driveTrainState(0, 0) + right_initial_position)
218 .left_velocity_goal(driveTrainState(1, 0))
219 .right_velocity_goal(driveTrainState(1, 0))
220 .Send();
221 }
Brian Silverman3b89ed82013-03-22 18:59:16 -0700222 left_initial_position += yoffset;
223 right_initial_position += yoffset;
Austin Schuh6be011a2013-03-19 10:07:02 +0000224 LOG(INFO, "Done moving\n");
225}
226
Brian Silverman13be6682013-03-22 21:02:07 -0700227// Drives forward while we can pick up discs up to max_distance (in meters).
Brian Silverman7992d6e2013-03-24 19:20:54 -0700228void DriveForwardPickUp(double max_distance, double wrist_angle) {
Brian Silverman13be6682013-03-22 21:02:07 -0700229 LOG(INFO, "going to pick up at a max distance of %f\n", max_distance);
Brian Silverman13be6682013-03-22 21:02:07 -0700230
231 static const ::aos::time::Time kPeriod = ::aos::time::Time::InMS(10);
232 ::aos::util::TrapezoidProfile profile(kPeriod);
233 ::Eigen::Matrix<double, 2, 1> driveTrainState;
234 const double goal_velocity = 0.0;
235 const double epsilon = 0.01;
236 static const double kMaximumAcceleration = 1.0;
237
238 profile.set_maximum_acceleration(kMaximumAcceleration);
239 profile.set_maximum_velocity(0.6);
240
Brian Silverman13be6682013-03-22 21:02:07 -0700241 bool driving_back = false;
Brian Silvermaned2cbde2013-03-31 01:56:14 -0700242 const double kDestination = -0.20;
Brian Silverman13be6682013-03-22 21:02:07 -0700243
244 while (true) {
Brian Silverman7f09f972013-03-22 23:11:39 -0700245 ::aos::time::PhasedLoop10MS(5000); // wait until next 10ms tick
Brian Silvermanc6ba6ee2013-03-22 21:10:38 -0700246 driveTrainState = profile.Update(driving_back ? kDestination : max_distance,
247 goal_velocity);
Brian Silverman13be6682013-03-22 21:02:07 -0700248
249 if (ShouldExitAuto()) return;
250
Brian Silvermanc6ba6ee2013-03-22 21:10:38 -0700251 if (driving_back) {
252 if (::std::abs(driveTrainState(0, 0)) < epsilon) break;
253 } else if (::std::abs(driveTrainState(0, 0) - max_distance) < epsilon) {
254 LOG(INFO, "went the max distance; driving back\n");
255 driving_back = true;
Brian Silverman7992d6e2013-03-24 19:20:54 -0700256 profile.set_maximum_velocity(2.5);
257 SetWristGoal(wrist_angle);
Brian Silverman13be6682013-03-22 21:02:07 -0700258 }
259
260 if (control_loops::index_loop.status.FetchLatest()) {
261 if (control_loops::index_loop.status->hopper_disc_count >= 4) {
262 LOG(INFO, "done intaking; driving back\n");
263 driving_back = true;
Brian Silverman7992d6e2013-03-24 19:20:54 -0700264 profile.set_maximum_velocity(2.5);
265 SetWristGoal(wrist_angle);
Brian Silverman13be6682013-03-22 21:02:07 -0700266 }
267 } else {
268 LOG(WARNING, "getting index status failed\n");
269 }
270
271 LOG(DEBUG, "Driving left to %f, right to %f\n",
272 driveTrainState(0, 0) + left_initial_position,
273 driveTrainState(0, 0) + right_initial_position);
274 control_loops::drivetrain.goal.MakeWithBuilder()
275 .control_loop_driving(true)
276 .highgear(false)
277 .left_goal(driveTrainState(0, 0) + left_initial_position)
278 .right_goal(driveTrainState(0, 0) + right_initial_position)
279 .left_velocity_goal(driveTrainState(1, 0))
280 .right_velocity_goal(driveTrainState(1, 0))
281 .Send();
282 }
Austin Schuhfae53362013-03-23 04:39:48 +0000283 left_initial_position += kDestination;
284 right_initial_position += kDestination;
Brian Silverman13be6682013-03-22 21:02:07 -0700285 LOG(INFO, "Done moving\n");
286}
287
Brian Silverman3b89ed82013-03-22 18:59:16 -0700288void DriveSpin(double radians) {
289 LOG(INFO, "going to spin %f\n", radians);
290
291 ::aos::util::TrapezoidProfile profile(::aos::time::Time::InMS(10));
292 ::Eigen::Matrix<double, 2, 1> driveTrainState;
293 const double goal_velocity = 0.0;
294 const double epsilon = 0.01;
Brian Silverman13be6682013-03-22 21:02:07 -0700295 // in drivetrain "meters"
Brian Silverman3b89ed82013-03-22 18:59:16 -0700296 const double kRobotWidth = 0.4544;
297
Brian Silverman7992d6e2013-03-24 19:20:54 -0700298 profile.set_maximum_acceleration(1.5);
299 profile.set_maximum_velocity(0.8);
Brian Silverman3b89ed82013-03-22 18:59:16 -0700300
301 const double side_offset = kRobotWidth * radians / 2.0;
302
303 while (true) {
Brian Silverman7f09f972013-03-22 23:11:39 -0700304 ::aos::time::PhasedLoop10MS(5000); // wait until next 10ms tick
Brian Silverman3b89ed82013-03-22 18:59:16 -0700305 driveTrainState = profile.Update(side_offset, goal_velocity);
306
307 if (::std::abs(driveTrainState(0, 0) - side_offset) < epsilon) break;
308 if (ShouldExitAuto()) return;
309
310 LOG(DEBUG, "Driving left to %f, right to %f\n",
Brian Silverman7992d6e2013-03-24 19:20:54 -0700311 left_initial_position - driveTrainState(0, 0),
312 right_initial_position + driveTrainState(0, 0));
Brian Silverman3b89ed82013-03-22 18:59:16 -0700313 control_loops::drivetrain.goal.MakeWithBuilder()
314 .control_loop_driving(true)
315 .highgear(false)
Brian Silverman7992d6e2013-03-24 19:20:54 -0700316 .left_goal(left_initial_position - driveTrainState(0, 0))
317 .right_goal(right_initial_position + driveTrainState(0, 0))
318 .left_velocity_goal(-driveTrainState(1, 0))
319 .right_velocity_goal(driveTrainState(1, 0))
Brian Silverman3b89ed82013-03-22 18:59:16 -0700320 .Send();
321 }
Brian Silverman7992d6e2013-03-24 19:20:54 -0700322 left_initial_position -= side_offset;
323 right_initial_position += side_offset;
Brian Silverman3b89ed82013-03-22 18:59:16 -0700324 LOG(INFO, "Done moving\n");
325}
326
327// start with N discs in the indexer
Austin Schuh6be011a2013-03-19 10:07:02 +0000328void HandleAuto() {
329 LOG(INFO, "Handling auto mode\n");
Brian Silvermance86bac2013-03-31 19:07:24 -0700330
Austin Schuh6be011a2013-03-19 10:07:02 +0000331 double WRIST_UP;
Brian Silvermance86bac2013-03-31 19:07:24 -0700332 const double WRIST_DOWN = -0.580;
333 const double WRIST_DOWN_TWO = WRIST_DOWN - 0.010;
Brian Silverman304b2bf2013-04-04 17:54:41 -0700334 const double ANGLE_ONE = 0.556;
335 const double ANGLE_TWO = 0.677;
Brian Silvermance86bac2013-03-31 19:07:24 -0700336
337 ResetIndex();
338 SetWristGoal(1.0); // wrist must calibrate itself on power-up
339 SetAngle_AdjustGoal(ANGLE_TWO); // make it still move a bit
340 SetShooterVelocity(0.0); // or else it keeps spinning from last time
341 ResetDrivetrain();
342
Brian Silverman304b2bf2013-04-04 17:54:41 -0700343 //::aos::time::SleepFor(::aos::time::Time::InSeconds(20));
Brian Silvermance86bac2013-03-31 19:07:24 -0700344 if (ShouldExitAuto()) return;
Austin Schuh6be011a2013-03-19 10:07:02 +0000345
346 ::aos::robot_state.FetchLatest();
Brian Silvermanc5277542013-03-22 13:33:07 -0700347 if (!::aos::robot_state.get() ||
Austin Schuh6be011a2013-03-19 10:07:02 +0000348 !constants::wrist_hall_effect_start_angle(&WRIST_UP)) {
349 LOG(ERROR, "Constants not ready\n");
350 return;
351 }
352 WRIST_UP -= 0.4;
353 LOG(INFO, "Got constants\n");
Austin Schuh6be011a2013-03-19 10:07:02 +0000354
Brian Silverman3b89ed82013-03-22 18:59:16 -0700355 control_loops::drivetrain.position.FetchLatest();
356 while (!control_loops::drivetrain.position.get()) {
357 LOG(WARNING, "No previous drivetrain position packet, trying to fetch again\n");
358 control_loops::drivetrain.position.FetchNextBlocking();
359 }
360 left_initial_position =
361 control_loops::drivetrain.position->left_encoder;
362 right_initial_position =
363 control_loops::drivetrain.position->right_encoder;
364
Brian Silverman3b89ed82013-03-22 18:59:16 -0700365 StopDrivetrain();
Austin Schuh6be011a2013-03-19 10:07:02 +0000366
Brian Silverman7f09f972013-03-22 23:11:39 -0700367 SetWristGoal(WRIST_UP); // wrist must calibrate itself on power-up
Austin Schuh6be011a2013-03-19 10:07:02 +0000368 SetAngle_AdjustGoal(ANGLE_ONE);
Brian Silverman304b2bf2013-04-04 17:54:41 -0700369 SetShooterVelocity(380.0);
Brian Silvermanb8d389f2013-03-19 22:54:06 -0700370 WaitForIndexReset();
Brian Silverman7f09f972013-03-22 23:11:39 -0700371 if (ShouldExitAuto()) return;
372 PreloadIndex(); // spin to top and put 1 disc into loader
Austin Schuh6be011a2013-03-19 10:07:02 +0000373
374 if (ShouldExitAuto()) return;
375 WaitForWrist();
376 if (ShouldExitAuto()) return;
377 WaitForAngle_Adjust();
Brian Silverman7f09f972013-03-22 23:11:39 -0700378 ShootIndex(); // tilt up, shoot, repeat until empty
379 // calls WaitForShooter
380 ShootNDiscs(3); // ShootNDiscs returns if ShouldExitAuto
Austin Schuh6be011a2013-03-19 10:07:02 +0000381 if (ShouldExitAuto()) return;
Austin Schuh6be011a2013-03-19 10:07:02 +0000382
Brian Silverman7f09f972013-03-22 23:11:39 -0700383 StartIndex(); // take in up to 4 discs
Austin Schuh6be011a2013-03-19 10:07:02 +0000384
Brian Silvermaned2cbde2013-03-31 01:56:14 -0700385 if (false) {
386 const double kDistanceToCenterMeters = 3.11023;
387 const double kMaxPickupDistance = 2.5;
388 const double kTurnToCenterDegrees = 78.2;
Austin Schuh6be011a2013-03-19 10:07:02 +0000389
Brian Silvermaned2cbde2013-03-31 01:56:14 -0700390 // Drive back to the center line.
391 SetDriveGoal(-kDistanceToCenterMeters);
392 if (ShouldExitAuto()) return;
Austin Schuh6be011a2013-03-19 10:07:02 +0000393
Brian Silvermaned2cbde2013-03-31 01:56:14 -0700394 SetWristGoal(WRIST_DOWN);
395 // Turn towards the center.
396 DriveSpin(kTurnToCenterDegrees * M_PI / 180.0);
397 if (ShouldExitAuto()) return;
398 WaitForWrist();
399 if (ShouldExitAuto()) return;
Austin Schuhfae53362013-03-23 04:39:48 +0000400
Brian Silvermaned2cbde2013-03-31 01:56:14 -0700401 // Pick up at most 4 discs and drive at most kMaxPickupDistance.
402 DriveForwardPickUp(kMaxPickupDistance, WRIST_UP);
Austin Schuhfae53362013-03-23 04:39:48 +0000403
Brian Silvermaned2cbde2013-03-31 01:56:14 -0700404 SetWristGoal(WRIST_UP);
405 DriveSpin(-kTurnToCenterDegrees * M_PI / 180.0);
406 if (ShouldExitAuto()) return;
407 // Drive back to where we were.
408 SetDriveGoal(kDistanceToCenterMeters);
409 if (ShouldExitAuto()) return;
Austin Schuhfae53362013-03-23 04:39:48 +0000410
Brian Silvermaned2cbde2013-03-31 01:56:14 -0700411 return;
Brian Silverman7992d6e2013-03-24 19:20:54 -0700412
Brian Silvermaned2cbde2013-03-31 01:56:14 -0700413 ShootNDiscs(4);
414 if (ShouldExitAuto()) return;
415 } else {
Austin Schuh9f97ce62013-04-04 05:48:28 +0000416 // Delay to let the disc out of the shooter.
Brian Silverman304b2bf2013-04-04 17:54:41 -0700417 ::aos::time::SleepFor(::aos::time::Time::InSeconds(0.25));
Brian Silvermaned2cbde2013-03-31 01:56:14 -0700418 SetWristGoal(WRIST_DOWN);
Brian Silvermaned2cbde2013-03-31 01:56:14 -0700419 StartIndex(); // take in up to 4 discs
420
421 if (ShouldExitAuto()) return;
422 WaitForWrist(); // wrist must be down before moving
423 ::aos::time::SleepFor(::aos::time::Time::InSeconds(0.25));
Austin Schuh9f97ce62013-04-04 05:48:28 +0000424 SetAngle_AdjustGoal(ANGLE_TWO);
425 SetShooterVelocity(375.0);
Brian Silvermaned2cbde2013-03-31 01:56:14 -0700426
427 if (ShouldExitAuto()) return;
428 WaitForIndex(); // ready to pick up discs
429
Brian Silvermance86bac2013-03-31 19:07:24 -0700430 static const double kDriveDistance = 2.8;
431 static const double kFirstDrive = 0.27;
432 static const double kSecondShootDistance = 2.0;
Brian Silvermaned2cbde2013-03-31 01:56:14 -0700433 SetDriveGoal(kFirstDrive, 0.6);
Brian Silvermance86bac2013-03-31 19:07:24 -0700434 SetWristGoal(WRIST_DOWN_TWO);
435 SetDriveGoal(kDriveDistance - kFirstDrive, 2.0);
Brian Silvermaned2cbde2013-03-31 01:56:14 -0700436 if (ShouldExitAuto()) return;
437
Brian Silvermance86bac2013-03-31 19:07:24 -0700438 ::aos::time::SleepFor(::aos::time::Time::InSeconds(0.5));
439 SetDriveGoal(kSecondShootDistance - kDriveDistance, 2.0);
Brian Silvermaned2cbde2013-03-31 01:56:14 -0700440 PreloadIndex();
Brian Silvermaned2cbde2013-03-31 01:56:14 -0700441
442 if (ShouldExitAuto()) return;
443 WaitForAngle_Adjust();
444 if (ShouldExitAuto()) return;
445 ShootIndex();
446 if (ShouldExitAuto()) return;
447 }
Austin Schuh47017412013-03-10 11:50:46 -0700448}
449
450} // namespace autonomous
451} // namespace frc971