blob: ea077989d1c9ea8bda19ad53d5649520eb950d86 [file] [log] [blame]
Brian Silverman20141f92015-01-05 17:39:01 -08001#include <stdio.h>
2#include <string.h>
3#include <unistd.h>
4#include <math.h>
5
6#include "aos/linux_code/init.h"
7#include "aos/prime/input/joystick_input.h"
8#include "aos/common/input/driver_station_data.h"
9#include "aos/common/logging/logging.h"
10#include "aos/common/util/log_interval.h"
11#include "aos/common/time.h"
Ben Fredricksond69f38b2015-01-28 20:06:15 -080012#include "aos/common/actions/actions.h"
Brian Silverman20141f92015-01-05 17:39:01 -080013
Daniel Petti61896522015-02-15 18:01:43 -080014#include "frc971/control_loops/claw/claw.q.h"
Brian Silverman20141f92015-01-05 17:39:01 -080015#include "frc971/control_loops/drivetrain/drivetrain.q.h"
Daniel Petti61896522015-02-15 18:01:43 -080016#include "frc971/control_loops/fridge/fridge.q.h"
Brian Silverman20141f92015-01-05 17:39:01 -080017#include "frc971/constants.h"
18#include "frc971/queues/gyro.q.h"
19#include "frc971/autonomous/auto.q.h"
Ben Fredrickson9fb2ab12015-02-16 16:42:08 -080020#include "frc971/actors/fridge_profile_actor.h"
Austin Schuhd8b2a242015-02-22 21:46:53 -080021#include "frc971/actors/pickup_actor.h"
22#include "frc971/actors/stack_actor.h"
23#include "frc971/actors/lift_actor.h"
Austin Schuh994d42c2015-03-01 00:02:17 -080024#include "frc971/actors/can_pickup_actor.h"
Austin Schuh700b9222015-03-01 03:03:15 -080025#include "frc971/actors/horizontal_can_pickup_actor.h"
Brian Silverman20141f92015-01-05 17:39:01 -080026
Daniel Petti61896522015-02-15 18:01:43 -080027using ::frc971::control_loops::claw_queue;
Brian Silvermanada5f2c2015-02-01 02:41:14 -050028using ::frc971::control_loops::drivetrain_queue;
Daniel Petti61896522015-02-15 18:01:43 -080029using ::frc971::control_loops::fridge_queue;
Brian Silverman20141f92015-01-05 17:39:01 -080030using ::frc971::sensors::gyro_reading;
31
32using ::aos::input::driver_station::ButtonLocation;
33using ::aos::input::driver_station::JoystickAxis;
34using ::aos::input::driver_station::ControlBit;
35
36namespace frc971 {
37namespace input {
38namespace joysticks {
39
Ben Fredrickson9fb2ab12015-02-16 16:42:08 -080040// preset motion limits
Austin Schuhd8b2a242015-02-22 21:46:53 -080041static const double kArmDebugVelocity = 0.40;
42static const double kArmDebugAcceleration = 1.0;
43static const double kElevatorDebugVelocity = 0.5;
Ben Fredrickson9fb2ab12015-02-16 16:42:08 -080044static const double kElevatorDebugAcceleration = 2.2;
45
Brian Silverman20141f92015-01-05 17:39:01 -080046const JoystickAxis kSteeringWheel(1, 1), kDriveThrottle(2, 2);
47const ButtonLocation kShiftHigh(2, 1), kShiftLow(2, 3);
48const ButtonLocation kQuickTurn(1, 5);
49
Daniel Petti61896522015-02-15 18:01:43 -080050// TODO(danielp): Real buttons for all of these.
Austin Schuh8a436e82015-02-16 23:31:28 -080051const ButtonLocation kElevatorUp(3, 10);
Austin Schuh700b9222015-03-01 03:03:15 -080052const ButtonLocation kElevatorCanUp(1, 1);
Austin Schuhcde7ffe2015-02-20 22:10:41 -080053const ButtonLocation kElevatorDown(3, 3);
Austin Schuh8a436e82015-02-16 23:31:28 -080054const ButtonLocation kArmUp(3, 8);
Austin Schuh29dabb62015-03-01 00:13:40 -080055const ButtonLocation kArmHighUp(1, 4);
Austin Schuh994d42c2015-03-01 00:02:17 -080056const ButtonLocation kCanPickup(3, 8);
Austin Schuhcde7ffe2015-02-20 22:10:41 -080057const ButtonLocation kArmDown(2, 6);
Austin Schuh8a436e82015-02-16 23:31:28 -080058const ButtonLocation kClawUp(3, 7);
59const ButtonLocation kClawDown(3, 6);
Austin Schuhcde7ffe2015-02-20 22:10:41 -080060const ButtonLocation kClawOpen(3, 11);
61const ButtonLocation kClawClosed(3, 5);
Austin Schuh700b9222015-03-01 03:03:15 -080062const ButtonLocation kFridgeClosed(3, 1);
63const ButtonLocation kFridgeOpen(2, 11);
Austin Schuhcde7ffe2015-02-20 22:10:41 -080064const ButtonLocation kRollersIn(3, 4);
Austin Schuh700b9222015-03-01 03:03:15 -080065const ButtonLocation kRollersOut(1, 9);
Austin Schuhcde7ffe2015-02-20 22:10:41 -080066const ButtonLocation kClawMiddle(3, 2);
Austin Schuhd8b2a242015-02-22 21:46:53 -080067const ButtonLocation kPickup(2, 10);
68const ButtonLocation kZero(2, 7);
69
70const ButtonLocation kStack(3, 9);
Daniel Petti61896522015-02-15 18:01:43 -080071
Ben Fredrickson9fb2ab12015-02-16 16:42:08 -080072// TODO(ben): Real buttons for all of these.
73const ButtonLocation kArmPresetOne(99, 99);
74const ButtonLocation kArmPresetTwo(99, 99);
75const ButtonLocation kElevatorPresetOne(99, 99);
76const ButtonLocation kElevatorPresetTwo(99, 99);
77
Daniel Petti61896522015-02-15 18:01:43 -080078// Testing mode.
Austin Schuh8a436e82015-02-16 23:31:28 -080079const double kElevatorVelocity = 0.5;
80const double kArmVelocity = 0.5;
81const double kClawVelocity = 2.0;
Daniel Petti61896522015-02-15 18:01:43 -080082// TODO(danielp): Verify.
83const double kJoystickDt = 0.01;
Brian Silverman20141f92015-01-05 17:39:01 -080084
85class Reader : public ::aos::input::JoystickInput {
86 public:
Austin Schuh331e13d2015-02-15 00:16:51 -080087 Reader() : was_running_(false) {}
Brian Silverman20141f92015-01-05 17:39:01 -080088
89 virtual void RunIteration(const ::aos::input::driver_station::Data &data) {
Austin Schuh6182f8d2015-02-14 22:15:04 -080090 bool last_auto_running = auto_running_;
91 auto_running_ = data.GetControlBit(ControlBit::kAutonomous) &&
Brian Silvermane1103e62015-02-15 02:03:38 -050092 data.GetControlBit(ControlBit::kEnabled);
Austin Schuh6182f8d2015-02-14 22:15:04 -080093 if (auto_running_ != last_auto_running) {
94 if (auto_running_) {
95 StartAuto();
96 } else {
97 StopAuto();
Brian Silverman20141f92015-01-05 17:39:01 -080098 }
Austin Schuh6182f8d2015-02-14 22:15:04 -080099 }
100
101 if (!data.GetControlBit(ControlBit::kAutonomous)) {
Daniel Petti61896522015-02-15 18:01:43 -0800102 HandleDrivetrain(data);
103 if (data.GetControlBit(ControlBit::kTestMode)) {
104 HandleTest(data);
105 } else {
106 HandleTeleop(data);
107 }
Brian Silverman20141f92015-01-05 17:39:01 -0800108 }
109 }
110
111 void HandleDrivetrain(const ::aos::input::driver_station::Data &data) {
Brian Silverman20141f92015-01-05 17:39:01 -0800112 const double wheel = -data.GetAxis(kSteeringWheel);
113 const double throttle = -data.GetAxis(kDriveThrottle);
Brian Silverman20141f92015-01-05 17:39:01 -0800114
Brian Silvermanada5f2c2015-02-01 02:41:14 -0500115 if (!drivetrain_queue.goal.MakeWithBuilder()
Brian Silverman20141f92015-01-05 17:39:01 -0800116 .steering(wheel)
117 .throttle(throttle)
Brian Silverman20141f92015-01-05 17:39:01 -0800118 .quickturn(data.IsPressed(kQuickTurn))
Austin Schuh331e13d2015-02-15 00:16:51 -0800119 .control_loop_driving(false)
Brian Silverman20141f92015-01-05 17:39:01 -0800120 .Send()) {
121 LOG(WARNING, "sending stick values failed\n");
122 }
Brian Silverman20141f92015-01-05 17:39:01 -0800123 }
124
125 void HandleTeleop(const ::aos::input::driver_station::Data &data) {
Brian Silverman20141f92015-01-05 17:39:01 -0800126 if (!data.GetControlBit(ControlBit::kEnabled)) {
127 action_queue_.CancelAllActions();
Austin Schuh6182f8d2015-02-14 22:15:04 -0800128 LOG(DEBUG, "Canceling\n");
Brian Silverman20141f92015-01-05 17:39:01 -0800129 }
130
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800131 if (data.PosEdge(kElevatorUp)) {
Austin Schuhd8b2a242015-02-22 21:46:53 -0800132 actors::LiftParams params;
133 params.lift_height = 0.45;
134 params.lift_arm = 0.2;
135 action_queue_.EnqueueAction(actors::MakeLiftAction(params));
136
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800137 claw_goal_ = 0.0;
Austin Schuhd8b2a242015-02-22 21:46:53 -0800138 if (!claw_queue.goal.MakeWithBuilder()
139 .angle(claw_goal_)
140 .rollers_closed(claw_rollers_closed_)
141 .intake(0.0)
142 .Send()) {
143 LOG(ERROR, "Sending claw goal failed.\n");
144 }
145 }
146 if (data.PosEdge(kStack)) {
147 actors::StackParams params;
148 params.claw_out_angle = 0.6;
149 action_queue_.EnqueueAction(actors::MakeStackAction(params));
150 }
Austin Schuh994d42c2015-03-01 00:02:17 -0800151
152 if (data.PosEdge(kCanPickup)) {
153 actors::CanPickupParams params;
154 params.pickup_angle = -0.93;
155 params.pickup_height = 0.265;
156 params.lift_height = 0.65;
157 params.end_height = 0.4;
158 params.end_angle = 0.0;
159 action_queue_.EnqueueAction(actors::MakeCanPickupAction(params));
160 }
161
Austin Schuhd8b2a242015-02-22 21:46:53 -0800162 if (data.PosEdge(kPickup)) {
163 actors::PickupParams params;
Austin Schuhe4e59ef2015-03-01 00:05:37 -0800164 // Lift to here initially.
165 params.pickup_angle = 0.9;
166 // Start sucking here
167 params.suck_angle = 0.8;
168 // Go back down to here to finish sucking.
Austin Schuhd8b2a242015-02-22 21:46:53 -0800169 params.suck_angle_finish = 0.4;
Austin Schuhe4e59ef2015-03-01 00:05:37 -0800170 // Pack the box back in here.
171 params.pickup_finish_angle = 0.95;
172 params.intake_time = 0.8;
173 params.intake_voltage = 9.0;
Austin Schuhd8b2a242015-02-22 21:46:53 -0800174 action_queue_.EnqueueAction(actors::MakePickupAction(params));
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800175 }
Austin Schuh700b9222015-03-01 03:03:15 -0800176
177 if (data.PosEdge(kElevatorCanUp)) {
178 actors::HorizontalCanPickupParams params;
179 params.elevator_height = 0.3;
180 params.pickup_angle = 0.54;
181 params.suck_time = 0.05;
182 params.suck_power = 8.0;
183
184 params.claw_settle_time = 0.05;
185 params.claw_settle_power = 5.0;
186 params.claw_full_lift_angle = 1.35;
187 params.claw_end_angle = 0.5;
188 action_queue_.EnqueueAction(
189 actors::MakeHorizontalCanPickupAction(params));
190 }
191
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800192 if (data.PosEdge(kElevatorDown)) {
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800193 claw_goal_ = 0.0;
Austin Schuhd8b2a242015-02-22 21:46:53 -0800194
195 actors::FridgeProfileParams fridge_params;
196 fridge_params.arm_max_velocity = kArmDebugVelocity;
197 fridge_params.arm_max_acceleration = kArmDebugAcceleration;
198 fridge_params.elevator_max_velocity = kElevatorDebugVelocity;
199 fridge_params.elevator_max_acceleration = kElevatorDebugAcceleration;
200
201 fridge_params.arm_angle = 0.0;
202 fridge_params.elevator_height = 0.035;
203
204 fridge_params.top_front_grabber = fridge_closed_;
205 fridge_params.top_back_grabber = fridge_closed_;
206 fridge_params.bottom_front_grabber = fridge_closed_;
207 fridge_params.bottom_back_grabber = fridge_closed_;
208 action_queue_.EnqueueAction(MakeFridgeProfileAction(fridge_params));
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800209 }
210
211 if (data.PosEdge(kClawMiddle)) {
Austin Schuhd8b2a242015-02-22 21:46:53 -0800212 claw_goal_ = 0.8;
213 }
214
Austin Schuh29dabb62015-03-01 00:13:40 -0800215 if (data.PosEdge(kArmHighUp)) {
Austin Schuh700b9222015-03-01 03:03:15 -0800216 claw_goal_ = 1.3;
Austin Schuh29dabb62015-03-01 00:13:40 -0800217 }
218
Austin Schuhd8b2a242015-02-22 21:46:53 -0800219 if (data.PosEdge(kZero)) {
220 elevator_goal_ = 0.0;
221 arm_goal_ = 0.0;
222 claw_goal_ = 0.0;
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800223 }
Austin Schuh29dabb62015-03-01 00:13:40 -0800224 if (data.PosEdge(kClawUp)) {
225 claw_goal_ = 0.6;
226 }
227 if (data.PosEdge(kClawDown)) {
228 claw_goal_ = 0.0;
229 }
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800230
231 if (data.PosEdge(kClawClosed)) {
232 claw_rollers_closed_ = true;
233 }
234 if (data.PosEdge(kClawOpen)) {
235 claw_rollers_closed_ = false;
236 }
237
238 if (data.PosEdge(kFridgeClosed)) {
239 fridge_closed_ = true;
240 }
241 if (data.PosEdge(kFridgeOpen)) {
242 fridge_closed_ = false;
243 }
244
245 if (data.PosEdge(ControlBit::kEnabled)) {
246 // If we got enabled, wait for everything to zero.
247 LOG(INFO, "Waiting for zero.\n");
248 waiting_for_zero_ = true;
249 }
250
Austin Schuh700b9222015-03-01 03:03:15 -0800251 claw_queue.status.FetchLatest();
252 fridge_queue.status.FetchLatest();
253 if (!claw_queue.status.get()) {
254 LOG(ERROR, "Got no claw status packet.\n");
255 // Not safe to continue.
256 return;
257 }
258 if (!fridge_queue.status.get()) {
259 LOG(ERROR, "Got no fridge status packet.\n");
260 return;
261 }
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800262
Austin Schuh700b9222015-03-01 03:03:15 -0800263 if (claw_queue.status->zeroed && fridge_queue.status->zeroed) {
264 if (waiting_for_zero_) {
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800265 LOG(INFO, "Zeroed! Starting teleop mode.\n");
266 waiting_for_zero_ = false;
267
268 // Set the initial goals to where we are now.
269 elevator_goal_ = fridge_queue.status->goal_height;
270 arm_goal_ = fridge_queue.status->goal_angle;
271 claw_goal_ = claw_queue.status->angle;
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800272 }
273 } else {
Austin Schuh700b9222015-03-01 03:03:15 -0800274 waiting_for_zero_ = true;
275 return;
276 }
277
278 if (!waiting_for_zero_) {
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800279 if (!action_queue_.Running()) {
280 auto new_fridge_goal = fridge_queue.goal.MakeMessage();
281 new_fridge_goal->height = elevator_goal_;
282 new_fridge_goal->angle = arm_goal_;
283 new_fridge_goal->angular_velocity = 0.0;
284 new_fridge_goal->velocity = 0.0;
285 new_fridge_goal->grabbers.top_front = fridge_closed_;
286 new_fridge_goal->grabbers.top_back = fridge_closed_;
287 new_fridge_goal->grabbers.bottom_front = fridge_closed_;
288 new_fridge_goal->grabbers.bottom_back = fridge_closed_;
289
290 if (!new_fridge_goal.Send()) {
291 LOG(ERROR, "Sending fridge goal failed.\n");
292 } else {
293 LOG(DEBUG, "sending goals: elevator: %f, arm: %f\n", elevator_goal_,
294 arm_goal_);
295 }
296 if (!claw_queue.goal.MakeWithBuilder()
297 .angle(claw_goal_)
298 .rollers_closed(claw_rollers_closed_)
Austin Schuh700b9222015-03-01 03:03:15 -0800299 .intake(data.IsPressed(kRollersIn)
300 ? 12.0
301 : (data.IsPressed(kRollersOut) ? -12.0 : 0.0))
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800302 .Send()) {
303 LOG(ERROR, "Sending claw goal failed.\n");
304 }
305 }
306 }
307
Austin Schuhd8b2a242015-02-22 21:46:53 -0800308 if (action_queue_.Running()) {
309 // If we are running an action, update our goals to the current goals.
310 control_loops::fridge_queue.status.FetchLatest();
311 if (control_loops::fridge_queue.status.get()) {
312 arm_goal_ = control_loops::fridge_queue.status->goal_angle;
313 elevator_goal_ = control_loops::fridge_queue.status->goal_height;
314 } else {
315 LOG(ERROR, "No fridge status!\n");
316 }
317
318 // If we are running an action, update our goals to the current goals.
319 control_loops::claw_queue.status.FetchLatest();
320 if (control_loops::claw_queue.status.get()) {
321 claw_goal_ = control_loops::claw_queue.status->goal_angle;
322 } else {
323 LOG(ERROR, "No fridge status!\n");
324 }
325 }
Brian Silverman20141f92015-01-05 17:39:01 -0800326 action_queue_.Tick();
327 was_running_ = action_queue_.Running();
328 }
329
Daniel Petti61896522015-02-15 18:01:43 -0800330 void HandleTest(const ::aos::input::driver_station::Data &data) {
331 if (action_queue_.Running()) {
332 // We don't really want any actions running.
333 LOG(DEBUG, "Cancelling actions for test mode.\n");
334 action_queue_.CancelAllActions();
335 }
336
337 if (data.GetControlBit(ControlBit::kEnabled)) {
338 if (data.PosEdge(ControlBit::kEnabled)) {
339 // If we got enabled, wait for everything to zero.
340 LOG(INFO, "Waiting for zero.\n");
341 waiting_for_zero_ = true;
342 }
343 if (waiting_for_zero_) {
344 claw_queue.status.FetchLatest();
345 fridge_queue.status.FetchLatest();
346 if (!claw_queue.status.get()) {
347 LOG(ERROR, "Got no claw status packet.\n");
348 // Not safe to continue.
349 return;
350 }
351 if (!fridge_queue.status.get()) {
352 LOG(ERROR, "Got no fridge status packet.\n");
353 return;
354 }
355
356 if (claw_queue.status->zeroed && fridge_queue.status->zeroed) {
357 LOG(INFO, "Zeroed! Starting test mode.\n");
358 waiting_for_zero_ = false;
359
360 // Set the initial goals to where we are now.
361 elevator_goal_ = fridge_queue.status->height;
362 arm_goal_ = fridge_queue.status->angle;
363 claw_goal_ = claw_queue.status->angle;
364 } else {
365 return;
366 }
367 }
368
369 // These buttons move a subsystem up or down for as long as they are
370 // pressed, at low velocity.
371 if (data.IsPressed(kElevatorUp)) {
372 elevator_goal_ += kElevatorVelocity * kJoystickDt;
373 }
374 if (data.IsPressed(kElevatorDown)) {
375 elevator_goal_ -= kElevatorVelocity * kJoystickDt;
376 }
377 if (data.IsPressed(kArmUp)) {
378 arm_goal_ += kArmVelocity * kJoystickDt;
379 }
380 if (data.IsPressed(kArmDown)) {
381 arm_goal_ -= kArmVelocity * kJoystickDt;
382 }
383 if (data.IsPressed(kClawUp)) {
384 claw_goal_ += kClawVelocity * kJoystickDt;
385 }
386 if (data.IsPressed(kClawDown)) {
387 claw_goal_ -= kClawVelocity * kJoystickDt;
388 }
389
Ben Fredrickson9fb2ab12015-02-16 16:42:08 -0800390 if (!action_queue_.Running()) {
391 if (!fridge_queue.goal.MakeWithBuilder()
392 .height(elevator_goal_)
393 .angle(arm_goal_)
394 .Send()) {
395 LOG(ERROR, "Sending fridge goal failed.\n");
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800396 } else {
397 LOG(DEBUG, "sending goals: elevator: %f, arm: %f\n", elevator_goal_,
398 arm_goal_);
Ben Fredrickson9fb2ab12015-02-16 16:42:08 -0800399 }
400 if (!claw_queue.goal.MakeWithBuilder().angle(claw_goal_).Send()) {
401 LOG(ERROR, "Sending claw goal failed.\n");
402 }
Daniel Petti61896522015-02-15 18:01:43 -0800403 }
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800404 /*
Ben Fredrickson9fb2ab12015-02-16 16:42:08 -0800405 if (data.IsPressed(kArmPresetOne) || data.IsPressed(kArmPresetTwo)) {
406 actors::FridgeProfileParams fridge_params;
407 fridge_params.arm_max_velocity = kArmDebugVelocity;
408 fridge_params.arm_max_acceleration = kArmDebugAcceleration;
409 if (data.IsPressed(kArmPresetOne)) {
410 LOG(INFO, "Preset asked for test arm position one position.\n");
411 fridge_params.arm_angle = M_PI / 4.0;
412 fridge_params.top_front_grabber = false;
413 fridge_params.top_back_grabber = false;
414 fridge_params.bottom_front_grabber = false;
415 fridge_params.bottom_back_grabber = false;
416 action_queue_.EnqueueAction(MakeFridgeProfileAction(fridge_params));
417 } else if (data.IsPressed(kArmPresetTwo)) {
418 LOG(INFO, "Preset asked for test arm position two position.\n");
419 fridge_params.arm_angle = -M_PI / 4.0;
420 fridge_params.top_front_grabber = true;
421 fridge_params.top_back_grabber = true;
422 fridge_params.bottom_front_grabber = true;
423 fridge_params.bottom_back_grabber = true;
424 action_queue_.EnqueueAction(MakeFridgeProfileAction(fridge_params));
425 }
426 } else if (data.IsPressed(kElevatorPresetOne) ||
427 data.IsPressed(kElevatorPresetOne)) {
428 actors::FridgeProfileParams fridge_params;
429 fridge_params.elevator_max_velocity = kElevatorDebugVelocity;
430 fridge_params.elevator_max_acceleration = kElevatorDebugAcceleration;
431 if (data.IsPressed(kElevatorPresetOne)) {
432 LOG(INFO, "Preset asked for test elevator position one position.\n");
433 fridge_params.elevator_height = 0.5;
434 fridge_params.top_front_grabber = false;
435 fridge_params.top_back_grabber = false;
436 fridge_params.bottom_front_grabber = false;
437 fridge_params.bottom_back_grabber = false;
438 action_queue_.EnqueueAction(MakeFridgeProfileAction(fridge_params));
439 } else if (data.IsPressed(kElevatorPresetTwo)) {
440 LOG(INFO, "Preset asked for test elevator position two position.\n");
441 fridge_params.elevator_height = 1.2;
442 fridge_params.top_front_grabber = true;
443 fridge_params.top_back_grabber = true;
444 fridge_params.bottom_front_grabber = true;
445 fridge_params.bottom_back_grabber = true;
446 action_queue_.EnqueueAction(MakeFridgeProfileAction(fridge_params));
447 }
Daniel Petti61896522015-02-15 18:01:43 -0800448 }
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800449 */
Daniel Petti61896522015-02-15 18:01:43 -0800450 }
451 }
452
Brian Silverman20141f92015-01-05 17:39:01 -0800453 private:
Austin Schuh6182f8d2015-02-14 22:15:04 -0800454 void StartAuto() {
455 LOG(INFO, "Starting auto mode\n");
456 ::frc971::autonomous::autonomous.MakeWithBuilder().run_auto(true).Send();
457 }
458
459 void StopAuto() {
460 LOG(INFO, "Stopping auto mode\n");
461 ::frc971::autonomous::autonomous.MakeWithBuilder().run_auto(false).Send();
462 }
463
Brian Silverman20141f92015-01-05 17:39:01 -0800464 bool was_running_;
Daniel Petti61896522015-02-15 18:01:43 -0800465
466 // Previous goals for systems.
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800467 double elevator_goal_ = 0.2;
Daniel Petti61896522015-02-15 18:01:43 -0800468 double arm_goal_ = 0.0;
469 double claw_goal_ = 0.0;
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800470 bool claw_rollers_closed_ = false;
471 bool fridge_closed_ = false;
Daniel Petti61896522015-02-15 18:01:43 -0800472
473 // If we're waiting for the subsystems to zero.
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800474 bool waiting_for_zero_ = true;
Daniel Petti61896522015-02-15 18:01:43 -0800475
Austin Schuh6182f8d2015-02-14 22:15:04 -0800476 bool auto_running_ = false;
477
Austin Schuh331e13d2015-02-15 00:16:51 -0800478 ::aos::common::actions::ActionQueue action_queue_;
Brian Silverman20141f92015-01-05 17:39:01 -0800479
480 ::aos::util::SimpleLogInterval no_drivetrain_status_ =
481 ::aos::util::SimpleLogInterval(::aos::time::Time::InSeconds(0.2), WARNING,
482 "no drivetrain status");
483};
484
485} // namespace joysticks
486} // namespace input
487} // namespace frc971
488
489int main() {
490 ::aos::Init();
491 ::frc971::input::joysticks::Reader reader;
492 reader.Run();
493 ::aos::Cleanup();
494}