blob: 31b5158360189e42e242abfb18a3374c062c16cd [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;
Austin Schuhbd1fe9c2019-06-29 16:35:48 -070060using ::y2019::control_loops::superstructure::SuperstructureQueue;
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>(
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700137 ".frc971.autonomous.auto_mode")),
138 superstructure_position_sender_(
139 event_loop->MakeSender<SuperstructureQueue::Position>(
140 ".y2019.control_loops.superstructure.superstructure_queue."
141 "position")) {
Sabina Davisabeae332019-02-01 21:12:57 -0800142 // Set to filter out anything shorter than 1/4 of the minimum pulse width
143 // we should ever see.
Austin Schuh45a549f2019-02-02 15:43:56 -0800144 UpdateFastEncoderFilterHz(kMaxFastEncoderPulsesPerSecond);
145 UpdateMediumEncoderFilterHz(kMaxMediumEncoderPulsesPerSecond);
Sabina Davisabeae332019-02-01 21:12:57 -0800146 }
147
Alex Perry5fb5ff22019-02-09 21:53:17 -0800148 // Elevator
149
150 void set_elevator_encoder(::std::unique_ptr<frc::Encoder> encoder) {
151 medium_encoder_filter_.Add(encoder.get());
152 elevator_encoder_.set_encoder(::std::move(encoder));
153 }
154
155 void set_elevator_absolute_pwm(
156 ::std::unique_ptr<frc::DigitalInput> absolute_pwm) {
157 elevator_encoder_.set_absolute_pwm(::std::move(absolute_pwm));
158 }
159
160 void set_elevator_potentiometer(
161 ::std::unique_ptr<frc::AnalogInput> potentiometer) {
162 elevator_encoder_.set_potentiometer(::std::move(potentiometer));
163 }
164
165 // Intake
166
167 void set_intake_encoder(::std::unique_ptr<frc::Encoder> encoder) {
168 medium_encoder_filter_.Add(encoder.get());
169 intake_encoder_.set_encoder(::std::move(encoder));
170 }
171
172 void set_intake_absolute_pwm(
173 ::std::unique_ptr<frc::DigitalInput> absolute_pwm) {
174 intake_encoder_.set_absolute_pwm(::std::move(absolute_pwm));
175 }
176
177 // Wrist
178
179 void set_wrist_encoder(::std::unique_ptr<frc::Encoder> encoder) {
180 medium_encoder_filter_.Add(encoder.get());
181 wrist_encoder_.set_encoder(::std::move(encoder));
182 }
183
184 void set_wrist_absolute_pwm(
185 ::std::unique_ptr<frc::DigitalInput> absolute_pwm) {
186 wrist_encoder_.set_absolute_pwm(::std::move(absolute_pwm));
187 }
188
189 void set_wrist_potentiometer(
190 ::std::unique_ptr<frc::AnalogInput> potentiometer) {
191 wrist_encoder_.set_potentiometer(::std::move(potentiometer));
192 }
193
194 // Stilts
195
196 void set_stilts_encoder(::std::unique_ptr<frc::Encoder> encoder) {
197 medium_encoder_filter_.Add(encoder.get());
198 stilts_encoder_.set_encoder(::std::move(encoder));
199 }
200
201 void set_stilts_absolute_pwm(
202 ::std::unique_ptr<frc::DigitalInput> absolute_pwm) {
203 stilts_encoder_.set_absolute_pwm(::std::move(absolute_pwm));
204 }
205
206 void set_stilts_potentiometer(
207 ::std::unique_ptr<frc::AnalogInput> potentiometer) {
208 stilts_encoder_.set_potentiometer(::std::move(potentiometer));
209 }
210
Austin Schuhe2f22482019-04-13 23:05:43 -0700211 void set_platform_left_detect(
212 ::std::unique_ptr<frc::DigitalInput> platform_left_detect) {
213 platform_left_detect_ = ::std::move(platform_left_detect);
214 }
215
216 void set_platform_right_detect(
217 ::std::unique_ptr<frc::DigitalInput> platform_right_detect) {
218 platform_right_detect_ = ::std::move(platform_right_detect);
219 }
220
Austin Schuh461e1182019-02-17 14:56:44 -0800221 // Vacuum pressure sensor
222 void set_vacuum_sensor(int port) {
223 vacuum_sensor_ = make_unique<frc::AnalogInput>(port);
224 }
225
Austin Schuha9644062019-03-28 14:31:52 -0700226 // Auto mode switches.
227 void set_autonomous_mode(int i, ::std::unique_ptr<frc::DigitalInput> sensor) {
228 autonomous_modes_.at(i) = ::std::move(sensor);
229 }
230
Sabina Davis399dbd82019-02-01 23:06:08 -0800231 void RunIteration() override {
Sabina Davisabeae332019-02-01 21:12:57 -0800232 {
233 auto drivetrain_message = drivetrain_queue.position.MakeMessage();
234 drivetrain_message->left_encoder =
235 drivetrain_translate(drivetrain_left_encoder_->GetRaw());
236 drivetrain_message->left_speed =
237 drivetrain_velocity_translate(drivetrain_left_encoder_->GetPeriod());
238
239 drivetrain_message->right_encoder =
240 -drivetrain_translate(drivetrain_right_encoder_->GetRaw());
241 drivetrain_message->right_speed = -drivetrain_velocity_translate(
242 drivetrain_right_encoder_->GetPeriod());
243
244 drivetrain_message.Send();
245 }
Alex Perry5fb5ff22019-02-09 21:53:17 -0800246 const auto values = constants::GetValues();
247
248 {
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700249 auto superstructure_message =
250 superstructure_position_sender_.MakeMessage();
Alex Perry5fb5ff22019-02-09 21:53:17 -0800251
252 // Elevator
253 CopyPosition(elevator_encoder_, &superstructure_message->elevator,
254 Values::kElevatorEncoderCountsPerRevolution(),
255 Values::kElevatorEncoderRatio(), elevator_pot_translate,
256 false, values.elevator.potentiometer_offset);
257 // Intake
258 CopyPosition(intake_encoder_, &superstructure_message->intake_joint,
259 Values::kIntakeEncoderCountsPerRevolution(),
260 Values::kIntakeEncoderRatio(), false);
261
262 // Wrist
263 CopyPosition(wrist_encoder_, &superstructure_message->wrist,
264 Values::kWristEncoderCountsPerRevolution(),
265 Values::kWristEncoderRatio(), wrist_pot_translate, false,
266 values.wrist.potentiometer_offset);
267
268 // Stilts
269 CopyPosition(stilts_encoder_, &superstructure_message->stilts,
270 Values::kStiltsEncoderCountsPerRevolution(),
271 Values::kStiltsEncoderRatio(), stilts_pot_translate, false,
272 values.stilts.potentiometer_offset);
273
Austin Schuh461e1182019-02-17 14:56:44 -0800274 // Suction
275 constexpr float kMinVoltage = 0.5;
276 constexpr float kMaxVoltage = 2.1;
277 superstructure_message->suction_pressure =
278 (vacuum_sensor_->GetVoltage() - kMinVoltage) /
279 (kMaxVoltage - kMinVoltage);
280
Austin Schuhe2f22482019-04-13 23:05:43 -0700281 superstructure_message->platform_left_detect =
282 !platform_left_detect_->Get();
283 superstructure_message->platform_right_detect =
284 !platform_right_detect_->Get();
285
Alex Perry5fb5ff22019-02-09 21:53:17 -0800286 superstructure_message.Send();
287 }
Austin Schuha9644062019-03-28 14:31:52 -0700288
289 {
Austin Schuha250b2d2019-05-27 16:14:02 -0700290 auto auto_mode_message = auto_mode_sender_.MakeMessage();
Austin Schuha9644062019-03-28 14:31:52 -0700291 auto_mode_message->mode = 0;
292 for (size_t i = 0; i < autonomous_modes_.size(); ++i) {
293 if (autonomous_modes_[i] && autonomous_modes_[i]->Get()) {
294 auto_mode_message->mode |= 1 << i;
295 }
296 }
297 LOG_STRUCT(DEBUG, "auto mode", *auto_mode_message);
298 auto_mode_message.Send();
299 }
Alex Perry5fb5ff22019-02-09 21:53:17 -0800300 }
301
302 private:
Austin Schuha250b2d2019-05-27 16:14:02 -0700303 ::aos::Sender<::frc971::autonomous::AutonomousMode> auto_mode_sender_;
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700304 ::aos::Sender<SuperstructureQueue::Position> superstructure_position_sender_;
Austin Schuha250b2d2019-05-27 16:14:02 -0700305
Alex Perry5fb5ff22019-02-09 21:53:17 -0800306 ::frc971::wpilib::AbsoluteEncoderAndPotentiometer elevator_encoder_,
307 wrist_encoder_, stilts_encoder_;
308
Austin Schuhe2f22482019-04-13 23:05:43 -0700309 ::std::unique_ptr<frc::DigitalInput> platform_left_detect_;
310 ::std::unique_ptr<frc::DigitalInput> platform_right_detect_;
311
Austin Schuh461e1182019-02-17 14:56:44 -0800312 ::std::unique_ptr<frc::AnalogInput> vacuum_sensor_;
313
Austin Schuha9644062019-03-28 14:31:52 -0700314 ::std::array<::std::unique_ptr<frc::DigitalInput>, 2> autonomous_modes_;
315
Alex Perry5fb5ff22019-02-09 21:53:17 -0800316 ::frc971::wpilib::AbsoluteEncoder intake_encoder_;
317 // TODO(sabina): Add wrist and elevator hall effects.
318};
319
Brian Silvermanf8b75252019-02-24 16:13:58 -0800320class CameraReader {
321 public:
Austin Schuh8a633d52019-05-12 15:04:01 -0700322 CameraReader(::aos::EventLoop *event_loop)
323 : camera_frame_sender_(
324 event_loop
325 ->MakeSender<::y2019::control_loops::drivetrain::CameraFrame>(
Austin Schuh5671a8c2019-05-19 17:01:04 -0700326 ".y2019.control_loops.drivetrain.camera_frames")),
327 camera_log_fetcher_(
328 event_loop->MakeFetcher<::y2019::CameraLog>(".y2019.camera_log")) {}
Austin Schuh8a633d52019-05-12 15:04:01 -0700329
Brian Silvermanf8b75252019-02-24 16:13:58 -0800330 CameraReader(const CameraReader &) = delete;
331 CameraReader &operator=(const CameraReader &) = delete;
332
333 void set_spi(frc::SPI *spi) {
334 spi_ = spi;
335 spi_->SetClockRate(1e6);
336 spi_->SetChipSelectActiveHigh();
337 spi_->SetClockActiveLow();
338 spi_->SetSampleDataOnFalling();
339 // It ignores you if you try changing this...
340 spi_->SetMSBFirst();
341 }
342
Brian Silverman7ecf0672019-03-02 15:30:03 -0800343 void set_activate_usb(std::unique_ptr<frc::DigitalInput> activate_usb) {
344 activate_usb_ = std::move(activate_usb);
345 }
346
347 void set_activate_passthrough(
348 std::unique_ptr<frc::DigitalInput> activate_passthrough) {
349 activate_passthrough_ = std::move(activate_passthrough);
350 }
351
Brian Silvermanf8b75252019-02-24 16:13:58 -0800352 void DoSpiTransaction() {
353 using namespace frc971::jevois;
354 RoborioToTeensy to_teensy{};
355 to_teensy.realtime_now = aos::realtime_clock::now();
Austin Schuh5671a8c2019-05-19 17:01:04 -0700356 camera_log_fetcher_.Fetch();
Brian Silverman7ecf0672019-03-02 15:30:03 -0800357 if (activate_usb_ && !activate_usb_->Get()) {
358 to_teensy.camera_command = CameraCommand::kUsb;
359 } else if (activate_passthrough_ && !activate_passthrough_->Get()) {
360 to_teensy.camera_command = CameraCommand::kCameraPassthrough;
Austin Schuh5671a8c2019-05-19 17:01:04 -0700361 } else if (camera_log_fetcher_.get() && camera_log_fetcher_->log) {
Austin Schuh4e2629d2019-03-28 14:44:37 -0700362 to_teensy.camera_command = CameraCommand::kLog;
Brian Silverman7ecf0672019-03-02 15:30:03 -0800363 } else {
364 to_teensy.camera_command = CameraCommand::kNormal;
365 }
Brian Silvermanf8b75252019-02-24 16:13:58 -0800366
367 std::array<char, spi_transfer_size() + 1> to_send{};
368 {
369 const auto to_send_data =
370 gsl::make_span(to_send).last<spi_transfer_size()>();
371 const auto encoded = SpiPackToTeensy(to_teensy);
372 std::copy(encoded.begin(), encoded.end(), to_send_data.begin());
373 }
374 rx_clearer_.ClearRxFifo();
375 // First, send recieve a dummy byte because the Teensy can't control what it
376 // sends for the first byte.
377 std::array<char, spi_transfer_size() + 1> to_receive;
378 DoTransaction(to_send, to_receive);
379 const auto unpacked = SpiUnpackToRoborio(
380 gsl::make_span(to_receive).last(spi_transfer_size()));
381 if (!unpacked) {
382 LOG(INFO, "Decoding SPI data failed\n");
383 return;
384 }
385
Brian Silvermanc41fb862019-03-02 21:14:46 -0800386 const auto now = aos::monotonic_clock::now();
387 for (const auto &received : unpacked->frames) {
Austin Schuh8a633d52019-05-12 15:04:01 -0700388 auto to_send = camera_frame_sender_.MakeMessage();
James Kuszmaule08f04e2019-05-01 21:46:50 -0500389 // Add an extra 10ms delay to account for unmodeled delays that Austin
390 // thinks exists.
Brian Silvermanc41fb862019-03-02 21:14:46 -0800391 to_send->timestamp =
James Kuszmaule08f04e2019-05-01 21:46:50 -0500392 std::chrono::nanoseconds(
393 (now - received.age - ::std::chrono::milliseconds(10))
394 .time_since_epoch()).count();
Brian Silvermanc41fb862019-03-02 21:14:46 -0800395 to_send->num_targets = received.targets.size();
396 for (size_t i = 0; i < received.targets.size(); ++i) {
397 to_send->targets[i].distance = received.targets[i].distance;
398 to_send->targets[i].height = received.targets[i].height;
399 to_send->targets[i].heading = received.targets[i].heading;
400 to_send->targets[i].skew = received.targets[i].skew;
401 }
402 to_send->camera = received.camera_index;
Austin Schuhbb52eec2019-03-03 18:32:14 -0800403 LOG_STRUCT(DEBUG, "camera_frames", *to_send);
Brian Silvermanc41fb862019-03-02 21:14:46 -0800404 to_send.Send();
405 }
Brian Silvermanf8b75252019-02-24 16:13:58 -0800406
407 if (dummy_spi_) {
408 uint8_t dummy_send, dummy_receive;
409 dummy_spi_->Transaction(&dummy_send, &dummy_receive, 1);
410 }
411 }
412
413 void DoTransaction(gsl::span<char> to_send, gsl::span<char> to_receive) {
414 CHECK_EQ(to_send.size(), to_receive.size());
415 const auto result = spi_->Transaction(
416 reinterpret_cast<uint8_t *>(to_send.data()),
417 reinterpret_cast<uint8_t *>(to_receive.data()), to_send.size());
418 if (result == to_send.size()) {
419 return;
420 }
421 if (result == -1) {
422 LOG(INFO, "SPI::Transaction of %zd bytes failed\n", to_send.size());
423 return;
424 }
425 LOG(FATAL, "SPI::Transaction returned something weird\n");
426 }
427
428 void SetDummySPI(frc::SPI::Port port) {
429 dummy_spi_.reset(new frc::SPI(port));
430 // Pick the same settings here in case the roboRIO decides to try something
431 // stupid when switching.
432 if (dummy_spi_) {
433 dummy_spi_->SetClockRate(1e5);
434 dummy_spi_->SetChipSelectActiveLow();
435 dummy_spi_->SetClockActiveLow();
436 dummy_spi_->SetSampleDataOnFalling();
437 dummy_spi_->SetMSBFirst();
438 }
439 }
440
441 private:
Austin Schuh8a633d52019-05-12 15:04:01 -0700442 ::aos::Sender<::y2019::control_loops::drivetrain::CameraFrame>
443 camera_frame_sender_;
Austin Schuh5671a8c2019-05-19 17:01:04 -0700444 ::aos::Fetcher<::y2019::CameraLog> camera_log_fetcher_;
Austin Schuh8a633d52019-05-12 15:04:01 -0700445
Brian Silvermanf8b75252019-02-24 16:13:58 -0800446 frc::SPI *spi_ = nullptr;
447 ::std::unique_ptr<frc::SPI> dummy_spi_;
448
Brian Silverman7ecf0672019-03-02 15:30:03 -0800449 std::unique_ptr<frc::DigitalInput> activate_usb_;
450 std::unique_ptr<frc::DigitalInput> activate_passthrough_;
451
Brian Silvermanf8b75252019-02-24 16:13:58 -0800452 frc971::wpilib::SpiRxClearer rx_clearer_;
453};
454
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700455class SuperstructureWriter
456 : public ::frc971::wpilib::LoopOutputHandler<SuperstructureQueue::Output> {
Alex Perry5fb5ff22019-02-09 21:53:17 -0800457 public:
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800458 SuperstructureWriter(::aos::EventLoop *event_loop)
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700459 : ::frc971::wpilib::LoopOutputHandler<SuperstructureQueue::Output>(
460 event_loop,
461 ".y2019.control_loops.superstructure.superstructure_queue.output"),
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800462 robot_state_fetcher_(
463 event_loop->MakeFetcher<::aos::RobotState>(".aos.robot_state")) {}
464
Alex Perry5fb5ff22019-02-09 21:53:17 -0800465 void set_elevator_victor(::std::unique_ptr<::frc::VictorSP> t) {
466 elevator_victor_ = ::std::move(t);
467 }
468
Austin Schuh461e1182019-02-17 14:56:44 -0800469 void set_suction_victor(::std::unique_ptr<::frc::VictorSP> t) {
470 suction_victor_ = ::std::move(t);
471 }
472
Alex Perry5fb5ff22019-02-09 21:53:17 -0800473 void set_intake_victor(::std::unique_ptr<::frc::VictorSP> t) {
474 intake_victor_ = ::std::move(t);
475 }
Alex Perry5fb5ff22019-02-09 21:53:17 -0800476
477 void set_wrist_victor(::std::unique_ptr<::frc::VictorSP> t) {
478 wrist_victor_ = ::std::move(t);
479 }
480
481 void set_stilts_victor(::std::unique_ptr<::frc::VictorSP> t) {
482 stilts_victor_ = ::std::move(t);
483 }
484
485 private:
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700486 void Write(const SuperstructureQueue::Output &output) override {
487 LOG_STRUCT(DEBUG, "will output", output);
488 elevator_victor_->SetSpeed(::aos::Clip(output.elevator_voltage,
Alex Perry5fb5ff22019-02-09 21:53:17 -0800489 -kMaxBringupPower,
490 kMaxBringupPower) /
491 12.0);
492
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700493 intake_victor_->SetSpeed(::aos::Clip(output.intake_joint_voltage,
Alex Perry5fb5ff22019-02-09 21:53:17 -0800494 -kMaxBringupPower, kMaxBringupPower) /
495 12.0);
496
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700497 wrist_victor_->SetSpeed(::aos::Clip(-output.wrist_voltage,
Alex Perry5fb5ff22019-02-09 21:53:17 -0800498 -kMaxBringupPower, kMaxBringupPower) /
499 12.0);
500
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700501 stilts_victor_->SetSpeed(::aos::Clip(output.stilts_voltage,
Alex Perry5fb5ff22019-02-09 21:53:17 -0800502 -kMaxBringupPower, kMaxBringupPower) /
503 12.0);
Austin Schuh461e1182019-02-17 14:56:44 -0800504
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800505 robot_state_fetcher_.Fetch();
506 const double battery_voltage = robot_state_fetcher_.get()
507 ? robot_state_fetcher_->voltage_battery
508 : 12.0;
Austin Schuhc2ee66b2019-02-19 13:37:46 -0800509
510 // Throw a fast low pass filter on the battery voltage so we don't respond
511 // too fast to noise.
512 filtered_battery_voltage_ =
513 0.5 * filtered_battery_voltage_ + 0.5 * battery_voltage;
514
515 suction_victor_->SetSpeed(::aos::Clip(
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700516 output.pump_voltage / filtered_battery_voltage_, -1.0, 1.0));
Alex Perry5fb5ff22019-02-09 21:53:17 -0800517 }
518
Austin Schuh461e1182019-02-17 14:56:44 -0800519 void Stop() override {
Alex Perry5fb5ff22019-02-09 21:53:17 -0800520 LOG(WARNING, "Superstructure output too old.\n");
521
522 elevator_victor_->SetDisabled();
523 intake_victor_->SetDisabled();
Alex Perry5fb5ff22019-02-09 21:53:17 -0800524 wrist_victor_->SetDisabled();
525 stilts_victor_->SetDisabled();
Austin Schuh461e1182019-02-17 14:56:44 -0800526 suction_victor_->SetDisabled();
Alex Perry5fb5ff22019-02-09 21:53:17 -0800527 }
528
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800529 ::aos::Fetcher<::aos::RobotState> robot_state_fetcher_;
530
Alex Perry5fb5ff22019-02-09 21:53:17 -0800531 ::std::unique_ptr<::frc::VictorSP> elevator_victor_, intake_victor_,
Austin Schuh461e1182019-02-17 14:56:44 -0800532 wrist_victor_, stilts_victor_, suction_victor_;
Austin Schuhc2ee66b2019-02-19 13:37:46 -0800533
534 double filtered_battery_voltage_ = 12.0;
Sabina Davisabeae332019-02-01 21:12:57 -0800535};
536
Austin Schuhc1d6f832019-02-15 23:22:17 -0800537class SolenoidWriter {
538 public:
Austin Schuhff973552019-05-19 16:49:28 -0700539 SolenoidWriter(::aos::EventLoop *event_loop)
540 : event_loop_(event_loop),
541 superstructure_fetcher_(event_loop->MakeFetcher<
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700542 SuperstructureQueue::Output>(
Austin Schuhff973552019-05-19 16:49:28 -0700543 ".y2019.control_loops.superstructure.superstructure_queue.output")),
544 status_light_fetcher_(event_loop->MakeFetcher<::y2019::StatusLight>(
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700545 ".y2019.status_light")) {
546 ::aos::SetCurrentThreadName("Solenoids");
547 ::aos::SetCurrentThreadRealtimePriority(27);
548
549 event_loop_->AddPhasedLoop([this](int iterations) { Loop(iterations); },
550 ::std::chrono::milliseconds(20),
551 ::std::chrono::milliseconds(1));
552 }
Austin Schuhc1d6f832019-02-15 23:22:17 -0800553
Austin Schuh461e1182019-02-17 14:56:44 -0800554 void set_big_suction_cup(int index0, int index1) {
555 big_suction_cup0_ = pcm_.MakeSolenoid(index0);
556 big_suction_cup1_ = pcm_.MakeSolenoid(index1);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800557 }
Austin Schuh461e1182019-02-17 14:56:44 -0800558 void set_small_suction_cup(int index0, int index1) {
559 small_suction_cup0_ = pcm_.MakeSolenoid(index0);
560 small_suction_cup1_ = pcm_.MakeSolenoid(index1);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800561 }
562
563 void set_intake_roller_talon(
564 ::std::unique_ptr<::ctre::phoenix::motorcontrol::can::TalonSRX> t) {
565 intake_rollers_talon_ = ::std::move(t);
Austin Schuh23a51632019-02-19 16:50:36 -0800566 intake_rollers_talon_->ConfigContinuousCurrentLimit(10.0, 0);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800567 intake_rollers_talon_->EnableCurrentLimit(true);
568 }
569
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700570 void Loop(const int iterations) {
571 if (iterations != 1) {
572 LOG(DEBUG, "Solenoids skipped %d iterations\n", iterations - 1);
573 }
Austin Schuhc1d6f832019-02-15 23:22:17 -0800574
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700575 {
576 superstructure_fetcher_.Fetch();
577 if (superstructure_fetcher_.get()) {
578 LOG_STRUCT(DEBUG, "solenoids", *superstructure_fetcher_);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800579
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700580 big_suction_cup0_->Set(!superstructure_fetcher_->intake_suction_bottom);
581 big_suction_cup1_->Set(!superstructure_fetcher_->intake_suction_bottom);
582 small_suction_cup0_->Set(superstructure_fetcher_->intake_suction_top);
583 small_suction_cup1_->Set(superstructure_fetcher_->intake_suction_top);
584
585 intake_rollers_talon_->Set(
586 ctre::phoenix::motorcontrol::ControlMode::PercentOutput,
587 ::aos::Clip(superstructure_fetcher_->intake_roller_voltage,
588 -kMaxBringupPower, kMaxBringupPower) /
589 12.0);
590 }
591 }
592
593 {
594 ::frc971::wpilib::PneumaticsToLog to_log;
595
596 pcm_.Flush();
597 to_log.read_solenoids = pcm_.GetAll();
598 LOG_STRUCT(DEBUG, "pneumatics info", to_log);
599 }
600
601 status_light_fetcher_.Fetch();
602 // If we don't have a light request (or it's an old one), we are borked.
603 // Flash the red light slowly.
604 if (!status_light_fetcher_.get() ||
605 status_light_fetcher_.get()->sent_time + chrono::milliseconds(100) <
606 event_loop_->monotonic_now()) {
607 StatusLight color;
608 color.red = 0.0;
609 color.green = 0.0;
610 color.blue = 0.0;
611
612 ++light_flash_;
613 if (light_flash_ > 10) {
614 color.red = 0.5;
Austin Schuhc1d6f832019-02-15 23:22:17 -0800615 }
616
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700617 if (light_flash_ > 20) {
618 light_flash_ = 0;
Austin Schuhc1d6f832019-02-15 23:22:17 -0800619 }
620
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700621 LOG_STRUCT(DEBUG, "color", color);
622 SetColor(color);
623 } else {
624 LOG_STRUCT(DEBUG, "color", *status_light_fetcher_.get());
625 SetColor(*status_light_fetcher_.get());
Sabina Davisc6329342019-03-01 20:44:42 -0800626 }
627 }
628
629 void SetColor(const StatusLight &status_light) {
630 // Save CAN bandwidth and CPU at the cost of RT. Only change the light when
631 // it actually changes. This is pretty low priority anyways.
632 static int time_since_last_send = 0;
633 ++time_since_last_send;
634 if (time_since_last_send > 10) {
635 time_since_last_send = 0;
636 }
637 if (status_light.green != last_green_ || time_since_last_send == 0) {
Sabina Davis77a11cf2019-03-09 18:20:26 -0800638 canifier_.SetLEDOutput(status_light.green,
639 ::ctre::phoenix::CANifier::LEDChannelA);
Sabina Davisc6329342019-03-01 20:44:42 -0800640 last_green_ = status_light.green;
641 }
642
643 if (status_light.blue != last_blue_ || time_since_last_send == 0) {
Sabina Davis77a11cf2019-03-09 18:20:26 -0800644 canifier_.SetLEDOutput(status_light.blue,
645 ::ctre::phoenix::CANifier::LEDChannelC);
Sabina Davisc6329342019-03-01 20:44:42 -0800646 last_blue_ = status_light.blue;
647 }
648
649 if (status_light.red != last_red_ || time_since_last_send == 0) {
Sabina Davis77a11cf2019-03-09 18:20:26 -0800650 canifier_.SetLEDOutput(status_light.red,
651 ::ctre::phoenix::CANifier::LEDChannelB);
Sabina Davisc6329342019-03-01 20:44:42 -0800652 last_red_ = status_light.red;
Austin Schuhc1d6f832019-02-15 23:22:17 -0800653 }
654 }
655
Austin Schuhc1d6f832019-02-15 23:22:17 -0800656 private:
Austin Schuhff973552019-05-19 16:49:28 -0700657 ::aos::EventLoop *event_loop_;
658
Austin Schuhc1d6f832019-02-15 23:22:17 -0800659 ::frc971::wpilib::BufferedPcm pcm_;
660
Austin Schuh461e1182019-02-17 14:56:44 -0800661 ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> big_suction_cup0_,
662 big_suction_cup1_, small_suction_cup0_, small_suction_cup1_;
Austin Schuhc1d6f832019-02-15 23:22:17 -0800663
664 ::std::unique_ptr<::ctre::phoenix::motorcontrol::can::TalonSRX>
665 intake_rollers_talon_;
666
Austin Schuhff973552019-05-19 16:49:28 -0700667 ::aos::Fetcher<
Austin Schuhc1d6f832019-02-15 23:22:17 -0800668 ::y2019::control_loops::superstructure::SuperstructureQueue::Output>
Austin Schuhff973552019-05-19 16:49:28 -0700669 superstructure_fetcher_;
670 ::aos::Fetcher<::y2019::StatusLight> status_light_fetcher_;
Austin Schuhc1d6f832019-02-15 23:22:17 -0800671
Sabina Davisc6329342019-03-01 20:44:42 -0800672 ::ctre::phoenix::CANifier canifier_{0};
673
Sabina Davisc6329342019-03-01 20:44:42 -0800674 double last_red_ = -1.0;
675 double last_green_ = -1.0;
676 double last_blue_ = -1.0;
677
678 int light_flash_ = 0;
Austin Schuhc1d6f832019-02-15 23:22:17 -0800679};
680
Sabina Davisabeae332019-02-01 21:12:57 -0800681class WPILibRobot : public ::frc971::wpilib::WPILibRobotBase {
682 public:
683 ::std::unique_ptr<frc::Encoder> make_encoder(int index) {
684 return make_unique<frc::Encoder>(10 + index * 2, 11 + index * 2, false,
685 frc::Encoder::k4X);
686 }
687
688 void Run() override {
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700689 // Thread 1.
690 ::aos::ShmEventLoop joystick_sender_event_loop;
691 ::frc971::wpilib::JoystickSender joystick_sender(
692 &joystick_sender_event_loop);
693 AddLoop(&joystick_sender_event_loop);
Sabina Davisabeae332019-02-01 21:12:57 -0800694
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700695 // Thread 2.
696 ::aos::ShmEventLoop pdp_fetcher_event_loop;
697 ::frc971::wpilib::PDPFetcher pdp_fetcher(&pdp_fetcher_event_loop);
698 AddLoop(&pdp_fetcher_event_loop);
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800699
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700700 // Thread 3.
701 ::aos::ShmEventLoop sensor_reader_event_loop;
702 SensorReader sensor_reader(&sensor_reader_event_loop);
703 sensor_reader.set_drivetrain_left_encoder(make_encoder(0));
704 sensor_reader.set_drivetrain_right_encoder(make_encoder(1));
Sabina Davisabeae332019-02-01 21:12:57 -0800705
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700706 sensor_reader.set_elevator_encoder(make_encoder(4));
707 sensor_reader.set_elevator_absolute_pwm(make_unique<frc::DigitalInput>(4));
708 sensor_reader.set_elevator_potentiometer(make_unique<frc::AnalogInput>(4));
Sabina Davisabeae332019-02-01 21:12:57 -0800709
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700710 sensor_reader.set_wrist_encoder(make_encoder(5));
711 sensor_reader.set_wrist_absolute_pwm(make_unique<frc::DigitalInput>(5));
712 sensor_reader.set_wrist_potentiometer(make_unique<frc::AnalogInput>(5));
Sabina Davisabeae332019-02-01 21:12:57 -0800713
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700714 sensor_reader.set_intake_encoder(make_encoder(2));
715 sensor_reader.set_intake_absolute_pwm(make_unique<frc::DigitalInput>(2));
Alex Perry5fb5ff22019-02-09 21:53:17 -0800716
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700717 sensor_reader.set_stilts_encoder(make_encoder(3));
718 sensor_reader.set_stilts_absolute_pwm(make_unique<frc::DigitalInput>(3));
719 sensor_reader.set_stilts_potentiometer(make_unique<frc::AnalogInput>(3));
Alex Perry5fb5ff22019-02-09 21:53:17 -0800720
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700721 sensor_reader.set_pwm_trigger(true);
722 sensor_reader.set_vacuum_sensor(7);
Alex Perry5fb5ff22019-02-09 21:53:17 -0800723
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700724 sensor_reader.set_platform_right_detect(make_unique<frc::DigitalInput>(6));
725 sensor_reader.set_platform_left_detect(make_unique<frc::DigitalInput>(7));
Alex Perry5fb5ff22019-02-09 21:53:17 -0800726
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700727 sensor_reader.set_autonomous_mode(0, make_unique<frc::DigitalInput>(22));
728 sensor_reader.set_autonomous_mode(0, make_unique<frc::DigitalInput>(23));
729 AddLoop(&sensor_reader_event_loop);
Sabina Davisabeae332019-02-01 21:12:57 -0800730
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700731 // Thread 4.
732 ::aos::ShmEventLoop imu_event_loop;
733 CameraReader camera_reader(&imu_event_loop);
Brian Silvermanf8b75252019-02-24 16:13:58 -0800734 frc::SPI camera_spi(frc::SPI::Port::kOnboardCS3);
735 camera_reader.set_spi(&camera_spi);
736 camera_reader.SetDummySPI(frc::SPI::Port::kOnboardCS2);
Brian Silverman7ecf0672019-03-02 15:30:03 -0800737 // Austin says 8, 9, 24, and 25 are good options to choose from for these.
738 camera_reader.set_activate_usb(make_unique<frc::DigitalInput>(24));
739 camera_reader.set_activate_passthrough(make_unique<frc::DigitalInput>(25));
Brian Silvermanf8b75252019-02-24 16:13:58 -0800740
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800741 auto imu_trigger = make_unique<frc::DigitalInput>(0);
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700742 ::frc971::wpilib::ADIS16448 imu(&imu_event_loop, frc::SPI::Port::kOnboardCS1,
Sabina Davisabeae332019-02-01 21:12:57 -0800743 imu_trigger.get());
Brian Silvermanf8b75252019-02-24 16:13:58 -0800744 imu.set_spi_idle_callback(
745 [&camera_reader]() { camera_reader.DoSpiTransaction(); });
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800746 auto imu_reset = make_unique<frc::DigitalOutput>(1);
Sabina Davisabeae332019-02-01 21:12:57 -0800747 imu.set_reset(imu_reset.get());
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700748 AddLoop(&imu_event_loop);
Sabina Davisabeae332019-02-01 21:12:57 -0800749
750 // While as of 2/9/18 the drivetrain Victors are SPX, it appears as though
751 // they are identical, as far as DrivetrainWriter is concerned, to the SP
752 // variety so all the Victors are written as SPs.
753
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700754 // Thread 5.
755 ::aos::ShmEventLoop output_event_loop;
756 ::frc971::wpilib::DrivetrainWriter drivetrain_writer(&output_event_loop);
Sabina Davisd004fd62019-02-02 23:51:46 -0800757 drivetrain_writer.set_left_controller0(
Sabina Davis1b84afa2019-02-09 01:20:21 -0800758 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(0)), true);
Sabina Davisd004fd62019-02-02 23:51:46 -0800759 drivetrain_writer.set_right_controller0(
Sabina Davis1b84afa2019-02-09 01:20:21 -0800760 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(1)), false);
Sabina Davisabeae332019-02-01 21:12:57 -0800761
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700762 SuperstructureWriter superstructure_writer(&output_event_loop);
Alex Perry5fb5ff22019-02-09 21:53:17 -0800763 superstructure_writer.set_elevator_victor(
Alex Perry5fb5ff22019-02-09 21:53:17 -0800764 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(4)));
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800765 // TODO(austin): Do the vacuum
Austin Schuh461e1182019-02-17 14:56:44 -0800766 superstructure_writer.set_suction_victor(
767 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(6)));
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800768 superstructure_writer.set_intake_victor(
769 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(2)));
Alex Perry5fb5ff22019-02-09 21:53:17 -0800770 superstructure_writer.set_wrist_victor(
771 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(5)));
772 superstructure_writer.set_stilts_victor(
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800773 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(3)));
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700774 AddLoop(&output_event_loop);
Alex Perry5fb5ff22019-02-09 21:53:17 -0800775
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700776 // Thread 6.
777 ::aos::ShmEventLoop solenoid_writer_event_loop;
778 SolenoidWriter solenoid_writer(&solenoid_writer_event_loop);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800779 solenoid_writer.set_intake_roller_talon(
780 make_unique<::ctre::phoenix::motorcontrol::can::TalonSRX>(10));
Austin Schuh461e1182019-02-17 14:56:44 -0800781 solenoid_writer.set_big_suction_cup(0, 1);
782 solenoid_writer.set_small_suction_cup(2, 3);
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700783 AddLoop(&solenoid_writer_event_loop);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800784
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700785 RunLoops();
Sabina Davisabeae332019-02-01 21:12:57 -0800786 }
787};
788
789} // namespace
790} // namespace wpilib
791} // namespace y2019
792
793AOS_ROBOT_CLASS(::y2019::wpilib::WPILibRobot);