blob: a2de230a85c24b0e7230a94171584adb265d338d [file] [log] [blame]
Campbell Crowley71b5f132017-02-18 13:16:08 -08001#include <stdio.h>
2#include <string.h>
3#include <unistd.h>
4#include <math.h>
5
Austin Schuh3028b1d2017-03-11 22:12:13 -08006#include "aos/common/actions/actions.h"
Campbell Crowley71b5f132017-02-18 13:16:08 -08007#include "aos/common/input/driver_station_data.h"
8#include "aos/common/logging/logging.h"
Campbell Crowley71b5f132017-02-18 13:16:08 -08009#include "aos/common/time.h"
Austin Schuh3028b1d2017-03-11 22:12:13 -080010#include "aos/common/util/log_interval.h"
11#include "aos/input/joystick_input.h"
12#include "aos/linux_code/init.h"
Campbell Crowley71b5f132017-02-18 13:16:08 -080013#include "frc971/autonomous/auto.q.h"
Austin Schuh3028b1d2017-03-11 22:12:13 -080014#include "frc971/autonomous/base_autonomous_actor.h"
15#include "frc971/control_loops/drivetrain/drivetrain.q.h"
16#include "y2017/constants.h"
17#include "y2017/control_loops/superstructure/superstructure.q.h"
Campbell Crowley71b5f132017-02-18 13:16:08 -080018
19using ::frc971::control_loops::drivetrain_queue;
20using ::y2017::control_loops::superstructure_queue;
21
22using ::aos::input::driver_station::ButtonLocation;
23using ::aos::input::driver_station::ControlBit;
24using ::aos::input::driver_station::JoystickAxis;
25using ::aos::input::driver_station::POVLocation;
26
27namespace y2017 {
28namespace input {
29namespace joysticks {
30
Austin Schuh51b1bae2017-04-09 18:31:57 -070031// Keep the other versions around so we can switch quickly.
32//#define STEERINGWHEEL
33#define PISTOL
34//#define XBOX
35
36#ifdef STEERINGWHEEL
Campbell Crowley71b5f132017-02-18 13:16:08 -080037const JoystickAxis kSteeringWheel(1, 1), kDriveThrottle(2, 2);
38const ButtonLocation kQuickTurn(1, 5);
Campbell Crowley71b5f132017-02-18 13:16:08 -080039const ButtonLocation kTurn1(1, 7);
40const ButtonLocation kTurn2(1, 11);
41
Austin Schuh51b1bae2017-04-09 18:31:57 -070042#endif
43
44#ifdef PISTOL
45// Pistol Grip controller
46const JoystickAxis kSteeringWheel(1, 1), kDriveThrottle(1, 2);
47//const ButtonLocation kQuickTurn(1, 7);
48const ButtonLocation kQuickTurn(1, 8);
49
50// Nop
51//const ButtonLocation kTurn1(1, 8);
52const ButtonLocation kTurn2(1, 9);
53
54const ButtonLocation kTurn1(1, 7);
55#endif
56
57#ifdef XBOX
58// xbox
59const JoystickAxis kSteeringWheel(1, 5), kDriveThrottle(1, 2);
60const ButtonLocation kQuickTurn(1, 5);
61
62// Nop
63const ButtonLocation kTurn1(1, 1);
64const ButtonLocation kTurn2(1, 2);
65
66#endif
67
68
Austin Schuh55c8d302017-04-05 19:25:37 -070069const ButtonLocation kGearSlotBack(2, 11);
70
Campbell Crowley71b5f132017-02-18 13:16:08 -080071const ButtonLocation kIntakeDown(3, 9);
Austin Schuhd0629b12017-03-22 22:37:16 -070072const POVLocation kIntakeUp(3, 90);
Campbell Crowley71b5f132017-02-18 13:16:08 -080073const ButtonLocation kIntakeIn(3, 12);
74const ButtonLocation kIntakeOut(3, 8);
Campbell Crowley71b5f132017-02-18 13:16:08 -080075const ButtonLocation kFire(3, 3);
Parker Schuh208a58d2017-04-12 20:51:38 -070076const ButtonLocation kVisionDistanceShot(3, 7);
Campbell Crowley71b5f132017-02-18 13:16:08 -080077const ButtonLocation kMiddleShot(3, 6);
78const POVLocation kFarShot(3, 270);
79
80const ButtonLocation kVisionAlign(3, 5);
81
82const ButtonLocation kReverseIndexer(3, 4);
83const ButtonLocation kExtra1(3, 11);
84const ButtonLocation kExtra2(3, 10);
Austin Schuhd0629b12017-03-22 22:37:16 -070085const ButtonLocation kHang(3, 2);
Campbell Crowley71b5f132017-02-18 13:16:08 -080086
87class Reader : public ::aos::input::JoystickInput {
88 public:
89 Reader() {}
90
Parker Schuh208a58d2017-04-12 20:51:38 -070091 enum class ShotDistance { VISION_SHOT, MIDDLE_SHOT, FAR_SHOT };
Austin Schuhd0629b12017-03-22 22:37:16 -070092
93 ShotDistance last_shot_distance_ = ShotDistance::FAR_SHOT;
94
Campbell Crowley71b5f132017-02-18 13:16:08 -080095 void RunIteration(const ::aos::input::driver_station::Data &data) override {
96 bool last_auto_running = auto_running_;
97 auto_running_ = data.GetControlBit(ControlBit::kAutonomous) &&
98 data.GetControlBit(ControlBit::kEnabled);
99 if (auto_running_ != last_auto_running) {
100 if (auto_running_) {
101 StartAuto();
102 } else {
103 StopAuto();
104 }
105 }
106
Campbell Crowley71b5f132017-02-18 13:16:08 -0800107 if (!auto_running_) {
108 HandleDrivetrain(data);
109 HandleTeleop(data);
110 }
111
112 // Process any pending actions.
113 action_queue_.Tick();
114 was_running_ = action_queue_.Running();
115 }
Austin Schuhd0629b12017-03-22 22:37:16 -0700116 int intake_accumulator_ = 0;
Campbell Crowley71b5f132017-02-18 13:16:08 -0800117
Austin Schuh51b1bae2017-04-09 18:31:57 -0700118 double Deadband(double value, const double deadband) {
119 if (::std::abs(value) < deadband) {
120 value = 0.0;
121 } else if (value > 0.0) {
122 value = (value - deadband) / (1.0 - deadband);
123 } else {
124 value = (value + deadband) / (1.0 - deadband);
125 }
126 return value;
127 }
128
Campbell Crowley71b5f132017-02-18 13:16:08 -0800129 void HandleDrivetrain(const ::aos::input::driver_station::Data &data) {
130 bool is_control_loop_driving = false;
131
Austin Schuh51b1bae2017-04-09 18:31:57 -0700132#ifdef STEERINGWHEEL
Campbell Crowley71b5f132017-02-18 13:16:08 -0800133 const double wheel = -data.GetAxis(kSteeringWheel);
134 const double throttle = -data.GetAxis(kDriveThrottle);
Austin Schuh51b1bae2017-04-09 18:31:57 -0700135#endif
136
137#ifdef XBOX
138 // xbox
139 constexpr double kWheelDeadband = 0.05;
140 constexpr double kThrottleDeadband = 0.05;
141 const double wheel =
142 Deadband(-data.GetAxis(kSteeringWheel), kWheelDeadband);
143
144 const double unmodified_throttle =
145 Deadband(-data.GetAxis(kDriveThrottle), kThrottleDeadband);
146
147 // Apply a sin function that's scaled to make it feel better.
148 constexpr double throttle_range = M_PI_2 * 0.9;
149
150 double throttle = ::std::sin(throttle_range * unmodified_throttle) /
151 ::std::sin(throttle_range);
152 throttle =
153 ::std::sin(throttle_range * throttle) / ::std::sin(throttle_range);
154 throttle = 2.0 * unmodified_throttle - throttle;
155#endif
156
157#ifdef PISTOL
158 const double wheel = data.GetAxis(kSteeringWheel) / 0.488;
159
160 const double unscaled_throttle = -data.GetAxis(kDriveThrottle);
161 double unmodified_throttle;
162 if (unscaled_throttle < 0.0) {
163 unmodified_throttle = unscaled_throttle / 0.228;
164 } else {
165 unmodified_throttle = unscaled_throttle / 0.484;
166 }
167 unmodified_throttle = Deadband(unmodified_throttle, 0.1);
168
169 // Apply a sin function that's scaled to make it feel better.
170 constexpr double throttle_range = M_PI_2 * 0.5;
171
172 double throttle = ::std::sin(throttle_range * unmodified_throttle) /
173 ::std::sin(throttle_range);
174 throttle =
175 ::std::sin(throttle_range * throttle) / ::std::sin(throttle_range);
176 throttle = 2.0 * unmodified_throttle - throttle;
177#endif
178
Campbell Crowley71b5f132017-02-18 13:16:08 -0800179 drivetrain_queue.status.FetchLatest();
Austin Schuhd0629b12017-03-22 22:37:16 -0700180 if (drivetrain_queue.status.get()) {
181 robot_velocity_ = drivetrain_queue.status->robot_speed;
182 }
Campbell Crowley71b5f132017-02-18 13:16:08 -0800183
Austin Schuh55c8d302017-04-05 19:25:37 -0700184 if (data.PosEdge(kTurn1) || data.PosEdge(kTurn2) ||
185 data.PosEdge(kGearSlotBack)) {
Campbell Crowley71b5f132017-02-18 13:16:08 -0800186 if (drivetrain_queue.status.get()) {
187 left_goal_ = drivetrain_queue.status->estimated_left_position;
188 right_goal_ = drivetrain_queue.status->estimated_right_position;
189 }
190 }
Austin Schuh51b1bae2017-04-09 18:31:57 -0700191#ifdef PISTOL
192 double current_left_goal = left_goal_ - wheel * 0.20 + throttle * 0.3;
193 double current_right_goal = right_goal_ + wheel * 0.20 + throttle * 0.3;
194#else
Austin Schuh55c8d302017-04-05 19:25:37 -0700195 double current_left_goal = left_goal_ - wheel * 0.5 + throttle * 0.3;
196 double current_right_goal = right_goal_ + wheel * 0.5 + throttle * 0.3;
Austin Schuh51b1bae2017-04-09 18:31:57 -0700197#endif
Campbell Crowley71b5f132017-02-18 13:16:08 -0800198 if (data.IsPressed(kTurn1) || data.IsPressed(kTurn2)) {
199 is_control_loop_driving = true;
200 }
Austin Schuh55c8d302017-04-05 19:25:37 -0700201 if (data.IsPressed(kGearSlotBack)) {
202 is_control_loop_driving = true;
203 current_left_goal = left_goal_ - 0.03;
204 current_right_goal = right_goal_ - 0.03;
205 }
206 auto new_drivetrain_goal = drivetrain_queue.goal.MakeMessage();
207 new_drivetrain_goal->steering = wheel;
208 new_drivetrain_goal->throttle = throttle;
209 new_drivetrain_goal->quickturn = data.IsPressed(kQuickTurn);
210 new_drivetrain_goal->control_loop_driving = is_control_loop_driving;
211 new_drivetrain_goal->left_goal = current_left_goal;
212 new_drivetrain_goal->right_goal = current_right_goal;
213 new_drivetrain_goal->left_velocity_goal = 0;
214 new_drivetrain_goal->right_velocity_goal = 0;
215
216 new_drivetrain_goal->linear.max_velocity = 3.0;
217 new_drivetrain_goal->linear.max_acceleration = 20.0;
218
219 if (!new_drivetrain_goal.Send()) {
Campbell Crowley71b5f132017-02-18 13:16:08 -0800220 LOG(WARNING, "sending stick values failed\n");
221 }
222 }
223
224 void HandleTeleop(const ::aos::input::driver_station::Data &data) {
225 // Default the intake to in.
Austin Schuhd0629b12017-03-22 22:37:16 -0700226 intake_goal_ = 0.07;
Adam Snaidere0554ef2017-03-11 23:02:45 -0800227 bool lights_on = false;
Austin Schuhd0629b12017-03-22 22:37:16 -0700228 bool vision_track = false;
Campbell Crowley71b5f132017-02-18 13:16:08 -0800229
230 if (!data.GetControlBit(ControlBit::kEnabled)) {
231 action_queue_.CancelAllActions();
232 LOG(DEBUG, "Canceling\n");
233 }
234
235 superstructure_queue.status.FetchLatest();
236 if (!superstructure_queue.status.get()) {
237 LOG(ERROR, "Got no superstructure status packet.\n");
238 return;
239 }
240
Austin Schuhd0629b12017-03-22 22:37:16 -0700241 if (data.IsPressed(kIntakeUp)) {
242 intake_goal_ = 0.0;
Austin Schuh3ae47432017-04-16 19:15:46 -0700243 turret_goal_ = M_PI / 3.0;
Austin Schuhd0629b12017-03-22 22:37:16 -0700244 }
Austin Schuh405724e2017-04-09 18:34:18 -0700245 if (data.IsPressed(kIntakeDown)) {
246 intake_goal_ = 0.235;
247 // Don't go quite so far out since we have a gear mech out now.
248 if (data.IsPressed(kIntakeUp)) {
249 intake_goal_ = 0.160;
250 }
251 }
Austin Schuhd0629b12017-03-22 22:37:16 -0700252
Campbell Crowley71b5f132017-02-18 13:16:08 -0800253
254 if (data.IsPressed(kVisionAlign)) {
255 // Align shot using vision
256 // TODO(campbell): Add vision aligning.
Adam Snaidere0554ef2017-03-11 23:02:45 -0800257 lights_on = true;
Austin Schuhd0629b12017-03-22 22:37:16 -0700258 vision_track = true;
259 }
260 if (data.PosEdge(kMiddleShot)) {
261 turret_goal_ = -M_PI;
262 }
263 if (data.PosEdge(kFarShot)) {
264 turret_goal_ = 0.0;
265 }
Parker Schuh208a58d2017-04-12 20:51:38 -0700266 if (data.PosEdge(kVisionDistanceShot)) {
267 turret_goal_ = 0.0;
268 }
Austin Schuhd0629b12017-03-22 22:37:16 -0700269
Parker Schuh208a58d2017-04-12 20:51:38 -0700270 if (data.IsPressed(kVisionDistanceShot)) {
271 last_shot_distance_ = ShotDistance::VISION_SHOT;
Campbell Crowley71b5f132017-02-18 13:16:08 -0800272 } else if (data.IsPressed(kMiddleShot)) {
Austin Schuhd0629b12017-03-22 22:37:16 -0700273 last_shot_distance_ = ShotDistance::MIDDLE_SHOT;
Campbell Crowley71b5f132017-02-18 13:16:08 -0800274 } else if (data.IsPressed(kFarShot)) {
Austin Schuhd0629b12017-03-22 22:37:16 -0700275 last_shot_distance_ = ShotDistance::FAR_SHOT;
276 }
277
Parker Schuh208a58d2017-04-12 20:51:38 -0700278 if (data.IsPressed(kVisionAlign) ||
Austin Schuhd0629b12017-03-22 22:37:16 -0700279 data.IsPressed(kMiddleShot) || data.IsPressed(kFarShot) ||
280 data.IsPressed(kFire)) {
281 switch (last_shot_distance_) {
Parker Schuh208a58d2017-04-12 20:51:38 -0700282 case ShotDistance::VISION_SHOT:
283 hood_goal_ = 0.31;
284 shooter_velocity_ = 320.0;
285 vision_distance_shot_ = true;
286 turret_goal_ = 0.0;
Austin Schuhd0629b12017-03-22 22:37:16 -0700287 break;
288 case ShotDistance::MIDDLE_SHOT:
Austin Schuh405724e2017-04-09 18:34:18 -0700289 hood_goal_ = 0.43 - 0.00;
290 shooter_velocity_ = 361.0;
Parker Schuh208a58d2017-04-12 20:51:38 -0700291 vision_distance_shot_ = false;
Austin Schuhd0629b12017-03-22 22:37:16 -0700292 break;
293 case ShotDistance::FAR_SHOT:
Austin Schuh405724e2017-04-09 18:34:18 -0700294 hood_goal_ = 0.43 - 0.01;
295 shooter_velocity_ = 365.0;
Parker Schuh208a58d2017-04-12 20:51:38 -0700296 vision_distance_shot_ = false;
Austin Schuhd0629b12017-03-22 22:37:16 -0700297 break;
298 }
Campbell Crowley71b5f132017-02-18 13:16:08 -0800299 } else {
Austin Schuhd0629b12017-03-22 22:37:16 -0700300 //hood_goal_ = 0.15;
Campbell Crowley71b5f132017-02-18 13:16:08 -0800301 shooter_velocity_ = 0.0;
302 }
303
304 if (data.IsPressed(kExtra1)) {
Austin Schuhd0629b12017-03-22 22:37:16 -0700305 //turret_goal_ = -M_PI * 3.0 / 4.0;
306 turret_goal_ += 0.150;
Campbell Crowley71b5f132017-02-18 13:16:08 -0800307 }
308 if (data.IsPressed(kExtra2)) {
Austin Schuhd0629b12017-03-22 22:37:16 -0700309 //turret_goal_ = M_PI * 3.0 / 4.0;
310 turret_goal_ -= 0.150;
Campbell Crowley71b5f132017-02-18 13:16:08 -0800311 }
Austin Schuhd0629b12017-03-22 22:37:16 -0700312 turret_goal_ = ::std::max(::std::min(turret_goal_, M_PI), -M_PI);
Campbell Crowley71b5f132017-02-18 13:16:08 -0800313
314 fire_ = data.IsPressed(kFire) && shooter_velocity_ != 0.0;
Austin Schuhd0629b12017-03-22 22:37:16 -0700315 if (data.IsPressed(kVisionAlign)) {
316 fire_ = fire_ && superstructure_queue.status->turret.vision_tracking;
317 }
Campbell Crowley71b5f132017-02-18 13:16:08 -0800318
319 auto new_superstructure_goal = superstructure_queue.goal.MakeMessage();
Austin Schuhd0629b12017-03-22 22:37:16 -0700320 if (data.IsPressed(kHang)) {
321 intake_goal_ = 0.23;
322 }
323
Campbell Crowley71b5f132017-02-18 13:16:08 -0800324 new_superstructure_goal->intake.distance = intake_goal_;
Austin Schuh3028b1d2017-03-11 22:12:13 -0800325 new_superstructure_goal->intake.disable_intake = false;
Campbell Crowley71b5f132017-02-18 13:16:08 -0800326 new_superstructure_goal->turret.angle = turret_goal_;
Austin Schuhd0629b12017-03-22 22:37:16 -0700327 new_superstructure_goal->turret.track = vision_track;
Campbell Crowley71b5f132017-02-18 13:16:08 -0800328 new_superstructure_goal->hood.angle = hood_goal_;
329 new_superstructure_goal->shooter.angular_velocity = shooter_velocity_;
330
Austin Schuh6a8131b2017-04-08 15:39:22 -0700331 if (data.IsPressed(kIntakeUp)) {
Austin Schuhd6fa5e02017-04-12 20:52:17 -0700332 new_superstructure_goal->intake.gear_servo = 0.30;
Austin Schuh6a8131b2017-04-08 15:39:22 -0700333 } else {
334 // Clamp the gear
Austin Schuhd6fa5e02017-04-12 20:52:17 -0700335 new_superstructure_goal->intake.gear_servo = 0.66;
Austin Schuh6a8131b2017-04-08 15:39:22 -0700336 }
337
Campbell Crowley71b5f132017-02-18 13:16:08 -0800338 new_superstructure_goal->intake.profile_params.max_velocity = 0.50;
Campbell Crowley71b5f132017-02-18 13:16:08 -0800339 new_superstructure_goal->hood.profile_params.max_velocity = 5.0;
340
341 new_superstructure_goal->intake.profile_params.max_acceleration = 5.0;
Austin Schuhd0629b12017-03-22 22:37:16 -0700342 if (vision_track) {
343 new_superstructure_goal->turret.profile_params.max_acceleration = 35.0;
344 new_superstructure_goal->turret.profile_params.max_velocity = 10.0;
345 } else {
346 new_superstructure_goal->turret.profile_params.max_acceleration = 15.0;
347 new_superstructure_goal->turret.profile_params.max_velocity = 6.0;
348 }
Campbell Crowley71b5f132017-02-18 13:16:08 -0800349 new_superstructure_goal->hood.profile_params.max_acceleration = 25.0;
350
Austin Schuh3028b1d2017-03-11 22:12:13 -0800351 new_superstructure_goal->intake.voltage_rollers = 0.0;
Adam Snaidere0554ef2017-03-11 23:02:45 -0800352 new_superstructure_goal->lights_on = lights_on;
Austin Schuh3028b1d2017-03-11 22:12:13 -0800353
Parker Schuh208a58d2017-04-12 20:51:38 -0700354 if (data.IsPressed(kVisionAlign) && vision_distance_shot_) {
355 new_superstructure_goal->use_vision_for_shots = true;
356 } else {
357 new_superstructure_goal->use_vision_for_shots = false;
358 }
359
Austin Schuh8e4a7ee2017-04-05 19:26:06 -0700360 if (superstructure_queue.status->intake.position >
361 superstructure_queue.status->intake.unprofiled_goal_position + 0.01) {
362 intake_accumulator_ = 10;
363 }
364 if (intake_accumulator_ > 0) {
365 --intake_accumulator_;
366 if (!superstructure_queue.status->intake.estopped) {
367 new_superstructure_goal->intake.voltage_rollers = 10.0;
368 }
369 }
370
Campbell Crowley71b5f132017-02-18 13:16:08 -0800371 if (data.IsPressed(kHang)) {
Austin Schuhd0629b12017-03-22 22:37:16 -0700372 new_superstructure_goal->intake.voltage_rollers = -10.0;
Austin Schuh3028b1d2017-03-11 22:12:13 -0800373 new_superstructure_goal->intake.disable_intake = true;
Austin Schuhd0629b12017-03-22 22:37:16 -0700374 } else if (data.IsPressed(kIntakeIn) || data.IsPressed(kFire)) {
375 if (robot_velocity_ > 2.0) {
376 new_superstructure_goal->intake.voltage_rollers = 12.0;
377 } else {
378 new_superstructure_goal->intake.voltage_rollers = 10.0;
379 }
Campbell Crowley71b5f132017-02-18 13:16:08 -0800380 } else if (data.IsPressed(kIntakeOut)) {
381 new_superstructure_goal->intake.voltage_rollers = -8.0;
Austin Schuh3028b1d2017-03-11 22:12:13 -0800382 }
383 if (intake_goal_ < 0.1) {
384 new_superstructure_goal->intake.voltage_rollers =
385 ::std::min(8.0, new_superstructure_goal->intake.voltage_rollers);
Campbell Crowley71b5f132017-02-18 13:16:08 -0800386 }
387
388 if (data.IsPressed(kReverseIndexer)) {
Austin Schuhd0629b12017-03-22 22:37:16 -0700389 new_superstructure_goal->indexer.voltage_rollers = -12.0;
Austin Schuh3028b1d2017-03-11 22:12:13 -0800390 new_superstructure_goal->indexer.angular_velocity = 4.0;
Campbell Crowley71b5f132017-02-18 13:16:08 -0800391 new_superstructure_goal->indexer.angular_velocity = 1.0;
Austin Schuh3028b1d2017-03-11 22:12:13 -0800392 } else if (fire_) {
Austin Schuhd0629b12017-03-22 22:37:16 -0700393 new_superstructure_goal->indexer.voltage_rollers = 12.0;
394 switch (last_shot_distance_) {
Parker Schuh208a58d2017-04-12 20:51:38 -0700395 case ShotDistance::VISION_SHOT:
396 new_superstructure_goal->indexer.angular_velocity = -2.25 * M_PI;
Austin Schuhd0629b12017-03-22 22:37:16 -0700397 break;
398 case ShotDistance::MIDDLE_SHOT:
399 case ShotDistance::FAR_SHOT:
400 new_superstructure_goal->indexer.angular_velocity = -2.25 * M_PI;
401 break;
402 }
Campbell Crowley71b5f132017-02-18 13:16:08 -0800403 } else {
404 new_superstructure_goal->indexer.voltage_rollers = 0.0;
405 new_superstructure_goal->indexer.angular_velocity = 0.0;
406 }
407
408 LOG_STRUCT(DEBUG, "sending goal", *new_superstructure_goal);
409 if (!new_superstructure_goal.Send()) {
410 LOG(ERROR, "Sending superstructure goal failed.\n");
411 }
412 }
413
414 private:
Austin Schuh3028b1d2017-03-11 22:12:13 -0800415 void StartAuto() {
416 LOG(INFO, "Starting auto mode\n");
417
418 ::frc971::autonomous::AutonomousActionParams params;
419 ::frc971::autonomous::auto_mode.FetchLatest();
420 if (::frc971::autonomous::auto_mode.get() != nullptr) {
421 params.mode = ::frc971::autonomous::auto_mode->mode;
422 } else {
423 LOG(WARNING, "no auto mode values\n");
424 params.mode = 0;
425 }
426 action_queue_.EnqueueAction(
427 ::frc971::autonomous::MakeAutonomousAction(params));
428 }
Campbell Crowley71b5f132017-02-18 13:16:08 -0800429
430 void StopAuto() {
431 LOG(INFO, "Stopping auto mode\n");
432 action_queue_.CancelAllActions();
433 }
434
435 // Current goals to send to the robot.
436 double intake_goal_ = 0.0;
437 double turret_goal_ = 0.0;
438 double hood_goal_ = 0.3;
439 double shooter_velocity_ = 0.0;
440
441 // Goals to send to the drivetrain in closed loop mode.
Austin Schuh3028b1d2017-03-11 22:12:13 -0800442 double left_goal_ = 0.0;
443 double right_goal_ = 0.0;
Campbell Crowley71b5f132017-02-18 13:16:08 -0800444
445 bool was_running_ = false;
446 bool auto_running_ = false;
447
Parker Schuh208a58d2017-04-12 20:51:38 -0700448 bool vision_distance_shot_ = false;
Campbell Crowley71b5f132017-02-18 13:16:08 -0800449
450 bool fire_ = false;
Austin Schuhd0629b12017-03-22 22:37:16 -0700451 double robot_velocity_ = 0.0;
Campbell Crowley71b5f132017-02-18 13:16:08 -0800452
453 ::aos::common::actions::ActionQueue action_queue_;
454};
455
456} // namespace joysticks
457} // namespace input
458} // namespace y2017
459
460int main() {
461 ::aos::Init(-1);
462 ::y2017::input::joysticks::Reader reader;
463 reader.Run();
464 ::aos::Cleanup();
465}