blob: c529054f2b8edbb3dfb75e2d5855632ff9c79a2a [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"
Austin Schuhd8b2a242015-02-22 21:46:53 -080020#include "frc971/actors/pickup_actor.h"
21#include "frc971/actors/stack_actor.h"
22#include "frc971/actors/lift_actor.h"
Austin Schuh994d42c2015-03-01 00:02:17 -080023#include "frc971/actors/can_pickup_actor.h"
Austin Schuh700b9222015-03-01 03:03:15 -080024#include "frc971/actors/horizontal_can_pickup_actor.h"
Brian Silverman20141f92015-01-05 17:39:01 -080025
Daniel Petti61896522015-02-15 18:01:43 -080026using ::frc971::control_loops::claw_queue;
Brian Silvermanada5f2c2015-02-01 02:41:14 -050027using ::frc971::control_loops::drivetrain_queue;
Daniel Petti61896522015-02-15 18:01:43 -080028using ::frc971::control_loops::fridge_queue;
Brian Silverman20141f92015-01-05 17:39:01 -080029using ::frc971::sensors::gyro_reading;
30
31using ::aos::input::driver_station::ButtonLocation;
32using ::aos::input::driver_station::JoystickAxis;
33using ::aos::input::driver_station::ControlBit;
34
35namespace frc971 {
36namespace input {
37namespace joysticks {
38
Ben Fredrickson9fb2ab12015-02-16 16:42:08 -080039// preset motion limits
Austin Schuh6e242ac2015-03-07 17:08:21 -080040constexpr actors::ProfileParams kArmMove{1.00, 1.0};
41constexpr actors::ProfileParams kElevatorMove{1.00, 3.2};
Ben Fredrickson9fb2ab12015-02-16 16:42:08 -080042
Brian Silverman20141f92015-01-05 17:39:01 -080043const JoystickAxis kSteeringWheel(1, 1), kDriveThrottle(2, 2);
44const ButtonLocation kShiftHigh(2, 1), kShiftLow(2, 3);
45const ButtonLocation kQuickTurn(1, 5);
46
Daniel Petti61896522015-02-15 18:01:43 -080047// TODO(danielp): Real buttons for all of these.
Austin Schuh8a436e82015-02-16 23:31:28 -080048const ButtonLocation kElevatorUp(3, 10);
Austin Schuh700b9222015-03-01 03:03:15 -080049const ButtonLocation kElevatorCanUp(1, 1);
Austin Schuhcde7ffe2015-02-20 22:10:41 -080050const ButtonLocation kElevatorDown(3, 3);
Austin Schuh8a436e82015-02-16 23:31:28 -080051const ButtonLocation kArmUp(3, 8);
Austin Schuh29dabb62015-03-01 00:13:40 -080052const ButtonLocation kArmHighUp(1, 4);
Austin Schuh994d42c2015-03-01 00:02:17 -080053const ButtonLocation kCanPickup(3, 8);
Austin Schuhcde7ffe2015-02-20 22:10:41 -080054const ButtonLocation kArmDown(2, 6);
Austin Schuh8a436e82015-02-16 23:31:28 -080055const ButtonLocation kClawUp(3, 7);
56const ButtonLocation kClawDown(3, 6);
Austin Schuhcde7ffe2015-02-20 22:10:41 -080057const ButtonLocation kClawOpen(3, 11);
58const ButtonLocation kClawClosed(3, 5);
Austin Schuh700b9222015-03-01 03:03:15 -080059const ButtonLocation kFridgeClosed(3, 1);
60const ButtonLocation kFridgeOpen(2, 11);
Austin Schuhcde7ffe2015-02-20 22:10:41 -080061const ButtonLocation kRollersIn(3, 4);
Austin Schuh700b9222015-03-01 03:03:15 -080062const ButtonLocation kRollersOut(1, 9);
Austin Schuhcde7ffe2015-02-20 22:10:41 -080063const ButtonLocation kClawMiddle(3, 2);
Austin Schuhd8b2a242015-02-22 21:46:53 -080064const ButtonLocation kPickup(2, 10);
65const ButtonLocation kZero(2, 7);
66
67const ButtonLocation kStack(3, 9);
Daniel Petti61896522015-02-15 18:01:43 -080068
Ben Fredrickson9fb2ab12015-02-16 16:42:08 -080069// TODO(ben): Real buttons for all of these.
70const ButtonLocation kArmPresetOne(99, 99);
71const ButtonLocation kArmPresetTwo(99, 99);
72const ButtonLocation kElevatorPresetOne(99, 99);
73const ButtonLocation kElevatorPresetTwo(99, 99);
74
Daniel Petti61896522015-02-15 18:01:43 -080075// Testing mode.
Austin Schuh8a436e82015-02-16 23:31:28 -080076const double kElevatorVelocity = 0.5;
77const double kArmVelocity = 0.5;
78const double kClawVelocity = 2.0;
Daniel Petti61896522015-02-15 18:01:43 -080079// TODO(danielp): Verify.
80const double kJoystickDt = 0.01;
Brian Silverman20141f92015-01-05 17:39:01 -080081
82class Reader : public ::aos::input::JoystickInput {
83 public:
Austin Schuh331e13d2015-02-15 00:16:51 -080084 Reader() : was_running_(false) {}
Brian Silverman20141f92015-01-05 17:39:01 -080085
86 virtual void RunIteration(const ::aos::input::driver_station::Data &data) {
Austin Schuh6182f8d2015-02-14 22:15:04 -080087 bool last_auto_running = auto_running_;
88 auto_running_ = data.GetControlBit(ControlBit::kAutonomous) &&
Brian Silvermane1103e62015-02-15 02:03:38 -050089 data.GetControlBit(ControlBit::kEnabled);
Austin Schuh6182f8d2015-02-14 22:15:04 -080090 if (auto_running_ != last_auto_running) {
91 if (auto_running_) {
92 StartAuto();
93 } else {
94 StopAuto();
Brian Silverman20141f92015-01-05 17:39:01 -080095 }
Austin Schuh6182f8d2015-02-14 22:15:04 -080096 }
97
98 if (!data.GetControlBit(ControlBit::kAutonomous)) {
Daniel Petti61896522015-02-15 18:01:43 -080099 HandleDrivetrain(data);
100 if (data.GetControlBit(ControlBit::kTestMode)) {
101 HandleTest(data);
102 } else {
103 HandleTeleop(data);
104 }
Brian Silverman20141f92015-01-05 17:39:01 -0800105 }
106 }
107
108 void HandleDrivetrain(const ::aos::input::driver_station::Data &data) {
Brian Silverman20141f92015-01-05 17:39:01 -0800109 const double wheel = -data.GetAxis(kSteeringWheel);
110 const double throttle = -data.GetAxis(kDriveThrottle);
Brian Silverman20141f92015-01-05 17:39:01 -0800111
Brian Silvermanada5f2c2015-02-01 02:41:14 -0500112 if (!drivetrain_queue.goal.MakeWithBuilder()
Brian Silverman20141f92015-01-05 17:39:01 -0800113 .steering(wheel)
114 .throttle(throttle)
Brian Silverman20141f92015-01-05 17:39:01 -0800115 .quickturn(data.IsPressed(kQuickTurn))
Austin Schuh331e13d2015-02-15 00:16:51 -0800116 .control_loop_driving(false)
Brian Silverman20141f92015-01-05 17:39:01 -0800117 .Send()) {
118 LOG(WARNING, "sending stick values failed\n");
119 }
Brian Silverman20141f92015-01-05 17:39:01 -0800120 }
121
122 void HandleTeleop(const ::aos::input::driver_station::Data &data) {
Brian Silverman20141f92015-01-05 17:39:01 -0800123 if (!data.GetControlBit(ControlBit::kEnabled)) {
124 action_queue_.CancelAllActions();
Austin Schuh6182f8d2015-02-14 22:15:04 -0800125 LOG(DEBUG, "Canceling\n");
Brian Silverman20141f92015-01-05 17:39:01 -0800126 }
127
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800128 if (data.PosEdge(kElevatorUp)) {
Austin Schuhd8b2a242015-02-22 21:46:53 -0800129 actors::LiftParams params;
130 params.lift_height = 0.45;
131 params.lift_arm = 0.2;
132 action_queue_.EnqueueAction(actors::MakeLiftAction(params));
133
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800134 claw_goal_ = 0.0;
Austin Schuhd8b2a242015-02-22 21:46:53 -0800135 if (!claw_queue.goal.MakeWithBuilder()
136 .angle(claw_goal_)
137 .rollers_closed(claw_rollers_closed_)
138 .intake(0.0)
139 .Send()) {
140 LOG(ERROR, "Sending claw goal failed.\n");
141 }
142 }
143 if (data.PosEdge(kStack)) {
144 actors::StackParams params;
145 params.claw_out_angle = 0.6;
146 action_queue_.EnqueueAction(actors::MakeStackAction(params));
147 }
Austin Schuh994d42c2015-03-01 00:02:17 -0800148
149 if (data.PosEdge(kCanPickup)) {
150 actors::CanPickupParams params;
151 params.pickup_angle = -0.93;
152 params.pickup_height = 0.265;
153 params.lift_height = 0.65;
154 params.end_height = 0.4;
155 params.end_angle = 0.0;
156 action_queue_.EnqueueAction(actors::MakeCanPickupAction(params));
157 }
158
Austin Schuhd8b2a242015-02-22 21:46:53 -0800159 if (data.PosEdge(kPickup)) {
160 actors::PickupParams params;
Austin Schuhe4e59ef2015-03-01 00:05:37 -0800161 // Lift to here initially.
162 params.pickup_angle = 0.9;
163 // Start sucking here
164 params.suck_angle = 0.8;
165 // Go back down to here to finish sucking.
Austin Schuhd8b2a242015-02-22 21:46:53 -0800166 params.suck_angle_finish = 0.4;
Austin Schuhe4e59ef2015-03-01 00:05:37 -0800167 // Pack the box back in here.
168 params.pickup_finish_angle = 0.95;
169 params.intake_time = 0.8;
170 params.intake_voltage = 9.0;
Austin Schuhd8b2a242015-02-22 21:46:53 -0800171 action_queue_.EnqueueAction(actors::MakePickupAction(params));
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800172 }
Austin Schuh700b9222015-03-01 03:03:15 -0800173
174 if (data.PosEdge(kElevatorCanUp)) {
175 actors::HorizontalCanPickupParams params;
176 params.elevator_height = 0.3;
177 params.pickup_angle = 0.54;
178 params.suck_time = 0.05;
179 params.suck_power = 8.0;
180
181 params.claw_settle_time = 0.05;
182 params.claw_settle_power = 5.0;
183 params.claw_full_lift_angle = 1.35;
184 params.claw_end_angle = 0.5;
185 action_queue_.EnqueueAction(
186 actors::MakeHorizontalCanPickupAction(params));
187 }
188
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800189 if (data.PosEdge(kElevatorDown)) {
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800190 claw_goal_ = 0.0;
Austin Schuh6e242ac2015-03-07 17:08:21 -0800191 arm_goal_ = 0.0;
192 elevator_goal_ = 0.035;
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800193 }
194
195 if (data.PosEdge(kClawMiddle)) {
Austin Schuhd8b2a242015-02-22 21:46:53 -0800196 claw_goal_ = 0.8;
197 }
198
Austin Schuh29dabb62015-03-01 00:13:40 -0800199 if (data.PosEdge(kArmHighUp)) {
Austin Schuh700b9222015-03-01 03:03:15 -0800200 claw_goal_ = 1.3;
Austin Schuh29dabb62015-03-01 00:13:40 -0800201 }
202
Austin Schuhd8b2a242015-02-22 21:46:53 -0800203 if (data.PosEdge(kZero)) {
204 elevator_goal_ = 0.0;
205 arm_goal_ = 0.0;
206 claw_goal_ = 0.0;
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800207 }
Austin Schuh29dabb62015-03-01 00:13:40 -0800208 if (data.PosEdge(kClawUp)) {
209 claw_goal_ = 0.6;
210 }
211 if (data.PosEdge(kClawDown)) {
212 claw_goal_ = 0.0;
213 }
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800214
215 if (data.PosEdge(kClawClosed)) {
216 claw_rollers_closed_ = true;
217 }
218 if (data.PosEdge(kClawOpen)) {
219 claw_rollers_closed_ = false;
220 }
221
222 if (data.PosEdge(kFridgeClosed)) {
223 fridge_closed_ = true;
224 }
225 if (data.PosEdge(kFridgeOpen)) {
226 fridge_closed_ = false;
227 }
228
229 if (data.PosEdge(ControlBit::kEnabled)) {
230 // If we got enabled, wait for everything to zero.
231 LOG(INFO, "Waiting for zero.\n");
232 waiting_for_zero_ = true;
233 }
234
Austin Schuh700b9222015-03-01 03:03:15 -0800235 claw_queue.status.FetchLatest();
236 fridge_queue.status.FetchLatest();
237 if (!claw_queue.status.get()) {
238 LOG(ERROR, "Got no claw status packet.\n");
239 // Not safe to continue.
240 return;
241 }
242 if (!fridge_queue.status.get()) {
243 LOG(ERROR, "Got no fridge status packet.\n");
244 return;
245 }
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800246
Austin Schuh700b9222015-03-01 03:03:15 -0800247 if (claw_queue.status->zeroed && fridge_queue.status->zeroed) {
248 if (waiting_for_zero_) {
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800249 LOG(INFO, "Zeroed! Starting teleop mode.\n");
250 waiting_for_zero_ = false;
251
252 // Set the initial goals to where we are now.
253 elevator_goal_ = fridge_queue.status->goal_height;
254 arm_goal_ = fridge_queue.status->goal_angle;
255 claw_goal_ = claw_queue.status->angle;
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800256 }
257 } else {
Austin Schuh700b9222015-03-01 03:03:15 -0800258 waiting_for_zero_ = true;
259 return;
260 }
261
262 if (!waiting_for_zero_) {
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800263 if (!action_queue_.Running()) {
264 auto new_fridge_goal = fridge_queue.goal.MakeMessage();
Austin Schuh6e242ac2015-03-07 17:08:21 -0800265 new_fridge_goal->max_velocity = elevator_params_.velocity;
266 new_fridge_goal->max_acceleration = elevator_params_.acceleration;
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800267 new_fridge_goal->height = elevator_goal_;
Austin Schuh6e242ac2015-03-07 17:08:21 -0800268 new_fridge_goal->velocity = 0.0;
269 new_fridge_goal->max_angular_velocity = arm_params_.velocity;
270 new_fridge_goal->max_angular_acceleration = arm_params_.acceleration;
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800271 new_fridge_goal->angle = arm_goal_;
272 new_fridge_goal->angular_velocity = 0.0;
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800273 new_fridge_goal->grabbers.top_front = fridge_closed_;
274 new_fridge_goal->grabbers.top_back = fridge_closed_;
275 new_fridge_goal->grabbers.bottom_front = fridge_closed_;
276 new_fridge_goal->grabbers.bottom_back = fridge_closed_;
277
278 if (!new_fridge_goal.Send()) {
279 LOG(ERROR, "Sending fridge goal failed.\n");
280 } else {
281 LOG(DEBUG, "sending goals: elevator: %f, arm: %f\n", elevator_goal_,
282 arm_goal_);
283 }
284 if (!claw_queue.goal.MakeWithBuilder()
285 .angle(claw_goal_)
286 .rollers_closed(claw_rollers_closed_)
Austin Schuh700b9222015-03-01 03:03:15 -0800287 .intake(data.IsPressed(kRollersIn)
288 ? 12.0
289 : (data.IsPressed(kRollersOut) ? -12.0 : 0.0))
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800290 .Send()) {
291 LOG(ERROR, "Sending claw goal failed.\n");
292 }
293 }
294 }
295
Austin Schuhd8b2a242015-02-22 21:46:53 -0800296 if (action_queue_.Running()) {
297 // If we are running an action, update our goals to the current goals.
298 control_loops::fridge_queue.status.FetchLatest();
299 if (control_loops::fridge_queue.status.get()) {
300 arm_goal_ = control_loops::fridge_queue.status->goal_angle;
301 elevator_goal_ = control_loops::fridge_queue.status->goal_height;
302 } else {
303 LOG(ERROR, "No fridge status!\n");
304 }
305
306 // If we are running an action, update our goals to the current goals.
307 control_loops::claw_queue.status.FetchLatest();
308 if (control_loops::claw_queue.status.get()) {
309 claw_goal_ = control_loops::claw_queue.status->goal_angle;
310 } else {
311 LOG(ERROR, "No fridge status!\n");
312 }
313 }
Brian Silverman20141f92015-01-05 17:39:01 -0800314 action_queue_.Tick();
315 was_running_ = action_queue_.Running();
316 }
317
Daniel Petti61896522015-02-15 18:01:43 -0800318 void HandleTest(const ::aos::input::driver_station::Data &data) {
319 if (action_queue_.Running()) {
320 // We don't really want any actions running.
321 LOG(DEBUG, "Cancelling actions for test mode.\n");
322 action_queue_.CancelAllActions();
323 }
324
325 if (data.GetControlBit(ControlBit::kEnabled)) {
326 if (data.PosEdge(ControlBit::kEnabled)) {
327 // If we got enabled, wait for everything to zero.
328 LOG(INFO, "Waiting for zero.\n");
329 waiting_for_zero_ = true;
330 }
331 if (waiting_for_zero_) {
332 claw_queue.status.FetchLatest();
333 fridge_queue.status.FetchLatest();
334 if (!claw_queue.status.get()) {
335 LOG(ERROR, "Got no claw status packet.\n");
336 // Not safe to continue.
337 return;
338 }
339 if (!fridge_queue.status.get()) {
340 LOG(ERROR, "Got no fridge status packet.\n");
341 return;
342 }
343
344 if (claw_queue.status->zeroed && fridge_queue.status->zeroed) {
345 LOG(INFO, "Zeroed! Starting test mode.\n");
346 waiting_for_zero_ = false;
347
348 // Set the initial goals to where we are now.
349 elevator_goal_ = fridge_queue.status->height;
350 arm_goal_ = fridge_queue.status->angle;
351 claw_goal_ = claw_queue.status->angle;
352 } else {
353 return;
354 }
355 }
356
357 // These buttons move a subsystem up or down for as long as they are
358 // pressed, at low velocity.
359 if (data.IsPressed(kElevatorUp)) {
360 elevator_goal_ += kElevatorVelocity * kJoystickDt;
361 }
362 if (data.IsPressed(kElevatorDown)) {
363 elevator_goal_ -= kElevatorVelocity * kJoystickDt;
364 }
365 if (data.IsPressed(kArmUp)) {
366 arm_goal_ += kArmVelocity * kJoystickDt;
367 }
368 if (data.IsPressed(kArmDown)) {
369 arm_goal_ -= kArmVelocity * kJoystickDt;
370 }
371 if (data.IsPressed(kClawUp)) {
372 claw_goal_ += kClawVelocity * kJoystickDt;
373 }
374 if (data.IsPressed(kClawDown)) {
375 claw_goal_ -= kClawVelocity * kJoystickDt;
376 }
377
Ben Fredrickson9fb2ab12015-02-16 16:42:08 -0800378 if (!action_queue_.Running()) {
379 if (!fridge_queue.goal.MakeWithBuilder()
380 .height(elevator_goal_)
381 .angle(arm_goal_)
382 .Send()) {
383 LOG(ERROR, "Sending fridge goal failed.\n");
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800384 } else {
385 LOG(DEBUG, "sending goals: elevator: %f, arm: %f\n", elevator_goal_,
386 arm_goal_);
Ben Fredrickson9fb2ab12015-02-16 16:42:08 -0800387 }
388 if (!claw_queue.goal.MakeWithBuilder().angle(claw_goal_).Send()) {
389 LOG(ERROR, "Sending claw goal failed.\n");
390 }
Daniel Petti61896522015-02-15 18:01:43 -0800391 }
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800392 /*
Ben Fredrickson9fb2ab12015-02-16 16:42:08 -0800393 if (data.IsPressed(kArmPresetOne) || data.IsPressed(kArmPresetTwo)) {
394 actors::FridgeProfileParams fridge_params;
395 fridge_params.arm_max_velocity = kArmDebugVelocity;
396 fridge_params.arm_max_acceleration = kArmDebugAcceleration;
397 if (data.IsPressed(kArmPresetOne)) {
398 LOG(INFO, "Preset asked for test arm position one position.\n");
399 fridge_params.arm_angle = M_PI / 4.0;
400 fridge_params.top_front_grabber = false;
401 fridge_params.top_back_grabber = false;
402 fridge_params.bottom_front_grabber = false;
403 fridge_params.bottom_back_grabber = false;
404 action_queue_.EnqueueAction(MakeFridgeProfileAction(fridge_params));
405 } else if (data.IsPressed(kArmPresetTwo)) {
406 LOG(INFO, "Preset asked for test arm position two position.\n");
407 fridge_params.arm_angle = -M_PI / 4.0;
408 fridge_params.top_front_grabber = true;
409 fridge_params.top_back_grabber = true;
410 fridge_params.bottom_front_grabber = true;
411 fridge_params.bottom_back_grabber = true;
412 action_queue_.EnqueueAction(MakeFridgeProfileAction(fridge_params));
413 }
414 } else if (data.IsPressed(kElevatorPresetOne) ||
415 data.IsPressed(kElevatorPresetOne)) {
416 actors::FridgeProfileParams fridge_params;
417 fridge_params.elevator_max_velocity = kElevatorDebugVelocity;
418 fridge_params.elevator_max_acceleration = kElevatorDebugAcceleration;
419 if (data.IsPressed(kElevatorPresetOne)) {
420 LOG(INFO, "Preset asked for test elevator position one position.\n");
421 fridge_params.elevator_height = 0.5;
422 fridge_params.top_front_grabber = false;
423 fridge_params.top_back_grabber = false;
424 fridge_params.bottom_front_grabber = false;
425 fridge_params.bottom_back_grabber = false;
426 action_queue_.EnqueueAction(MakeFridgeProfileAction(fridge_params));
427 } else if (data.IsPressed(kElevatorPresetTwo)) {
428 LOG(INFO, "Preset asked for test elevator position two position.\n");
429 fridge_params.elevator_height = 1.2;
430 fridge_params.top_front_grabber = true;
431 fridge_params.top_back_grabber = true;
432 fridge_params.bottom_front_grabber = true;
433 fridge_params.bottom_back_grabber = true;
434 action_queue_.EnqueueAction(MakeFridgeProfileAction(fridge_params));
435 }
Daniel Petti61896522015-02-15 18:01:43 -0800436 }
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800437 */
Daniel Petti61896522015-02-15 18:01:43 -0800438 }
439 }
440
Brian Silverman20141f92015-01-05 17:39:01 -0800441 private:
Austin Schuh6182f8d2015-02-14 22:15:04 -0800442 void StartAuto() {
443 LOG(INFO, "Starting auto mode\n");
444 ::frc971::autonomous::autonomous.MakeWithBuilder().run_auto(true).Send();
445 }
446
447 void StopAuto() {
448 LOG(INFO, "Stopping auto mode\n");
449 ::frc971::autonomous::autonomous.MakeWithBuilder().run_auto(false).Send();
450 }
451
Brian Silverman20141f92015-01-05 17:39:01 -0800452 bool was_running_;
Daniel Petti61896522015-02-15 18:01:43 -0800453
454 // Previous goals for systems.
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800455 double elevator_goal_ = 0.2;
Daniel Petti61896522015-02-15 18:01:43 -0800456 double arm_goal_ = 0.0;
457 double claw_goal_ = 0.0;
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800458 bool claw_rollers_closed_ = false;
459 bool fridge_closed_ = false;
Austin Schuh6e242ac2015-03-07 17:08:21 -0800460 actors::ProfileParams arm_params_ = kArmMove;
461 actors::ProfileParams elevator_params_ = kElevatorMove;
Daniel Petti61896522015-02-15 18:01:43 -0800462
463 // If we're waiting for the subsystems to zero.
Austin Schuhcde7ffe2015-02-20 22:10:41 -0800464 bool waiting_for_zero_ = true;
Daniel Petti61896522015-02-15 18:01:43 -0800465
Austin Schuh6182f8d2015-02-14 22:15:04 -0800466 bool auto_running_ = false;
467
Austin Schuh331e13d2015-02-15 00:16:51 -0800468 ::aos::common::actions::ActionQueue action_queue_;
Brian Silverman20141f92015-01-05 17:39:01 -0800469
470 ::aos::util::SimpleLogInterval no_drivetrain_status_ =
471 ::aos::util::SimpleLogInterval(::aos::time::Time::InSeconds(0.2), WARNING,
472 "no drivetrain status");
473};
474
475} // namespace joysticks
476} // namespace input
477} // namespace frc971
478
479int main() {
480 ::aos::Init();
481 ::frc971::input::joysticks::Reader reader;
482 reader.Run();
483 ::aos::Cleanup();
484}