blob: e6dbb1f842eb7ecd711e03403389e7a6b1c654ec [file] [log] [blame]
Sabina Davisabeae332019-02-01 21:12:57 -08001#include <inttypes.h>
2#include <stdio.h>
3#include <string.h>
4#include <unistd.h>
5
6#include <array>
7#include <chrono>
8#include <cmath>
9#include <functional>
10#include <mutex>
11#include <thread>
12
13#include "frc971/wpilib/ahal/AnalogInput.h"
14#include "frc971/wpilib/ahal/Counter.h"
15#include "frc971/wpilib/ahal/DigitalGlitchFilter.h"
16#include "frc971/wpilib/ahal/DriverStation.h"
17#include "frc971/wpilib/ahal/Encoder.h"
18#include "frc971/wpilib/ahal/VictorSP.h"
Sabina Davisc6329342019-03-01 20:44:42 -080019#include "ctre/phoenix/CANifier.h"
Sabina Davisabeae332019-02-01 21:12:57 -080020#undef ERROR
21
22#include "aos/commonmath.h"
Austin Schuh8a633d52019-05-12 15:04:01 -070023#include "aos/events/event-loop.h"
Austin Schuhdf6cbb12019-02-02 13:46:52 -080024#include "aos/events/shm-event-loop.h"
Sabina Davisabeae332019-02-01 21:12:57 -080025#include "aos/init.h"
26#include "aos/logging/logging.h"
27#include "aos/logging/queue_logging.h"
28#include "aos/make_unique.h"
Austin Schuhc2ee66b2019-02-19 13:37:46 -080029#include "aos/robot_state/robot_state.q.h"
Sabina Davisabeae332019-02-01 21:12:57 -080030#include "aos/time/time.h"
Sabina Davisabeae332019-02-01 21:12:57 -080031#include "aos/util/log_interval.h"
32#include "aos/util/phased_loop.h"
33#include "aos/util/wrapping_counter.h"
Brian Silvermanc41fb862019-03-02 21:14:46 -080034#include "ctre/phoenix/motorcontrol/can/TalonSRX.h"
Sabina Davisabeae332019-02-01 21:12:57 -080035#include "frc971/autonomous/auto.q.h"
36#include "frc971/control_loops/drivetrain/drivetrain.q.h"
37#include "frc971/wpilib/ADIS16448.h"
Austin Schuhc1d6f832019-02-15 23:22:17 -080038#include "frc971/wpilib/buffered_pcm.h"
39#include "frc971/wpilib/buffered_solenoid.h"
Sabina Davisabeae332019-02-01 21:12:57 -080040#include "frc971/wpilib/dma.h"
Sabina Davisd004fd62019-02-02 23:51:46 -080041#include "frc971/wpilib/drivetrain_writer.h"
Sabina Davisabeae332019-02-01 21:12:57 -080042#include "frc971/wpilib/encoder_and_potentiometer.h"
Sabina Davisabeae332019-02-01 21:12:57 -080043#include "frc971/wpilib/joystick_sender.h"
44#include "frc971/wpilib/logging.q.h"
45#include "frc971/wpilib/loop_output_handler.h"
46#include "frc971/wpilib/pdp_fetcher.h"
Sabina Davisadc58542019-02-01 22:23:00 -080047#include "frc971/wpilib/sensor_reader.h"
Sabina Davisabeae332019-02-01 21:12:57 -080048#include "frc971/wpilib/wpilib_robot_base.h"
Sabina Davis7be49f32019-02-02 00:30:19 -080049#include "y2019/constants.h"
Brian Silvermanc41fb862019-03-02 21:14:46 -080050#include "y2019/control_loops/drivetrain/camera.q.h"
Alex Perry5fb5ff22019-02-09 21:53:17 -080051#include "y2019/control_loops/superstructure/superstructure.q.h"
Brian Silvermanf8b75252019-02-24 16:13:58 -080052#include "y2019/jevois/spi.h"
Sabina Davisc6329342019-03-01 20:44:42 -080053#include "y2019/status_light.q.h"
Sabina Davisabeae332019-02-01 21:12:57 -080054
55#ifndef M_PI
56#define M_PI 3.14159265358979323846
57#endif
58
59using ::frc971::control_loops::drivetrain_queue;
Alex Perry5fb5ff22019-02-09 21:53:17 -080060using ::y2019::control_loops::superstructure::superstructure_queue;
Sabina Davis7be49f32019-02-02 00:30:19 -080061using ::y2019::constants::Values;
Sabina Davisabeae332019-02-01 21:12:57 -080062using ::aos::monotonic_clock;
63namespace chrono = ::std::chrono;
64using aos::make_unique;
65
66namespace y2019 {
67namespace wpilib {
68namespace {
69
70constexpr double kMaxBringupPower = 12.0;
71
72// TODO(Brian): Fix the interpretation of the result of GetRaw here and in the
73// DMA stuff and then removing the * 2.0 in *_translate.
74// The low bit is direction.
75
76// TODO(brian): Use ::std::max instead once we have C++14 so that can be
77// constexpr.
78template <typename T>
79constexpr T max(T a, T b) {
80 return (a > b) ? a : b;
81}
82
83template <typename T, typename... Rest>
84constexpr T max(T a, T b, T c, Rest... rest) {
85 return max(max(a, b), c, rest...);
86}
87
88double drivetrain_translate(int32_t in) {
Sabina Davis7be49f32019-02-02 00:30:19 -080089 return ((static_cast<double>(in) /
90 Values::kDrivetrainEncoderCountsPerRevolution()) *
Sabina Davisabeae332019-02-01 21:12:57 -080091 (2.0 * M_PI)) *
92 Values::kDrivetrainEncoderRatio() *
Sabina Davis7be49f32019-02-02 00:30:19 -080093 control_loops::drivetrain::kWheelRadius;
Sabina Davisabeae332019-02-01 21:12:57 -080094}
95
96double drivetrain_velocity_translate(double in) {
Sabina Davis7be49f32019-02-02 00:30:19 -080097 return (((1.0 / in) / Values::kDrivetrainCyclesPerRevolution()) *
Sabina Davisabeae332019-02-01 21:12:57 -080098 (2.0 * M_PI)) *
99 Values::kDrivetrainEncoderRatio() *
Sabina Davis7be49f32019-02-02 00:30:19 -0800100 control_loops::drivetrain::kWheelRadius;
Sabina Davisabeae332019-02-01 21:12:57 -0800101}
102
Alex Perry5fb5ff22019-02-09 21:53:17 -0800103double elevator_pot_translate(double voltage) {
104 return voltage * Values::kElevatorPotRatio() *
Austin Schuhed7f8632019-02-15 23:12:20 -0800105 (10.0 /*turns*/ / 5.0 /*volts*/) * (2 * M_PI /*radians*/);
Alex Perry5fb5ff22019-02-09 21:53:17 -0800106}
107
108double wrist_pot_translate(double voltage) {
Austin Schuhed7f8632019-02-15 23:12:20 -0800109 return voltage * Values::kWristPotRatio() * (5.0 /*turns*/ / 5.0 /*volts*/) *
Alex Perry5fb5ff22019-02-09 21:53:17 -0800110 (2 * M_PI /*radians*/);
111}
112
113double stilts_pot_translate(double voltage) {
114 return voltage * Values::kStiltsPotRatio() *
115 (10.0 /*turns*/ / 5.0 /*volts*/) * (2 * M_PI /*radians*/);
116}
117
Sabina Davisabeae332019-02-01 21:12:57 -0800118constexpr double kMaxFastEncoderPulsesPerSecond =
Alex Perry5fb5ff22019-02-09 21:53:17 -0800119 max(Values::kMaxDrivetrainEncoderPulsesPerSecond(),
120 Values::kMaxIntakeEncoderPulsesPerSecond());
Sabina Davisabeae332019-02-01 21:12:57 -0800121static_assert(kMaxFastEncoderPulsesPerSecond <= 1300000,
122 "fast encoders are too fast");
Sabina Davisabeae332019-02-01 21:12:57 -0800123constexpr double kMaxMediumEncoderPulsesPerSecond =
Alex Perry5fb5ff22019-02-09 21:53:17 -0800124 max(Values::kMaxElevatorEncoderPulsesPerSecond(),
125 Values::kMaxWristEncoderPulsesPerSecond());
Theo Bafrali00e42272019-02-12 01:07:46 -0800126
Sabina Davisabeae332019-02-01 21:12:57 -0800127static_assert(kMaxMediumEncoderPulsesPerSecond <= 400000,
128 "medium encoders are too fast");
129
130// Class to send position messages with sensor readings to our loops.
Sabina Davisadc58542019-02-01 22:23:00 -0800131class SensorReader : public ::frc971::wpilib::SensorReader {
Sabina Davisabeae332019-02-01 21:12:57 -0800132 public:
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800133 SensorReader(::aos::EventLoop *event_loop)
Austin Schuha250b2d2019-05-27 16:14:02 -0700134 : ::frc971::wpilib::SensorReader(event_loop),
135 auto_mode_sender_(
136 event_loop->MakeSender<::frc971::autonomous::AutonomousMode>(
137 ".frc971.autonomous.auto_mode")) {
Sabina Davisabeae332019-02-01 21:12:57 -0800138 // Set to filter out anything shorter than 1/4 of the minimum pulse width
139 // we should ever see.
Austin Schuh45a549f2019-02-02 15:43:56 -0800140 UpdateFastEncoderFilterHz(kMaxFastEncoderPulsesPerSecond);
141 UpdateMediumEncoderFilterHz(kMaxMediumEncoderPulsesPerSecond);
Sabina Davisabeae332019-02-01 21:12:57 -0800142 }
143
Alex Perry5fb5ff22019-02-09 21:53:17 -0800144 // Elevator
145
146 void set_elevator_encoder(::std::unique_ptr<frc::Encoder> encoder) {
147 medium_encoder_filter_.Add(encoder.get());
148 elevator_encoder_.set_encoder(::std::move(encoder));
149 }
150
151 void set_elevator_absolute_pwm(
152 ::std::unique_ptr<frc::DigitalInput> absolute_pwm) {
153 elevator_encoder_.set_absolute_pwm(::std::move(absolute_pwm));
154 }
155
156 void set_elevator_potentiometer(
157 ::std::unique_ptr<frc::AnalogInput> potentiometer) {
158 elevator_encoder_.set_potentiometer(::std::move(potentiometer));
159 }
160
161 // Intake
162
163 void set_intake_encoder(::std::unique_ptr<frc::Encoder> encoder) {
164 medium_encoder_filter_.Add(encoder.get());
165 intake_encoder_.set_encoder(::std::move(encoder));
166 }
167
168 void set_intake_absolute_pwm(
169 ::std::unique_ptr<frc::DigitalInput> absolute_pwm) {
170 intake_encoder_.set_absolute_pwm(::std::move(absolute_pwm));
171 }
172
173 // Wrist
174
175 void set_wrist_encoder(::std::unique_ptr<frc::Encoder> encoder) {
176 medium_encoder_filter_.Add(encoder.get());
177 wrist_encoder_.set_encoder(::std::move(encoder));
178 }
179
180 void set_wrist_absolute_pwm(
181 ::std::unique_ptr<frc::DigitalInput> absolute_pwm) {
182 wrist_encoder_.set_absolute_pwm(::std::move(absolute_pwm));
183 }
184
185 void set_wrist_potentiometer(
186 ::std::unique_ptr<frc::AnalogInput> potentiometer) {
187 wrist_encoder_.set_potentiometer(::std::move(potentiometer));
188 }
189
190 // Stilts
191
192 void set_stilts_encoder(::std::unique_ptr<frc::Encoder> encoder) {
193 medium_encoder_filter_.Add(encoder.get());
194 stilts_encoder_.set_encoder(::std::move(encoder));
195 }
196
197 void set_stilts_absolute_pwm(
198 ::std::unique_ptr<frc::DigitalInput> absolute_pwm) {
199 stilts_encoder_.set_absolute_pwm(::std::move(absolute_pwm));
200 }
201
202 void set_stilts_potentiometer(
203 ::std::unique_ptr<frc::AnalogInput> potentiometer) {
204 stilts_encoder_.set_potentiometer(::std::move(potentiometer));
205 }
206
Austin Schuhe2f22482019-04-13 23:05:43 -0700207 void set_platform_left_detect(
208 ::std::unique_ptr<frc::DigitalInput> platform_left_detect) {
209 platform_left_detect_ = ::std::move(platform_left_detect);
210 }
211
212 void set_platform_right_detect(
213 ::std::unique_ptr<frc::DigitalInput> platform_right_detect) {
214 platform_right_detect_ = ::std::move(platform_right_detect);
215 }
216
Austin Schuh461e1182019-02-17 14:56:44 -0800217 // Vacuum pressure sensor
218 void set_vacuum_sensor(int port) {
219 vacuum_sensor_ = make_unique<frc::AnalogInput>(port);
220 }
221
Austin Schuha9644062019-03-28 14:31:52 -0700222 // Auto mode switches.
223 void set_autonomous_mode(int i, ::std::unique_ptr<frc::DigitalInput> sensor) {
224 autonomous_modes_.at(i) = ::std::move(sensor);
225 }
226
Sabina Davis399dbd82019-02-01 23:06:08 -0800227 void RunIteration() override {
Sabina Davisabeae332019-02-01 21:12:57 -0800228 {
229 auto drivetrain_message = drivetrain_queue.position.MakeMessage();
230 drivetrain_message->left_encoder =
231 drivetrain_translate(drivetrain_left_encoder_->GetRaw());
232 drivetrain_message->left_speed =
233 drivetrain_velocity_translate(drivetrain_left_encoder_->GetPeriod());
234
235 drivetrain_message->right_encoder =
236 -drivetrain_translate(drivetrain_right_encoder_->GetRaw());
237 drivetrain_message->right_speed = -drivetrain_velocity_translate(
238 drivetrain_right_encoder_->GetPeriod());
239
240 drivetrain_message.Send();
241 }
Alex Perry5fb5ff22019-02-09 21:53:17 -0800242 const auto values = constants::GetValues();
243
244 {
245 auto superstructure_message = superstructure_queue.position.MakeMessage();
246
247 // Elevator
248 CopyPosition(elevator_encoder_, &superstructure_message->elevator,
249 Values::kElevatorEncoderCountsPerRevolution(),
250 Values::kElevatorEncoderRatio(), elevator_pot_translate,
251 false, values.elevator.potentiometer_offset);
252 // Intake
253 CopyPosition(intake_encoder_, &superstructure_message->intake_joint,
254 Values::kIntakeEncoderCountsPerRevolution(),
255 Values::kIntakeEncoderRatio(), false);
256
257 // Wrist
258 CopyPosition(wrist_encoder_, &superstructure_message->wrist,
259 Values::kWristEncoderCountsPerRevolution(),
260 Values::kWristEncoderRatio(), wrist_pot_translate, false,
261 values.wrist.potentiometer_offset);
262
263 // Stilts
264 CopyPosition(stilts_encoder_, &superstructure_message->stilts,
265 Values::kStiltsEncoderCountsPerRevolution(),
266 Values::kStiltsEncoderRatio(), stilts_pot_translate, false,
267 values.stilts.potentiometer_offset);
268
Austin Schuh461e1182019-02-17 14:56:44 -0800269 // Suction
270 constexpr float kMinVoltage = 0.5;
271 constexpr float kMaxVoltage = 2.1;
272 superstructure_message->suction_pressure =
273 (vacuum_sensor_->GetVoltage() - kMinVoltage) /
274 (kMaxVoltage - kMinVoltage);
275
Austin Schuhe2f22482019-04-13 23:05:43 -0700276 superstructure_message->platform_left_detect =
277 !platform_left_detect_->Get();
278 superstructure_message->platform_right_detect =
279 !platform_right_detect_->Get();
280
Alex Perry5fb5ff22019-02-09 21:53:17 -0800281 superstructure_message.Send();
282 }
Austin Schuha9644062019-03-28 14:31:52 -0700283
284 {
Austin Schuha250b2d2019-05-27 16:14:02 -0700285 auto auto_mode_message = auto_mode_sender_.MakeMessage();
Austin Schuha9644062019-03-28 14:31:52 -0700286 auto_mode_message->mode = 0;
287 for (size_t i = 0; i < autonomous_modes_.size(); ++i) {
288 if (autonomous_modes_[i] && autonomous_modes_[i]->Get()) {
289 auto_mode_message->mode |= 1 << i;
290 }
291 }
292 LOG_STRUCT(DEBUG, "auto mode", *auto_mode_message);
293 auto_mode_message.Send();
294 }
Alex Perry5fb5ff22019-02-09 21:53:17 -0800295 }
296
297 private:
Austin Schuha250b2d2019-05-27 16:14:02 -0700298 ::aos::Sender<::frc971::autonomous::AutonomousMode> auto_mode_sender_;
299
Alex Perry5fb5ff22019-02-09 21:53:17 -0800300 ::frc971::wpilib::AbsoluteEncoderAndPotentiometer elevator_encoder_,
301 wrist_encoder_, stilts_encoder_;
302
Austin Schuhe2f22482019-04-13 23:05:43 -0700303 ::std::unique_ptr<frc::DigitalInput> platform_left_detect_;
304 ::std::unique_ptr<frc::DigitalInput> platform_right_detect_;
305
Austin Schuh461e1182019-02-17 14:56:44 -0800306 ::std::unique_ptr<frc::AnalogInput> vacuum_sensor_;
307
Austin Schuha9644062019-03-28 14:31:52 -0700308 ::std::array<::std::unique_ptr<frc::DigitalInput>, 2> autonomous_modes_;
309
Alex Perry5fb5ff22019-02-09 21:53:17 -0800310 ::frc971::wpilib::AbsoluteEncoder intake_encoder_;
311 // TODO(sabina): Add wrist and elevator hall effects.
312};
313
Brian Silvermanf8b75252019-02-24 16:13:58 -0800314class CameraReader {
315 public:
Austin Schuh8a633d52019-05-12 15:04:01 -0700316 CameraReader(::aos::EventLoop *event_loop)
317 : camera_frame_sender_(
318 event_loop
319 ->MakeSender<::y2019::control_loops::drivetrain::CameraFrame>(
Austin Schuh5671a8c2019-05-19 17:01:04 -0700320 ".y2019.control_loops.drivetrain.camera_frames")),
321 camera_log_fetcher_(
322 event_loop->MakeFetcher<::y2019::CameraLog>(".y2019.camera_log")) {}
Austin Schuh8a633d52019-05-12 15:04:01 -0700323
Brian Silvermanf8b75252019-02-24 16:13:58 -0800324 CameraReader(const CameraReader &) = delete;
325 CameraReader &operator=(const CameraReader &) = delete;
326
327 void set_spi(frc::SPI *spi) {
328 spi_ = spi;
329 spi_->SetClockRate(1e6);
330 spi_->SetChipSelectActiveHigh();
331 spi_->SetClockActiveLow();
332 spi_->SetSampleDataOnFalling();
333 // It ignores you if you try changing this...
334 spi_->SetMSBFirst();
335 }
336
Brian Silverman7ecf0672019-03-02 15:30:03 -0800337 void set_activate_usb(std::unique_ptr<frc::DigitalInput> activate_usb) {
338 activate_usb_ = std::move(activate_usb);
339 }
340
341 void set_activate_passthrough(
342 std::unique_ptr<frc::DigitalInput> activate_passthrough) {
343 activate_passthrough_ = std::move(activate_passthrough);
344 }
345
Brian Silvermanf8b75252019-02-24 16:13:58 -0800346 void DoSpiTransaction() {
347 using namespace frc971::jevois;
348 RoborioToTeensy to_teensy{};
349 to_teensy.realtime_now = aos::realtime_clock::now();
Austin Schuh5671a8c2019-05-19 17:01:04 -0700350 camera_log_fetcher_.Fetch();
Brian Silverman7ecf0672019-03-02 15:30:03 -0800351 if (activate_usb_ && !activate_usb_->Get()) {
352 to_teensy.camera_command = CameraCommand::kUsb;
353 } else if (activate_passthrough_ && !activate_passthrough_->Get()) {
354 to_teensy.camera_command = CameraCommand::kCameraPassthrough;
Austin Schuh5671a8c2019-05-19 17:01:04 -0700355 } else if (camera_log_fetcher_.get() && camera_log_fetcher_->log) {
Austin Schuh4e2629d2019-03-28 14:44:37 -0700356 to_teensy.camera_command = CameraCommand::kLog;
Brian Silverman7ecf0672019-03-02 15:30:03 -0800357 } else {
358 to_teensy.camera_command = CameraCommand::kNormal;
359 }
Brian Silvermanf8b75252019-02-24 16:13:58 -0800360
361 std::array<char, spi_transfer_size() + 1> to_send{};
362 {
363 const auto to_send_data =
364 gsl::make_span(to_send).last<spi_transfer_size()>();
365 const auto encoded = SpiPackToTeensy(to_teensy);
366 std::copy(encoded.begin(), encoded.end(), to_send_data.begin());
367 }
368 rx_clearer_.ClearRxFifo();
369 // First, send recieve a dummy byte because the Teensy can't control what it
370 // sends for the first byte.
371 std::array<char, spi_transfer_size() + 1> to_receive;
372 DoTransaction(to_send, to_receive);
373 const auto unpacked = SpiUnpackToRoborio(
374 gsl::make_span(to_receive).last(spi_transfer_size()));
375 if (!unpacked) {
376 LOG(INFO, "Decoding SPI data failed\n");
377 return;
378 }
379
Brian Silvermanc41fb862019-03-02 21:14:46 -0800380 const auto now = aos::monotonic_clock::now();
381 for (const auto &received : unpacked->frames) {
Austin Schuh8a633d52019-05-12 15:04:01 -0700382 auto to_send = camera_frame_sender_.MakeMessage();
James Kuszmaule08f04e2019-05-01 21:46:50 -0500383 // Add an extra 10ms delay to account for unmodeled delays that Austin
384 // thinks exists.
Brian Silvermanc41fb862019-03-02 21:14:46 -0800385 to_send->timestamp =
James Kuszmaule08f04e2019-05-01 21:46:50 -0500386 std::chrono::nanoseconds(
387 (now - received.age - ::std::chrono::milliseconds(10))
388 .time_since_epoch()).count();
Brian Silvermanc41fb862019-03-02 21:14:46 -0800389 to_send->num_targets = received.targets.size();
390 for (size_t i = 0; i < received.targets.size(); ++i) {
391 to_send->targets[i].distance = received.targets[i].distance;
392 to_send->targets[i].height = received.targets[i].height;
393 to_send->targets[i].heading = received.targets[i].heading;
394 to_send->targets[i].skew = received.targets[i].skew;
395 }
396 to_send->camera = received.camera_index;
Austin Schuhbb52eec2019-03-03 18:32:14 -0800397 LOG_STRUCT(DEBUG, "camera_frames", *to_send);
Brian Silvermanc41fb862019-03-02 21:14:46 -0800398 to_send.Send();
399 }
Brian Silvermanf8b75252019-02-24 16:13:58 -0800400
401 if (dummy_spi_) {
402 uint8_t dummy_send, dummy_receive;
403 dummy_spi_->Transaction(&dummy_send, &dummy_receive, 1);
404 }
405 }
406
407 void DoTransaction(gsl::span<char> to_send, gsl::span<char> to_receive) {
408 CHECK_EQ(to_send.size(), to_receive.size());
409 const auto result = spi_->Transaction(
410 reinterpret_cast<uint8_t *>(to_send.data()),
411 reinterpret_cast<uint8_t *>(to_receive.data()), to_send.size());
412 if (result == to_send.size()) {
413 return;
414 }
415 if (result == -1) {
416 LOG(INFO, "SPI::Transaction of %zd bytes failed\n", to_send.size());
417 return;
418 }
419 LOG(FATAL, "SPI::Transaction returned something weird\n");
420 }
421
422 void SetDummySPI(frc::SPI::Port port) {
423 dummy_spi_.reset(new frc::SPI(port));
424 // Pick the same settings here in case the roboRIO decides to try something
425 // stupid when switching.
426 if (dummy_spi_) {
427 dummy_spi_->SetClockRate(1e5);
428 dummy_spi_->SetChipSelectActiveLow();
429 dummy_spi_->SetClockActiveLow();
430 dummy_spi_->SetSampleDataOnFalling();
431 dummy_spi_->SetMSBFirst();
432 }
433 }
434
435 private:
Austin Schuh8a633d52019-05-12 15:04:01 -0700436 ::aos::Sender<::y2019::control_loops::drivetrain::CameraFrame>
437 camera_frame_sender_;
Austin Schuh5671a8c2019-05-19 17:01:04 -0700438 ::aos::Fetcher<::y2019::CameraLog> camera_log_fetcher_;
Austin Schuh8a633d52019-05-12 15:04:01 -0700439
Brian Silvermanf8b75252019-02-24 16:13:58 -0800440 frc::SPI *spi_ = nullptr;
441 ::std::unique_ptr<frc::SPI> dummy_spi_;
442
Brian Silverman7ecf0672019-03-02 15:30:03 -0800443 std::unique_ptr<frc::DigitalInput> activate_usb_;
444 std::unique_ptr<frc::DigitalInput> activate_passthrough_;
445
Brian Silvermanf8b75252019-02-24 16:13:58 -0800446 frc971::wpilib::SpiRxClearer rx_clearer_;
447};
448
Alex Perry5fb5ff22019-02-09 21:53:17 -0800449class SuperstructureWriter : public ::frc971::wpilib::LoopOutputHandler {
450 public:
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800451 SuperstructureWriter(::aos::EventLoop *event_loop)
452 : ::frc971::wpilib::LoopOutputHandler(event_loop),
453 robot_state_fetcher_(
454 event_loop->MakeFetcher<::aos::RobotState>(".aos.robot_state")) {}
455
Alex Perry5fb5ff22019-02-09 21:53:17 -0800456 void set_elevator_victor(::std::unique_ptr<::frc::VictorSP> t) {
457 elevator_victor_ = ::std::move(t);
458 }
459
Austin Schuh461e1182019-02-17 14:56:44 -0800460 void set_suction_victor(::std::unique_ptr<::frc::VictorSP> t) {
461 suction_victor_ = ::std::move(t);
462 }
463
Alex Perry5fb5ff22019-02-09 21:53:17 -0800464 void set_intake_victor(::std::unique_ptr<::frc::VictorSP> t) {
465 intake_victor_ = ::std::move(t);
466 }
Alex Perry5fb5ff22019-02-09 21:53:17 -0800467
468 void set_wrist_victor(::std::unique_ptr<::frc::VictorSP> t) {
469 wrist_victor_ = ::std::move(t);
470 }
471
472 void set_stilts_victor(::std::unique_ptr<::frc::VictorSP> t) {
473 stilts_victor_ = ::std::move(t);
474 }
475
476 private:
Austin Schuh461e1182019-02-17 14:56:44 -0800477 void Read() override {
Alex Perry5fb5ff22019-02-09 21:53:17 -0800478 ::y2019::control_loops::superstructure::superstructure_queue.output
479 .FetchAnother();
480 }
481
Austin Schuh461e1182019-02-17 14:56:44 -0800482 void Write() override {
Alex Perry5fb5ff22019-02-09 21:53:17 -0800483 auto &queue =
484 ::y2019::control_loops::superstructure::superstructure_queue.output;
485 LOG_STRUCT(DEBUG, "will output", *queue);
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800486 elevator_victor_->SetSpeed(::aos::Clip(queue->elevator_voltage,
Alex Perry5fb5ff22019-02-09 21:53:17 -0800487 -kMaxBringupPower,
488 kMaxBringupPower) /
489 12.0);
490
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800491 intake_victor_->SetSpeed(::aos::Clip(queue->intake_joint_voltage,
Alex Perry5fb5ff22019-02-09 21:53:17 -0800492 -kMaxBringupPower, kMaxBringupPower) /
493 12.0);
494
Alex Perry5fb5ff22019-02-09 21:53:17 -0800495 wrist_victor_->SetSpeed(::aos::Clip(-queue->wrist_voltage,
496 -kMaxBringupPower, kMaxBringupPower) /
497 12.0);
498
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800499 stilts_victor_->SetSpeed(::aos::Clip(queue->stilts_voltage,
Alex Perry5fb5ff22019-02-09 21:53:17 -0800500 -kMaxBringupPower, kMaxBringupPower) /
501 12.0);
Austin Schuh461e1182019-02-17 14:56:44 -0800502
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800503 robot_state_fetcher_.Fetch();
504 const double battery_voltage = robot_state_fetcher_.get()
505 ? robot_state_fetcher_->voltage_battery
506 : 12.0;
Austin Schuhc2ee66b2019-02-19 13:37:46 -0800507
508 // Throw a fast low pass filter on the battery voltage so we don't respond
509 // too fast to noise.
510 filtered_battery_voltage_ =
511 0.5 * filtered_battery_voltage_ + 0.5 * battery_voltage;
512
513 suction_victor_->SetSpeed(::aos::Clip(
514 queue->pump_voltage / filtered_battery_voltage_, -1.0, 1.0));
Alex Perry5fb5ff22019-02-09 21:53:17 -0800515 }
516
Austin Schuh461e1182019-02-17 14:56:44 -0800517 void Stop() override {
Alex Perry5fb5ff22019-02-09 21:53:17 -0800518 LOG(WARNING, "Superstructure output too old.\n");
519
520 elevator_victor_->SetDisabled();
521 intake_victor_->SetDisabled();
Alex Perry5fb5ff22019-02-09 21:53:17 -0800522 wrist_victor_->SetDisabled();
523 stilts_victor_->SetDisabled();
Austin Schuh461e1182019-02-17 14:56:44 -0800524 suction_victor_->SetDisabled();
Alex Perry5fb5ff22019-02-09 21:53:17 -0800525 }
526
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800527 ::aos::Fetcher<::aos::RobotState> robot_state_fetcher_;
528
Alex Perry5fb5ff22019-02-09 21:53:17 -0800529 ::std::unique_ptr<::frc::VictorSP> elevator_victor_, intake_victor_,
Austin Schuh461e1182019-02-17 14:56:44 -0800530 wrist_victor_, stilts_victor_, suction_victor_;
Austin Schuhc2ee66b2019-02-19 13:37:46 -0800531
532 double filtered_battery_voltage_ = 12.0;
Sabina Davisabeae332019-02-01 21:12:57 -0800533};
534
Austin Schuhc1d6f832019-02-15 23:22:17 -0800535class SolenoidWriter {
536 public:
Austin Schuhff973552019-05-19 16:49:28 -0700537 SolenoidWriter(::aos::EventLoop *event_loop)
538 : event_loop_(event_loop),
539 superstructure_fetcher_(event_loop->MakeFetcher<
540 ::y2019::control_loops::superstructure::
541 SuperstructureQueue::Output>(
542 ".y2019.control_loops.superstructure.superstructure_queue.output")),
543 status_light_fetcher_(event_loop->MakeFetcher<::y2019::StatusLight>(
544 ".y2019.status_light")) {}
Austin Schuhc1d6f832019-02-15 23:22:17 -0800545
Austin Schuh461e1182019-02-17 14:56:44 -0800546 void set_big_suction_cup(int index0, int index1) {
547 big_suction_cup0_ = pcm_.MakeSolenoid(index0);
548 big_suction_cup1_ = pcm_.MakeSolenoid(index1);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800549 }
Austin Schuh461e1182019-02-17 14:56:44 -0800550 void set_small_suction_cup(int index0, int index1) {
551 small_suction_cup0_ = pcm_.MakeSolenoid(index0);
552 small_suction_cup1_ = pcm_.MakeSolenoid(index1);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800553 }
554
555 void set_intake_roller_talon(
556 ::std::unique_ptr<::ctre::phoenix::motorcontrol::can::TalonSRX> t) {
557 intake_rollers_talon_ = ::std::move(t);
Austin Schuh23a51632019-02-19 16:50:36 -0800558 intake_rollers_talon_->ConfigContinuousCurrentLimit(10.0, 0);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800559 intake_rollers_talon_->EnableCurrentLimit(true);
560 }
561
562 void operator()() {
563 ::aos::SetCurrentThreadName("Solenoids");
564 ::aos::SetCurrentThreadRealtimePriority(27);
565
566 ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(20),
567 ::std::chrono::milliseconds(1));
568
569 while (run_) {
570 {
571 const int iterations = phased_loop.SleepUntilNext();
572 if (iterations != 1) {
573 LOG(DEBUG, "Solenoids skipped %d iterations\n", iterations - 1);
574 }
575 }
576
577 {
Austin Schuhff973552019-05-19 16:49:28 -0700578 superstructure_fetcher_.Fetch();
579 if (superstructure_fetcher_.get()) {
580 LOG_STRUCT(DEBUG, "solenoids", *superstructure_fetcher_);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800581
Austin Schuhff973552019-05-19 16:49:28 -0700582 big_suction_cup0_->Set(
583 !superstructure_fetcher_->intake_suction_bottom);
584 big_suction_cup1_->Set(
585 !superstructure_fetcher_->intake_suction_bottom);
586 small_suction_cup0_->Set(superstructure_fetcher_->intake_suction_top);
587 small_suction_cup1_->Set(superstructure_fetcher_->intake_suction_top);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800588
589 intake_rollers_talon_->Set(
590 ctre::phoenix::motorcontrol::ControlMode::PercentOutput,
Austin Schuhff973552019-05-19 16:49:28 -0700591 ::aos::Clip(superstructure_fetcher_->intake_roller_voltage,
Austin Schuhc1d6f832019-02-15 23:22:17 -0800592 -kMaxBringupPower, kMaxBringupPower) /
593 12.0);
594 }
595 }
596
597 {
598 ::frc971::wpilib::PneumaticsToLog to_log;
599
600 pcm_.Flush();
601 to_log.read_solenoids = pcm_.GetAll();
602 LOG_STRUCT(DEBUG, "pneumatics info", to_log);
603 }
Sabina Davisc6329342019-03-01 20:44:42 -0800604
Austin Schuhff973552019-05-19 16:49:28 -0700605 status_light_fetcher_.Fetch();
Sabina Davisc6329342019-03-01 20:44:42 -0800606 // If we don't have a light request (or it's an old one), we are borked.
607 // Flash the red light slowly.
Austin Schuhff973552019-05-19 16:49:28 -0700608 if (!status_light_fetcher_.get() ||
609 status_light_fetcher_.get()->sent_time + chrono::milliseconds(100) <
610 event_loop_->monotonic_now()) {
Sabina Davisc6329342019-03-01 20:44:42 -0800611 StatusLight color;
612 color.red = 0.0;
613 color.green = 0.0;
614 color.blue = 0.0;
615
616 ++light_flash_;
617 if (light_flash_ > 10) {
618 color.red = 0.5;
619 }
620
621 if (light_flash_ > 20) {
622 light_flash_ = 0;
623 }
624
625 LOG_STRUCT(DEBUG, "color", color);
626 SetColor(color);
627 } else {
Austin Schuhff973552019-05-19 16:49:28 -0700628 LOG_STRUCT(DEBUG, "color", *status_light_fetcher_.get());
629 SetColor(*status_light_fetcher_.get());
Sabina Davisc6329342019-03-01 20:44:42 -0800630 }
631 }
632 }
633
634 void SetColor(const StatusLight &status_light) {
635 // Save CAN bandwidth and CPU at the cost of RT. Only change the light when
636 // it actually changes. This is pretty low priority anyways.
637 static int time_since_last_send = 0;
638 ++time_since_last_send;
639 if (time_since_last_send > 10) {
640 time_since_last_send = 0;
641 }
642 if (status_light.green != last_green_ || time_since_last_send == 0) {
Sabina Davis77a11cf2019-03-09 18:20:26 -0800643 canifier_.SetLEDOutput(status_light.green,
644 ::ctre::phoenix::CANifier::LEDChannelA);
Sabina Davisc6329342019-03-01 20:44:42 -0800645 last_green_ = status_light.green;
646 }
647
648 if (status_light.blue != last_blue_ || time_since_last_send == 0) {
Sabina Davis77a11cf2019-03-09 18:20:26 -0800649 canifier_.SetLEDOutput(status_light.blue,
650 ::ctre::phoenix::CANifier::LEDChannelC);
Sabina Davisc6329342019-03-01 20:44:42 -0800651 last_blue_ = status_light.blue;
652 }
653
654 if (status_light.red != last_red_ || time_since_last_send == 0) {
Sabina Davis77a11cf2019-03-09 18:20:26 -0800655 canifier_.SetLEDOutput(status_light.red,
656 ::ctre::phoenix::CANifier::LEDChannelB);
Sabina Davisc6329342019-03-01 20:44:42 -0800657 last_red_ = status_light.red;
Austin Schuhc1d6f832019-02-15 23:22:17 -0800658 }
659 }
660
661 void Quit() { run_ = false; }
662
663 private:
Austin Schuhff973552019-05-19 16:49:28 -0700664 ::aos::EventLoop *event_loop_;
665
Austin Schuhc1d6f832019-02-15 23:22:17 -0800666 ::frc971::wpilib::BufferedPcm pcm_;
667
Austin Schuh461e1182019-02-17 14:56:44 -0800668 ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> big_suction_cup0_,
669 big_suction_cup1_, small_suction_cup0_, small_suction_cup1_;
Austin Schuhc1d6f832019-02-15 23:22:17 -0800670
671 ::std::unique_ptr<::ctre::phoenix::motorcontrol::can::TalonSRX>
672 intake_rollers_talon_;
673
Austin Schuhff973552019-05-19 16:49:28 -0700674 ::aos::Fetcher<
Austin Schuhc1d6f832019-02-15 23:22:17 -0800675 ::y2019::control_loops::superstructure::SuperstructureQueue::Output>
Austin Schuhff973552019-05-19 16:49:28 -0700676 superstructure_fetcher_;
677 ::aos::Fetcher<::y2019::StatusLight> status_light_fetcher_;
Austin Schuhc1d6f832019-02-15 23:22:17 -0800678
Sabina Davisc6329342019-03-01 20:44:42 -0800679 ::ctre::phoenix::CANifier canifier_{0};
680
Austin Schuhc1d6f832019-02-15 23:22:17 -0800681 ::std::atomic<bool> run_{true};
Sabina Davisc6329342019-03-01 20:44:42 -0800682
683 double last_red_ = -1.0;
684 double last_green_ = -1.0;
685 double last_blue_ = -1.0;
686
687 int light_flash_ = 0;
Austin Schuhc1d6f832019-02-15 23:22:17 -0800688};
689
Sabina Davisabeae332019-02-01 21:12:57 -0800690class WPILibRobot : public ::frc971::wpilib::WPILibRobotBase {
691 public:
692 ::std::unique_ptr<frc::Encoder> make_encoder(int index) {
693 return make_unique<frc::Encoder>(10 + index * 2, 11 + index * 2, false,
694 frc::Encoder::k4X);
695 }
696
697 void Run() override {
698 ::aos::InitNRT();
699 ::aos::SetCurrentThreadName("StartCompetition");
700
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800701 ::aos::ShmEventLoop event_loop;
Austin Schuhff973552019-05-19 16:49:28 -0700702 ::aos::ShmEventLoop solenoid_event_loop;
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800703
704 ::frc971::wpilib::JoystickSender joystick_sender(&event_loop);
Sabina Davisabeae332019-02-01 21:12:57 -0800705 ::std::thread joystick_thread(::std::ref(joystick_sender));
706
Austin Schuh0b545432019-05-12 15:46:12 -0700707 ::frc971::wpilib::PDPFetcher pdp_fetcher(&event_loop);
Sabina Davisabeae332019-02-01 21:12:57 -0800708 ::std::thread pdp_fetcher_thread(::std::ref(pdp_fetcher));
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800709 SensorReader reader(&event_loop);
Sabina Davisabeae332019-02-01 21:12:57 -0800710
Sabina Davisabeae332019-02-01 21:12:57 -0800711 reader.set_drivetrain_left_encoder(make_encoder(0));
712 reader.set_drivetrain_right_encoder(make_encoder(1));
713
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800714 reader.set_elevator_encoder(make_encoder(4));
715 reader.set_elevator_absolute_pwm(make_unique<frc::DigitalInput>(4));
716 reader.set_elevator_potentiometer(make_unique<frc::AnalogInput>(4));
Alex Perry5fb5ff22019-02-09 21:53:17 -0800717
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800718 reader.set_wrist_encoder(make_encoder(5));
719 reader.set_wrist_absolute_pwm(make_unique<frc::DigitalInput>(5));
720 reader.set_wrist_potentiometer(make_unique<frc::AnalogInput>(5));
Alex Perry5fb5ff22019-02-09 21:53:17 -0800721
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800722 reader.set_intake_encoder(make_encoder(2));
723 reader.set_intake_absolute_pwm(make_unique<frc::DigitalInput>(2));
Alex Perry5fb5ff22019-02-09 21:53:17 -0800724
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800725 reader.set_stilts_encoder(make_encoder(3));
726 reader.set_stilts_absolute_pwm(make_unique<frc::DigitalInput>(3));
Alex Perry5fb5ff22019-02-09 21:53:17 -0800727 reader.set_stilts_potentiometer(make_unique<frc::AnalogInput>(3));
728
Austin Schuh3b010bc2019-02-24 17:25:37 -0800729 reader.set_pwm_trigger(true);
Austin Schuh461e1182019-02-17 14:56:44 -0800730 reader.set_vacuum_sensor(7);
Sabina Davisabeae332019-02-01 21:12:57 -0800731
Austin Schuhe2f22482019-04-13 23:05:43 -0700732 reader.set_platform_right_detect(make_unique<frc::DigitalInput>(6));
733 reader.set_platform_left_detect(make_unique<frc::DigitalInput>(7));
734
Austin Schuha9644062019-03-28 14:31:52 -0700735 reader.set_autonomous_mode(0, make_unique<frc::DigitalInput>(22));
736 reader.set_autonomous_mode(0, make_unique<frc::DigitalInput>(23));
737
Sabina Davisabeae332019-02-01 21:12:57 -0800738 ::std::thread reader_thread(::std::ref(reader));
739
Austin Schuh8a633d52019-05-12 15:04:01 -0700740 CameraReader camera_reader(&event_loop);
Brian Silvermanf8b75252019-02-24 16:13:58 -0800741 frc::SPI camera_spi(frc::SPI::Port::kOnboardCS3);
742 camera_reader.set_spi(&camera_spi);
743 camera_reader.SetDummySPI(frc::SPI::Port::kOnboardCS2);
Brian Silverman7ecf0672019-03-02 15:30:03 -0800744 // Austin says 8, 9, 24, and 25 are good options to choose from for these.
745 camera_reader.set_activate_usb(make_unique<frc::DigitalInput>(24));
746 camera_reader.set_activate_passthrough(make_unique<frc::DigitalInput>(25));
Brian Silvermanf8b75252019-02-24 16:13:58 -0800747
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800748 auto imu_trigger = make_unique<frc::DigitalInput>(0);
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800749 ::frc971::wpilib::ADIS16448 imu(&event_loop, frc::SPI::Port::kOnboardCS1,
Sabina Davisabeae332019-02-01 21:12:57 -0800750 imu_trigger.get());
Brian Silvermanf8b75252019-02-24 16:13:58 -0800751 imu.set_spi_idle_callback(
752 [&camera_reader]() { camera_reader.DoSpiTransaction(); });
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800753 auto imu_reset = make_unique<frc::DigitalOutput>(1);
Sabina Davisabeae332019-02-01 21:12:57 -0800754 imu.set_reset(imu_reset.get());
755 ::std::thread imu_thread(::std::ref(imu));
756
757 // While as of 2/9/18 the drivetrain Victors are SPX, it appears as though
758 // they are identical, as far as DrivetrainWriter is concerned, to the SP
759 // variety so all the Victors are written as SPs.
760
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800761 ::frc971::wpilib::DrivetrainWriter drivetrain_writer(&event_loop);
Sabina Davisd004fd62019-02-02 23:51:46 -0800762 drivetrain_writer.set_left_controller0(
Sabina Davis1b84afa2019-02-09 01:20:21 -0800763 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(0)), true);
Sabina Davisd004fd62019-02-02 23:51:46 -0800764 drivetrain_writer.set_right_controller0(
Sabina Davis1b84afa2019-02-09 01:20:21 -0800765 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(1)), false);
Sabina Davisabeae332019-02-01 21:12:57 -0800766 ::std::thread drivetrain_writer_thread(::std::ref(drivetrain_writer));
767
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800768 SuperstructureWriter superstructure_writer(&event_loop);
Alex Perry5fb5ff22019-02-09 21:53:17 -0800769 superstructure_writer.set_elevator_victor(
Alex Perry5fb5ff22019-02-09 21:53:17 -0800770 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(4)));
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800771 // TODO(austin): Do the vacuum
Austin Schuh461e1182019-02-17 14:56:44 -0800772 superstructure_writer.set_suction_victor(
773 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(6)));
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800774 superstructure_writer.set_intake_victor(
775 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(2)));
Alex Perry5fb5ff22019-02-09 21:53:17 -0800776 superstructure_writer.set_wrist_victor(
777 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(5)));
778 superstructure_writer.set_stilts_victor(
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800779 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(3)));
Alex Perry5fb5ff22019-02-09 21:53:17 -0800780
781 ::std::thread superstructure_writer_thread(
782 ::std::ref(superstructure_writer));
783
Austin Schuhff973552019-05-19 16:49:28 -0700784 SolenoidWriter solenoid_writer(&solenoid_event_loop);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800785 solenoid_writer.set_intake_roller_talon(
786 make_unique<::ctre::phoenix::motorcontrol::can::TalonSRX>(10));
Austin Schuh461e1182019-02-17 14:56:44 -0800787 solenoid_writer.set_big_suction_cup(0, 1);
788 solenoid_writer.set_small_suction_cup(2, 3);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800789
790 ::std::thread solenoid_writer_thread(::std::ref(solenoid_writer));
791
Sabina Davisabeae332019-02-01 21:12:57 -0800792 // Wait forever. Not much else to do...
793 while (true) {
794 const int r = select(0, nullptr, nullptr, nullptr, nullptr);
795 if (r != 0) {
796 PLOG(WARNING, "infinite select failed");
797 } else {
798 PLOG(WARNING, "infinite select succeeded??\n");
799 }
800 }
801
802 LOG(ERROR, "Exiting WPILibRobot\n");
803
Austin Schuhc1d6f832019-02-15 23:22:17 -0800804 solenoid_writer.Quit();
805 solenoid_writer_thread.join();
Sabina Davisabeae332019-02-01 21:12:57 -0800806 joystick_sender.Quit();
807 joystick_thread.join();
808 pdp_fetcher.Quit();
809 pdp_fetcher_thread.join();
810 reader.Quit();
811 reader_thread.join();
812 imu.Quit();
813 imu_thread.join();
814
815 drivetrain_writer.Quit();
816 drivetrain_writer_thread.join();
Alex Perry5fb5ff22019-02-09 21:53:17 -0800817 superstructure_writer.Quit();
818 superstructure_writer_thread.join();
Sabina Davisabeae332019-02-01 21:12:57 -0800819
820 ::aos::Cleanup();
821 }
822};
823
824} // namespace
825} // namespace wpilib
826} // namespace y2019
827
828AOS_ROBOT_CLASS(::y2019::wpilib::WPILibRobot);