blob: 9ca37d8c889bc46cc1a9b7d8f777f3fad1423fea [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
Austin Schuhbd1fe9c2019-06-29 16:35:48 -070059using ::y2019::control_loops::superstructure::SuperstructureQueue;
Sabina Davis7be49f32019-02-02 00:30:19 -080060using ::y2019::constants::Values;
Sabina Davisabeae332019-02-01 21:12:57 -080061using ::aos::monotonic_clock;
62namespace chrono = ::std::chrono;
63using aos::make_unique;
64
65namespace y2019 {
66namespace wpilib {
67namespace {
68
69constexpr double kMaxBringupPower = 12.0;
70
71// TODO(Brian): Fix the interpretation of the result of GetRaw here and in the
72// DMA stuff and then removing the * 2.0 in *_translate.
73// The low bit is direction.
74
75// TODO(brian): Use ::std::max instead once we have C++14 so that can be
76// constexpr.
77template <typename T>
78constexpr T max(T a, T b) {
79 return (a > b) ? a : b;
80}
81
82template <typename T, typename... Rest>
83constexpr T max(T a, T b, T c, Rest... rest) {
84 return max(max(a, b), c, rest...);
85}
86
87double drivetrain_translate(int32_t in) {
Sabina Davis7be49f32019-02-02 00:30:19 -080088 return ((static_cast<double>(in) /
89 Values::kDrivetrainEncoderCountsPerRevolution()) *
Sabina Davisabeae332019-02-01 21:12:57 -080090 (2.0 * M_PI)) *
91 Values::kDrivetrainEncoderRatio() *
Sabina Davis7be49f32019-02-02 00:30:19 -080092 control_loops::drivetrain::kWheelRadius;
Sabina Davisabeae332019-02-01 21:12:57 -080093}
94
95double drivetrain_velocity_translate(double in) {
Sabina Davis7be49f32019-02-02 00:30:19 -080096 return (((1.0 / in) / Values::kDrivetrainCyclesPerRevolution()) *
Sabina Davisabeae332019-02-01 21:12:57 -080097 (2.0 * M_PI)) *
98 Values::kDrivetrainEncoderRatio() *
Sabina Davis7be49f32019-02-02 00:30:19 -080099 control_loops::drivetrain::kWheelRadius;
Sabina Davisabeae332019-02-01 21:12:57 -0800100}
101
Alex Perry5fb5ff22019-02-09 21:53:17 -0800102double elevator_pot_translate(double voltage) {
103 return voltage * Values::kElevatorPotRatio() *
Austin Schuhed7f8632019-02-15 23:12:20 -0800104 (10.0 /*turns*/ / 5.0 /*volts*/) * (2 * M_PI /*radians*/);
Alex Perry5fb5ff22019-02-09 21:53:17 -0800105}
106
107double wrist_pot_translate(double voltage) {
Austin Schuhed7f8632019-02-15 23:12:20 -0800108 return voltage * Values::kWristPotRatio() * (5.0 /*turns*/ / 5.0 /*volts*/) *
Alex Perry5fb5ff22019-02-09 21:53:17 -0800109 (2 * M_PI /*radians*/);
110}
111
112double stilts_pot_translate(double voltage) {
113 return voltage * Values::kStiltsPotRatio() *
114 (10.0 /*turns*/ / 5.0 /*volts*/) * (2 * M_PI /*radians*/);
115}
116
Sabina Davisabeae332019-02-01 21:12:57 -0800117constexpr double kMaxFastEncoderPulsesPerSecond =
Alex Perry5fb5ff22019-02-09 21:53:17 -0800118 max(Values::kMaxDrivetrainEncoderPulsesPerSecond(),
119 Values::kMaxIntakeEncoderPulsesPerSecond());
Sabina Davisabeae332019-02-01 21:12:57 -0800120static_assert(kMaxFastEncoderPulsesPerSecond <= 1300000,
121 "fast encoders are too fast");
Sabina Davisabeae332019-02-01 21:12:57 -0800122constexpr double kMaxMediumEncoderPulsesPerSecond =
Alex Perry5fb5ff22019-02-09 21:53:17 -0800123 max(Values::kMaxElevatorEncoderPulsesPerSecond(),
124 Values::kMaxWristEncoderPulsesPerSecond());
Theo Bafrali00e42272019-02-12 01:07:46 -0800125
Sabina Davisabeae332019-02-01 21:12:57 -0800126static_assert(kMaxMediumEncoderPulsesPerSecond <= 400000,
127 "medium encoders are too fast");
128
129// Class to send position messages with sensor readings to our loops.
Sabina Davisadc58542019-02-01 22:23:00 -0800130class SensorReader : public ::frc971::wpilib::SensorReader {
Sabina Davisabeae332019-02-01 21:12:57 -0800131 public:
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800132 SensorReader(::aos::EventLoop *event_loop)
Austin Schuha250b2d2019-05-27 16:14:02 -0700133 : ::frc971::wpilib::SensorReader(event_loop),
134 auto_mode_sender_(
135 event_loop->MakeSender<::frc971::autonomous::AutonomousMode>(
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700136 ".frc971.autonomous.auto_mode")),
137 superstructure_position_sender_(
138 event_loop->MakeSender<SuperstructureQueue::Position>(
139 ".y2019.control_loops.superstructure.superstructure_queue."
Austin Schuhbd0a40f2019-06-30 14:56:31 -0700140 "position")),
141 drivetrain_position_sender_(
142 event_loop->MakeSender<
143 ::frc971::control_loops::DrivetrainQueue::Position>(
144 ".frc971.control_loops.drivetrain_queue.position")) {
Sabina Davisabeae332019-02-01 21:12:57 -0800145 // Set to filter out anything shorter than 1/4 of the minimum pulse width
146 // we should ever see.
Austin Schuh45a549f2019-02-02 15:43:56 -0800147 UpdateFastEncoderFilterHz(kMaxFastEncoderPulsesPerSecond);
148 UpdateMediumEncoderFilterHz(kMaxMediumEncoderPulsesPerSecond);
Sabina Davisabeae332019-02-01 21:12:57 -0800149 }
150
Alex Perry5fb5ff22019-02-09 21:53:17 -0800151 // Elevator
152
153 void set_elevator_encoder(::std::unique_ptr<frc::Encoder> encoder) {
154 medium_encoder_filter_.Add(encoder.get());
155 elevator_encoder_.set_encoder(::std::move(encoder));
156 }
157
158 void set_elevator_absolute_pwm(
159 ::std::unique_ptr<frc::DigitalInput> absolute_pwm) {
160 elevator_encoder_.set_absolute_pwm(::std::move(absolute_pwm));
161 }
162
163 void set_elevator_potentiometer(
164 ::std::unique_ptr<frc::AnalogInput> potentiometer) {
165 elevator_encoder_.set_potentiometer(::std::move(potentiometer));
166 }
167
168 // Intake
169
170 void set_intake_encoder(::std::unique_ptr<frc::Encoder> encoder) {
171 medium_encoder_filter_.Add(encoder.get());
172 intake_encoder_.set_encoder(::std::move(encoder));
173 }
174
175 void set_intake_absolute_pwm(
176 ::std::unique_ptr<frc::DigitalInput> absolute_pwm) {
177 intake_encoder_.set_absolute_pwm(::std::move(absolute_pwm));
178 }
179
180 // Wrist
181
182 void set_wrist_encoder(::std::unique_ptr<frc::Encoder> encoder) {
183 medium_encoder_filter_.Add(encoder.get());
184 wrist_encoder_.set_encoder(::std::move(encoder));
185 }
186
187 void set_wrist_absolute_pwm(
188 ::std::unique_ptr<frc::DigitalInput> absolute_pwm) {
189 wrist_encoder_.set_absolute_pwm(::std::move(absolute_pwm));
190 }
191
192 void set_wrist_potentiometer(
193 ::std::unique_ptr<frc::AnalogInput> potentiometer) {
194 wrist_encoder_.set_potentiometer(::std::move(potentiometer));
195 }
196
197 // Stilts
198
199 void set_stilts_encoder(::std::unique_ptr<frc::Encoder> encoder) {
200 medium_encoder_filter_.Add(encoder.get());
201 stilts_encoder_.set_encoder(::std::move(encoder));
202 }
203
204 void set_stilts_absolute_pwm(
205 ::std::unique_ptr<frc::DigitalInput> absolute_pwm) {
206 stilts_encoder_.set_absolute_pwm(::std::move(absolute_pwm));
207 }
208
209 void set_stilts_potentiometer(
210 ::std::unique_ptr<frc::AnalogInput> potentiometer) {
211 stilts_encoder_.set_potentiometer(::std::move(potentiometer));
212 }
213
Austin Schuhe2f22482019-04-13 23:05:43 -0700214 void set_platform_left_detect(
215 ::std::unique_ptr<frc::DigitalInput> platform_left_detect) {
216 platform_left_detect_ = ::std::move(platform_left_detect);
217 }
218
219 void set_platform_right_detect(
220 ::std::unique_ptr<frc::DigitalInput> platform_right_detect) {
221 platform_right_detect_ = ::std::move(platform_right_detect);
222 }
223
Austin Schuh461e1182019-02-17 14:56:44 -0800224 // Vacuum pressure sensor
225 void set_vacuum_sensor(int port) {
226 vacuum_sensor_ = make_unique<frc::AnalogInput>(port);
227 }
228
Austin Schuha9644062019-03-28 14:31:52 -0700229 // Auto mode switches.
230 void set_autonomous_mode(int i, ::std::unique_ptr<frc::DigitalInput> sensor) {
231 autonomous_modes_.at(i) = ::std::move(sensor);
232 }
233
Sabina Davis399dbd82019-02-01 23:06:08 -0800234 void RunIteration() override {
Sabina Davisabeae332019-02-01 21:12:57 -0800235 {
Austin Schuhbd0a40f2019-06-30 14:56:31 -0700236 auto drivetrain_message = drivetrain_position_sender_.MakeMessage();
Sabina Davisabeae332019-02-01 21:12:57 -0800237 drivetrain_message->left_encoder =
238 drivetrain_translate(drivetrain_left_encoder_->GetRaw());
239 drivetrain_message->left_speed =
240 drivetrain_velocity_translate(drivetrain_left_encoder_->GetPeriod());
241
242 drivetrain_message->right_encoder =
243 -drivetrain_translate(drivetrain_right_encoder_->GetRaw());
244 drivetrain_message->right_speed = -drivetrain_velocity_translate(
245 drivetrain_right_encoder_->GetPeriod());
246
247 drivetrain_message.Send();
248 }
Alex Perry5fb5ff22019-02-09 21:53:17 -0800249 const auto values = constants::GetValues();
250
251 {
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700252 auto superstructure_message =
253 superstructure_position_sender_.MakeMessage();
Alex Perry5fb5ff22019-02-09 21:53:17 -0800254
255 // Elevator
256 CopyPosition(elevator_encoder_, &superstructure_message->elevator,
257 Values::kElevatorEncoderCountsPerRevolution(),
258 Values::kElevatorEncoderRatio(), elevator_pot_translate,
259 false, values.elevator.potentiometer_offset);
260 // Intake
261 CopyPosition(intake_encoder_, &superstructure_message->intake_joint,
262 Values::kIntakeEncoderCountsPerRevolution(),
263 Values::kIntakeEncoderRatio(), false);
264
265 // Wrist
266 CopyPosition(wrist_encoder_, &superstructure_message->wrist,
267 Values::kWristEncoderCountsPerRevolution(),
268 Values::kWristEncoderRatio(), wrist_pot_translate, false,
269 values.wrist.potentiometer_offset);
270
271 // Stilts
272 CopyPosition(stilts_encoder_, &superstructure_message->stilts,
273 Values::kStiltsEncoderCountsPerRevolution(),
274 Values::kStiltsEncoderRatio(), stilts_pot_translate, false,
275 values.stilts.potentiometer_offset);
276
Austin Schuh461e1182019-02-17 14:56:44 -0800277 // Suction
278 constexpr float kMinVoltage = 0.5;
279 constexpr float kMaxVoltage = 2.1;
280 superstructure_message->suction_pressure =
281 (vacuum_sensor_->GetVoltage() - kMinVoltage) /
282 (kMaxVoltage - kMinVoltage);
283
Austin Schuhe2f22482019-04-13 23:05:43 -0700284 superstructure_message->platform_left_detect =
285 !platform_left_detect_->Get();
286 superstructure_message->platform_right_detect =
287 !platform_right_detect_->Get();
288
Alex Perry5fb5ff22019-02-09 21:53:17 -0800289 superstructure_message.Send();
290 }
Austin Schuha9644062019-03-28 14:31:52 -0700291
292 {
Austin Schuha250b2d2019-05-27 16:14:02 -0700293 auto auto_mode_message = auto_mode_sender_.MakeMessage();
Austin Schuha9644062019-03-28 14:31:52 -0700294 auto_mode_message->mode = 0;
295 for (size_t i = 0; i < autonomous_modes_.size(); ++i) {
296 if (autonomous_modes_[i] && autonomous_modes_[i]->Get()) {
297 auto_mode_message->mode |= 1 << i;
298 }
299 }
300 LOG_STRUCT(DEBUG, "auto mode", *auto_mode_message);
301 auto_mode_message.Send();
302 }
Alex Perry5fb5ff22019-02-09 21:53:17 -0800303 }
304
305 private:
Austin Schuha250b2d2019-05-27 16:14:02 -0700306 ::aos::Sender<::frc971::autonomous::AutonomousMode> auto_mode_sender_;
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700307 ::aos::Sender<SuperstructureQueue::Position> superstructure_position_sender_;
Austin Schuhbd0a40f2019-06-30 14:56:31 -0700308 ::aos::Sender<::frc971::control_loops::DrivetrainQueue::Position>
309 drivetrain_position_sender_;
Austin Schuha250b2d2019-05-27 16:14:02 -0700310
Alex Perry5fb5ff22019-02-09 21:53:17 -0800311 ::frc971::wpilib::AbsoluteEncoderAndPotentiometer elevator_encoder_,
312 wrist_encoder_, stilts_encoder_;
313
Austin Schuhe2f22482019-04-13 23:05:43 -0700314 ::std::unique_ptr<frc::DigitalInput> platform_left_detect_;
315 ::std::unique_ptr<frc::DigitalInput> platform_right_detect_;
316
Austin Schuh461e1182019-02-17 14:56:44 -0800317 ::std::unique_ptr<frc::AnalogInput> vacuum_sensor_;
318
Austin Schuha9644062019-03-28 14:31:52 -0700319 ::std::array<::std::unique_ptr<frc::DigitalInput>, 2> autonomous_modes_;
320
Alex Perry5fb5ff22019-02-09 21:53:17 -0800321 ::frc971::wpilib::AbsoluteEncoder intake_encoder_;
322 // TODO(sabina): Add wrist and elevator hall effects.
323};
324
Brian Silvermanf8b75252019-02-24 16:13:58 -0800325class CameraReader {
326 public:
Austin Schuh8a633d52019-05-12 15:04:01 -0700327 CameraReader(::aos::EventLoop *event_loop)
328 : camera_frame_sender_(
329 event_loop
330 ->MakeSender<::y2019::control_loops::drivetrain::CameraFrame>(
Austin Schuh5671a8c2019-05-19 17:01:04 -0700331 ".y2019.control_loops.drivetrain.camera_frames")),
332 camera_log_fetcher_(
333 event_loop->MakeFetcher<::y2019::CameraLog>(".y2019.camera_log")) {}
Austin Schuh8a633d52019-05-12 15:04:01 -0700334
Brian Silvermanf8b75252019-02-24 16:13:58 -0800335 CameraReader(const CameraReader &) = delete;
336 CameraReader &operator=(const CameraReader &) = delete;
337
338 void set_spi(frc::SPI *spi) {
339 spi_ = spi;
340 spi_->SetClockRate(1e6);
341 spi_->SetChipSelectActiveHigh();
342 spi_->SetClockActiveLow();
343 spi_->SetSampleDataOnFalling();
344 // It ignores you if you try changing this...
345 spi_->SetMSBFirst();
346 }
347
Brian Silverman7ecf0672019-03-02 15:30:03 -0800348 void set_activate_usb(std::unique_ptr<frc::DigitalInput> activate_usb) {
349 activate_usb_ = std::move(activate_usb);
350 }
351
352 void set_activate_passthrough(
353 std::unique_ptr<frc::DigitalInput> activate_passthrough) {
354 activate_passthrough_ = std::move(activate_passthrough);
355 }
356
Brian Silvermanf8b75252019-02-24 16:13:58 -0800357 void DoSpiTransaction() {
358 using namespace frc971::jevois;
359 RoborioToTeensy to_teensy{};
360 to_teensy.realtime_now = aos::realtime_clock::now();
Austin Schuh5671a8c2019-05-19 17:01:04 -0700361 camera_log_fetcher_.Fetch();
Brian Silverman7ecf0672019-03-02 15:30:03 -0800362 if (activate_usb_ && !activate_usb_->Get()) {
363 to_teensy.camera_command = CameraCommand::kUsb;
364 } else if (activate_passthrough_ && !activate_passthrough_->Get()) {
365 to_teensy.camera_command = CameraCommand::kCameraPassthrough;
Austin Schuh5671a8c2019-05-19 17:01:04 -0700366 } else if (camera_log_fetcher_.get() && camera_log_fetcher_->log) {
Austin Schuh4e2629d2019-03-28 14:44:37 -0700367 to_teensy.camera_command = CameraCommand::kLog;
Brian Silverman7ecf0672019-03-02 15:30:03 -0800368 } else {
369 to_teensy.camera_command = CameraCommand::kNormal;
370 }
Brian Silvermanf8b75252019-02-24 16:13:58 -0800371
372 std::array<char, spi_transfer_size() + 1> to_send{};
373 {
374 const auto to_send_data =
375 gsl::make_span(to_send).last<spi_transfer_size()>();
376 const auto encoded = SpiPackToTeensy(to_teensy);
377 std::copy(encoded.begin(), encoded.end(), to_send_data.begin());
378 }
379 rx_clearer_.ClearRxFifo();
380 // First, send recieve a dummy byte because the Teensy can't control what it
381 // sends for the first byte.
382 std::array<char, spi_transfer_size() + 1> to_receive;
383 DoTransaction(to_send, to_receive);
384 const auto unpacked = SpiUnpackToRoborio(
385 gsl::make_span(to_receive).last(spi_transfer_size()));
386 if (!unpacked) {
387 LOG(INFO, "Decoding SPI data failed\n");
388 return;
389 }
390
Brian Silvermanc41fb862019-03-02 21:14:46 -0800391 const auto now = aos::monotonic_clock::now();
392 for (const auto &received : unpacked->frames) {
Austin Schuh8a633d52019-05-12 15:04:01 -0700393 auto to_send = camera_frame_sender_.MakeMessage();
James Kuszmaule08f04e2019-05-01 21:46:50 -0500394 // Add an extra 10ms delay to account for unmodeled delays that Austin
395 // thinks exists.
Brian Silvermanc41fb862019-03-02 21:14:46 -0800396 to_send->timestamp =
James Kuszmaule08f04e2019-05-01 21:46:50 -0500397 std::chrono::nanoseconds(
398 (now - received.age - ::std::chrono::milliseconds(10))
399 .time_since_epoch()).count();
Brian Silvermanc41fb862019-03-02 21:14:46 -0800400 to_send->num_targets = received.targets.size();
401 for (size_t i = 0; i < received.targets.size(); ++i) {
402 to_send->targets[i].distance = received.targets[i].distance;
403 to_send->targets[i].height = received.targets[i].height;
404 to_send->targets[i].heading = received.targets[i].heading;
405 to_send->targets[i].skew = received.targets[i].skew;
406 }
407 to_send->camera = received.camera_index;
Austin Schuhbb52eec2019-03-03 18:32:14 -0800408 LOG_STRUCT(DEBUG, "camera_frames", *to_send);
Brian Silvermanc41fb862019-03-02 21:14:46 -0800409 to_send.Send();
410 }
Brian Silvermanf8b75252019-02-24 16:13:58 -0800411
412 if (dummy_spi_) {
413 uint8_t dummy_send, dummy_receive;
414 dummy_spi_->Transaction(&dummy_send, &dummy_receive, 1);
415 }
416 }
417
418 void DoTransaction(gsl::span<char> to_send, gsl::span<char> to_receive) {
419 CHECK_EQ(to_send.size(), to_receive.size());
420 const auto result = spi_->Transaction(
421 reinterpret_cast<uint8_t *>(to_send.data()),
422 reinterpret_cast<uint8_t *>(to_receive.data()), to_send.size());
423 if (result == to_send.size()) {
424 return;
425 }
426 if (result == -1) {
427 LOG(INFO, "SPI::Transaction of %zd bytes failed\n", to_send.size());
428 return;
429 }
430 LOG(FATAL, "SPI::Transaction returned something weird\n");
431 }
432
433 void SetDummySPI(frc::SPI::Port port) {
434 dummy_spi_.reset(new frc::SPI(port));
435 // Pick the same settings here in case the roboRIO decides to try something
436 // stupid when switching.
437 if (dummy_spi_) {
438 dummy_spi_->SetClockRate(1e5);
439 dummy_spi_->SetChipSelectActiveLow();
440 dummy_spi_->SetClockActiveLow();
441 dummy_spi_->SetSampleDataOnFalling();
442 dummy_spi_->SetMSBFirst();
443 }
444 }
445
446 private:
Austin Schuh8a633d52019-05-12 15:04:01 -0700447 ::aos::Sender<::y2019::control_loops::drivetrain::CameraFrame>
448 camera_frame_sender_;
Austin Schuh5671a8c2019-05-19 17:01:04 -0700449 ::aos::Fetcher<::y2019::CameraLog> camera_log_fetcher_;
Austin Schuh8a633d52019-05-12 15:04:01 -0700450
Brian Silvermanf8b75252019-02-24 16:13:58 -0800451 frc::SPI *spi_ = nullptr;
452 ::std::unique_ptr<frc::SPI> dummy_spi_;
453
Brian Silverman7ecf0672019-03-02 15:30:03 -0800454 std::unique_ptr<frc::DigitalInput> activate_usb_;
455 std::unique_ptr<frc::DigitalInput> activate_passthrough_;
456
Brian Silvermanf8b75252019-02-24 16:13:58 -0800457 frc971::wpilib::SpiRxClearer rx_clearer_;
458};
459
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700460class SuperstructureWriter
461 : public ::frc971::wpilib::LoopOutputHandler<SuperstructureQueue::Output> {
Alex Perry5fb5ff22019-02-09 21:53:17 -0800462 public:
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800463 SuperstructureWriter(::aos::EventLoop *event_loop)
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700464 : ::frc971::wpilib::LoopOutputHandler<SuperstructureQueue::Output>(
465 event_loop,
466 ".y2019.control_loops.superstructure.superstructure_queue.output"),
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800467 robot_state_fetcher_(
468 event_loop->MakeFetcher<::aos::RobotState>(".aos.robot_state")) {}
469
Alex Perry5fb5ff22019-02-09 21:53:17 -0800470 void set_elevator_victor(::std::unique_ptr<::frc::VictorSP> t) {
471 elevator_victor_ = ::std::move(t);
472 }
473
Austin Schuh461e1182019-02-17 14:56:44 -0800474 void set_suction_victor(::std::unique_ptr<::frc::VictorSP> t) {
475 suction_victor_ = ::std::move(t);
476 }
477
Alex Perry5fb5ff22019-02-09 21:53:17 -0800478 void set_intake_victor(::std::unique_ptr<::frc::VictorSP> t) {
479 intake_victor_ = ::std::move(t);
480 }
Alex Perry5fb5ff22019-02-09 21:53:17 -0800481
482 void set_wrist_victor(::std::unique_ptr<::frc::VictorSP> t) {
483 wrist_victor_ = ::std::move(t);
484 }
485
486 void set_stilts_victor(::std::unique_ptr<::frc::VictorSP> t) {
487 stilts_victor_ = ::std::move(t);
488 }
489
490 private:
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700491 void Write(const SuperstructureQueue::Output &output) override {
492 LOG_STRUCT(DEBUG, "will output", output);
493 elevator_victor_->SetSpeed(::aos::Clip(output.elevator_voltage,
Alex Perry5fb5ff22019-02-09 21:53:17 -0800494 -kMaxBringupPower,
495 kMaxBringupPower) /
496 12.0);
497
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700498 intake_victor_->SetSpeed(::aos::Clip(output.intake_joint_voltage,
Alex Perry5fb5ff22019-02-09 21:53:17 -0800499 -kMaxBringupPower, kMaxBringupPower) /
500 12.0);
501
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700502 wrist_victor_->SetSpeed(::aos::Clip(-output.wrist_voltage,
Alex Perry5fb5ff22019-02-09 21:53:17 -0800503 -kMaxBringupPower, kMaxBringupPower) /
504 12.0);
505
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700506 stilts_victor_->SetSpeed(::aos::Clip(output.stilts_voltage,
Alex Perry5fb5ff22019-02-09 21:53:17 -0800507 -kMaxBringupPower, kMaxBringupPower) /
508 12.0);
Austin Schuh461e1182019-02-17 14:56:44 -0800509
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800510 robot_state_fetcher_.Fetch();
511 const double battery_voltage = robot_state_fetcher_.get()
512 ? robot_state_fetcher_->voltage_battery
513 : 12.0;
Austin Schuhc2ee66b2019-02-19 13:37:46 -0800514
515 // Throw a fast low pass filter on the battery voltage so we don't respond
516 // too fast to noise.
517 filtered_battery_voltage_ =
518 0.5 * filtered_battery_voltage_ + 0.5 * battery_voltage;
519
520 suction_victor_->SetSpeed(::aos::Clip(
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700521 output.pump_voltage / filtered_battery_voltage_, -1.0, 1.0));
Alex Perry5fb5ff22019-02-09 21:53:17 -0800522 }
523
Austin Schuh461e1182019-02-17 14:56:44 -0800524 void Stop() override {
Alex Perry5fb5ff22019-02-09 21:53:17 -0800525 LOG(WARNING, "Superstructure output too old.\n");
526
527 elevator_victor_->SetDisabled();
528 intake_victor_->SetDisabled();
Alex Perry5fb5ff22019-02-09 21:53:17 -0800529 wrist_victor_->SetDisabled();
530 stilts_victor_->SetDisabled();
Austin Schuh461e1182019-02-17 14:56:44 -0800531 suction_victor_->SetDisabled();
Alex Perry5fb5ff22019-02-09 21:53:17 -0800532 }
533
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800534 ::aos::Fetcher<::aos::RobotState> robot_state_fetcher_;
535
Alex Perry5fb5ff22019-02-09 21:53:17 -0800536 ::std::unique_ptr<::frc::VictorSP> elevator_victor_, intake_victor_,
Austin Schuh461e1182019-02-17 14:56:44 -0800537 wrist_victor_, stilts_victor_, suction_victor_;
Austin Schuhc2ee66b2019-02-19 13:37:46 -0800538
539 double filtered_battery_voltage_ = 12.0;
Sabina Davisabeae332019-02-01 21:12:57 -0800540};
541
Austin Schuhc1d6f832019-02-15 23:22:17 -0800542class SolenoidWriter {
543 public:
Austin Schuhff973552019-05-19 16:49:28 -0700544 SolenoidWriter(::aos::EventLoop *event_loop)
545 : event_loop_(event_loop),
546 superstructure_fetcher_(event_loop->MakeFetcher<
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700547 SuperstructureQueue::Output>(
Austin Schuhff973552019-05-19 16:49:28 -0700548 ".y2019.control_loops.superstructure.superstructure_queue.output")),
549 status_light_fetcher_(event_loop->MakeFetcher<::y2019::StatusLight>(
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700550 ".y2019.status_light")) {
551 ::aos::SetCurrentThreadName("Solenoids");
552 ::aos::SetCurrentThreadRealtimePriority(27);
553
554 event_loop_->AddPhasedLoop([this](int iterations) { Loop(iterations); },
555 ::std::chrono::milliseconds(20),
556 ::std::chrono::milliseconds(1));
557 }
Austin Schuhc1d6f832019-02-15 23:22:17 -0800558
Austin Schuh461e1182019-02-17 14:56:44 -0800559 void set_big_suction_cup(int index0, int index1) {
560 big_suction_cup0_ = pcm_.MakeSolenoid(index0);
561 big_suction_cup1_ = pcm_.MakeSolenoid(index1);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800562 }
Austin Schuh461e1182019-02-17 14:56:44 -0800563 void set_small_suction_cup(int index0, int index1) {
564 small_suction_cup0_ = pcm_.MakeSolenoid(index0);
565 small_suction_cup1_ = pcm_.MakeSolenoid(index1);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800566 }
567
568 void set_intake_roller_talon(
569 ::std::unique_ptr<::ctre::phoenix::motorcontrol::can::TalonSRX> t) {
570 intake_rollers_talon_ = ::std::move(t);
Austin Schuh23a51632019-02-19 16:50:36 -0800571 intake_rollers_talon_->ConfigContinuousCurrentLimit(10.0, 0);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800572 intake_rollers_talon_->EnableCurrentLimit(true);
573 }
574
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700575 void Loop(const int iterations) {
576 if (iterations != 1) {
577 LOG(DEBUG, "Solenoids skipped %d iterations\n", iterations - 1);
578 }
Austin Schuhc1d6f832019-02-15 23:22:17 -0800579
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700580 {
581 superstructure_fetcher_.Fetch();
582 if (superstructure_fetcher_.get()) {
583 LOG_STRUCT(DEBUG, "solenoids", *superstructure_fetcher_);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800584
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700585 big_suction_cup0_->Set(!superstructure_fetcher_->intake_suction_bottom);
586 big_suction_cup1_->Set(!superstructure_fetcher_->intake_suction_bottom);
587 small_suction_cup0_->Set(superstructure_fetcher_->intake_suction_top);
588 small_suction_cup1_->Set(superstructure_fetcher_->intake_suction_top);
589
590 intake_rollers_talon_->Set(
591 ctre::phoenix::motorcontrol::ControlMode::PercentOutput,
592 ::aos::Clip(superstructure_fetcher_->intake_roller_voltage,
593 -kMaxBringupPower, kMaxBringupPower) /
594 12.0);
595 }
596 }
597
598 {
599 ::frc971::wpilib::PneumaticsToLog to_log;
600
601 pcm_.Flush();
602 to_log.read_solenoids = pcm_.GetAll();
603 LOG_STRUCT(DEBUG, "pneumatics info", to_log);
604 }
605
606 status_light_fetcher_.Fetch();
607 // If we don't have a light request (or it's an old one), we are borked.
608 // Flash the red light slowly.
609 if (!status_light_fetcher_.get() ||
610 status_light_fetcher_.get()->sent_time + chrono::milliseconds(100) <
611 event_loop_->monotonic_now()) {
612 StatusLight color;
613 color.red = 0.0;
614 color.green = 0.0;
615 color.blue = 0.0;
616
617 ++light_flash_;
618 if (light_flash_ > 10) {
619 color.red = 0.5;
Austin Schuhc1d6f832019-02-15 23:22:17 -0800620 }
621
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700622 if (light_flash_ > 20) {
623 light_flash_ = 0;
Austin Schuhc1d6f832019-02-15 23:22:17 -0800624 }
625
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700626 LOG_STRUCT(DEBUG, "color", color);
627 SetColor(color);
628 } else {
629 LOG_STRUCT(DEBUG, "color", *status_light_fetcher_.get());
630 SetColor(*status_light_fetcher_.get());
Sabina Davisc6329342019-03-01 20:44:42 -0800631 }
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
Austin Schuhc1d6f832019-02-15 23:22:17 -0800661 private:
Austin Schuhff973552019-05-19 16:49:28 -0700662 ::aos::EventLoop *event_loop_;
663
Austin Schuhc1d6f832019-02-15 23:22:17 -0800664 ::frc971::wpilib::BufferedPcm pcm_;
665
Austin Schuh461e1182019-02-17 14:56:44 -0800666 ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> big_suction_cup0_,
667 big_suction_cup1_, small_suction_cup0_, small_suction_cup1_;
Austin Schuhc1d6f832019-02-15 23:22:17 -0800668
669 ::std::unique_ptr<::ctre::phoenix::motorcontrol::can::TalonSRX>
670 intake_rollers_talon_;
671
Austin Schuhff973552019-05-19 16:49:28 -0700672 ::aos::Fetcher<
Austin Schuhc1d6f832019-02-15 23:22:17 -0800673 ::y2019::control_loops::superstructure::SuperstructureQueue::Output>
Austin Schuhff973552019-05-19 16:49:28 -0700674 superstructure_fetcher_;
675 ::aos::Fetcher<::y2019::StatusLight> status_light_fetcher_;
Austin Schuhc1d6f832019-02-15 23:22:17 -0800676
Sabina Davisc6329342019-03-01 20:44:42 -0800677 ::ctre::phoenix::CANifier canifier_{0};
678
Sabina Davisc6329342019-03-01 20:44:42 -0800679 double last_red_ = -1.0;
680 double last_green_ = -1.0;
681 double last_blue_ = -1.0;
682
683 int light_flash_ = 0;
Austin Schuhc1d6f832019-02-15 23:22:17 -0800684};
685
Sabina Davisabeae332019-02-01 21:12:57 -0800686class WPILibRobot : public ::frc971::wpilib::WPILibRobotBase {
687 public:
688 ::std::unique_ptr<frc::Encoder> make_encoder(int index) {
689 return make_unique<frc::Encoder>(10 + index * 2, 11 + index * 2, false,
690 frc::Encoder::k4X);
691 }
692
693 void Run() override {
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700694 // Thread 1.
695 ::aos::ShmEventLoop joystick_sender_event_loop;
696 ::frc971::wpilib::JoystickSender joystick_sender(
697 &joystick_sender_event_loop);
698 AddLoop(&joystick_sender_event_loop);
Sabina Davisabeae332019-02-01 21:12:57 -0800699
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700700 // Thread 2.
701 ::aos::ShmEventLoop pdp_fetcher_event_loop;
702 ::frc971::wpilib::PDPFetcher pdp_fetcher(&pdp_fetcher_event_loop);
703 AddLoop(&pdp_fetcher_event_loop);
Austin Schuhdf6cbb12019-02-02 13:46:52 -0800704
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700705 // Thread 3.
706 ::aos::ShmEventLoop sensor_reader_event_loop;
707 SensorReader sensor_reader(&sensor_reader_event_loop);
708 sensor_reader.set_drivetrain_left_encoder(make_encoder(0));
709 sensor_reader.set_drivetrain_right_encoder(make_encoder(1));
Sabina Davisabeae332019-02-01 21:12:57 -0800710
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700711 sensor_reader.set_elevator_encoder(make_encoder(4));
712 sensor_reader.set_elevator_absolute_pwm(make_unique<frc::DigitalInput>(4));
713 sensor_reader.set_elevator_potentiometer(make_unique<frc::AnalogInput>(4));
Sabina Davisabeae332019-02-01 21:12:57 -0800714
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700715 sensor_reader.set_wrist_encoder(make_encoder(5));
716 sensor_reader.set_wrist_absolute_pwm(make_unique<frc::DigitalInput>(5));
717 sensor_reader.set_wrist_potentiometer(make_unique<frc::AnalogInput>(5));
Sabina Davisabeae332019-02-01 21:12:57 -0800718
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700719 sensor_reader.set_intake_encoder(make_encoder(2));
720 sensor_reader.set_intake_absolute_pwm(make_unique<frc::DigitalInput>(2));
Alex Perry5fb5ff22019-02-09 21:53:17 -0800721
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700722 sensor_reader.set_stilts_encoder(make_encoder(3));
723 sensor_reader.set_stilts_absolute_pwm(make_unique<frc::DigitalInput>(3));
724 sensor_reader.set_stilts_potentiometer(make_unique<frc::AnalogInput>(3));
Alex Perry5fb5ff22019-02-09 21:53:17 -0800725
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700726 sensor_reader.set_pwm_trigger(true);
727 sensor_reader.set_vacuum_sensor(7);
Alex Perry5fb5ff22019-02-09 21:53:17 -0800728
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700729 sensor_reader.set_platform_right_detect(make_unique<frc::DigitalInput>(6));
730 sensor_reader.set_platform_left_detect(make_unique<frc::DigitalInput>(7));
Alex Perry5fb5ff22019-02-09 21:53:17 -0800731
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700732 sensor_reader.set_autonomous_mode(0, make_unique<frc::DigitalInput>(22));
733 sensor_reader.set_autonomous_mode(0, make_unique<frc::DigitalInput>(23));
734 AddLoop(&sensor_reader_event_loop);
Sabina Davisabeae332019-02-01 21:12:57 -0800735
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700736 // Thread 4.
737 ::aos::ShmEventLoop imu_event_loop;
738 CameraReader camera_reader(&imu_event_loop);
Brian Silvermanf8b75252019-02-24 16:13:58 -0800739 frc::SPI camera_spi(frc::SPI::Port::kOnboardCS3);
740 camera_reader.set_spi(&camera_spi);
741 camera_reader.SetDummySPI(frc::SPI::Port::kOnboardCS2);
Brian Silverman7ecf0672019-03-02 15:30:03 -0800742 // Austin says 8, 9, 24, and 25 are good options to choose from for these.
743 camera_reader.set_activate_usb(make_unique<frc::DigitalInput>(24));
744 camera_reader.set_activate_passthrough(make_unique<frc::DigitalInput>(25));
Brian Silvermanf8b75252019-02-24 16:13:58 -0800745
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800746 auto imu_trigger = make_unique<frc::DigitalInput>(0);
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700747 ::frc971::wpilib::ADIS16448 imu(&imu_event_loop, frc::SPI::Port::kOnboardCS1,
Sabina Davisabeae332019-02-01 21:12:57 -0800748 imu_trigger.get());
Brian Silvermanf8b75252019-02-24 16:13:58 -0800749 imu.set_spi_idle_callback(
750 [&camera_reader]() { camera_reader.DoSpiTransaction(); });
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800751 auto imu_reset = make_unique<frc::DigitalOutput>(1);
Sabina Davisabeae332019-02-01 21:12:57 -0800752 imu.set_reset(imu_reset.get());
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700753 AddLoop(&imu_event_loop);
Sabina Davisabeae332019-02-01 21:12:57 -0800754
755 // While as of 2/9/18 the drivetrain Victors are SPX, it appears as though
756 // they are identical, as far as DrivetrainWriter is concerned, to the SP
757 // variety so all the Victors are written as SPs.
758
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700759 // Thread 5.
760 ::aos::ShmEventLoop output_event_loop;
761 ::frc971::wpilib::DrivetrainWriter drivetrain_writer(&output_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
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700767 SuperstructureWriter superstructure_writer(&output_event_loop);
Alex Perry5fb5ff22019-02-09 21:53:17 -0800768 superstructure_writer.set_elevator_victor(
Alex Perry5fb5ff22019-02-09 21:53:17 -0800769 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(4)));
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800770 // TODO(austin): Do the vacuum
Austin Schuh461e1182019-02-17 14:56:44 -0800771 superstructure_writer.set_suction_victor(
772 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(6)));
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800773 superstructure_writer.set_intake_victor(
774 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(2)));
Alex Perry5fb5ff22019-02-09 21:53:17 -0800775 superstructure_writer.set_wrist_victor(
776 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(5)));
777 superstructure_writer.set_stilts_victor(
Austin Schuh3e3d4ba2019-02-15 23:14:52 -0800778 ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(3)));
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700779 AddLoop(&output_event_loop);
Alex Perry5fb5ff22019-02-09 21:53:17 -0800780
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700781 // Thread 6.
782 ::aos::ShmEventLoop solenoid_writer_event_loop;
783 SolenoidWriter solenoid_writer(&solenoid_writer_event_loop);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800784 solenoid_writer.set_intake_roller_talon(
785 make_unique<::ctre::phoenix::motorcontrol::can::TalonSRX>(10));
Austin Schuh461e1182019-02-17 14:56:44 -0800786 solenoid_writer.set_big_suction_cup(0, 1);
787 solenoid_writer.set_small_suction_cup(2, 3);
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700788 AddLoop(&solenoid_writer_event_loop);
Austin Schuhc1d6f832019-02-15 23:22:17 -0800789
Austin Schuhbd1fe9c2019-06-29 16:35:48 -0700790 RunLoops();
Sabina Davisabeae332019-02-01 21:12:57 -0800791 }
792};
793
794} // namespace
795} // namespace wpilib
796} // namespace y2019
797
798AOS_ROBOT_CLASS(::y2019::wpilib::WPILibRobot);