blob: acf820f179fb8b62e6ef2cb389523562305aa0cf [file] [log] [blame]
Comran Morshed9a9948c2016-01-16 15:58:04 +00001#include <stdio.h>
2#include <string.h>
3#include <unistd.h>
4#include <inttypes.h>
5
6#include <thread>
7#include <mutex>
8#include <functional>
Brian Silverman68cb5c22016-03-20 18:11:14 -07009#include <array>
Comran Morshed9a9948c2016-01-16 15:58:04 +000010
11#include "Encoder.h"
12#include "Talon.h"
Austin Schuh8b89d332016-03-24 20:19:12 -070013#include "Relay.h"
Comran Morshed9a9948c2016-01-16 15:58:04 +000014#include "DriverStation.h"
15#include "AnalogInput.h"
16#include "Compressor.h"
Comran Morshed9a9948c2016-01-16 15:58:04 +000017#include "frc971/wpilib/wpilib_robot_base.h"
Comran Morshed9a9948c2016-01-16 15:58:04 +000018#ifndef WPILIB2015
19#include "DigitalGlitchFilter.h"
20#endif
21#undef ERROR
22
23#include "aos/common/logging/logging.h"
24#include "aos/common/logging/queue_logging.h"
25#include "aos/common/time.h"
26#include "aos/common/util/log_interval.h"
27#include "aos/common/util/phased_loop.h"
28#include "aos/common/util/wrapping_counter.h"
29#include "aos/common/stl_mutex.h"
30#include "aos/linux_code/init.h"
31#include "aos/common/messages/robot_state.q.h"
Austin Schuhcaa1ee92016-02-27 14:45:37 -080032#include "aos/common/commonmath.h"
Comran Morshed9a9948c2016-01-16 15:58:04 +000033
Comran Morshed225f0b92016-02-10 20:34:27 +000034#include "frc971/control_loops/control_loops.q.h"
Comran Morshed9a9948c2016-01-16 15:58:04 +000035#include "frc971/control_loops/drivetrain/drivetrain.q.h"
Comran Morshedb79c4242016-02-06 18:27:26 +000036#include "y2016/control_loops/shooter/shooter.q.h"
Comran Morshed6c6a0a92016-01-17 12:45:16 +000037#include "y2016/constants.h"
Comran Morshed5bb12112016-02-16 13:48:57 +000038#include "y2016/control_loops/drivetrain/drivetrain_dog_motor_plant.h"
Comran Morshed225f0b92016-02-10 20:34:27 +000039#include "y2016/control_loops/shooter/shooter.q.h"
40#include "y2016/control_loops/superstructure/superstructure.q.h"
Comran Morshedaa0573c2016-03-05 19:05:54 +000041#include "y2016/queues/ball_detector.q.h"
Brian Silverman68cb5c22016-03-20 18:11:14 -070042#include "y2016/actors/autonomous_action.q.h"
Comran Morshed9a9948c2016-01-16 15:58:04 +000043
44#include "frc971/wpilib/joystick_sender.h"
45#include "frc971/wpilib/loop_output_handler.h"
46#include "frc971/wpilib/buffered_solenoid.h"
47#include "frc971/wpilib/buffered_pcm.h"
48#include "frc971/wpilib/gyro_sender.h"
49#include "frc971/wpilib/dma_edge_counting.h"
50#include "frc971/wpilib/interrupt_edge_counting.h"
51#include "frc971/wpilib/encoder_and_potentiometer.h"
52#include "frc971/wpilib/logging.q.h"
53#include "frc971/wpilib/wpilib_interface.h"
54#include "frc971/wpilib/pdp_fetcher.h"
Brian Silverman5f17a972016-02-28 01:49:32 -050055#include "frc971/wpilib/ADIS16448.h"
Brian Silvermanb5b46ca2016-03-13 01:14:17 -050056#include "frc971/wpilib/dma.h"
Comran Morshed9a9948c2016-01-16 15:58:04 +000057
58#ifndef M_PI
59#define M_PI 3.14159265358979323846
60#endif
61
62using ::frc971::control_loops::drivetrain_queue;
Comran Morshed225f0b92016-02-10 20:34:27 +000063using ::y2016::control_loops::shooter::shooter_queue;
64using ::y2016::control_loops::superstructure_queue;
Comran Morshed9a9948c2016-01-16 15:58:04 +000065
Comran Morshed6c6a0a92016-01-17 12:45:16 +000066namespace y2016 {
Comran Morshed9a9948c2016-01-16 15:58:04 +000067namespace wpilib {
Austin Schuha9992ff2016-02-28 21:59:23 -080068namespace {
69constexpr double kMaxBringupPower = 12.0;
70} // namespace
Comran Morshed9a9948c2016-01-16 15:58:04 +000071
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): Replace this with ::std::make_unique once all our toolchains
77// have support.
78template <class T, class... U>
79std::unique_ptr<T> make_unique(U &&... u) {
80 return std::unique_ptr<T>(new T(std::forward<U>(u)...));
81}
82
Comran Morshed225f0b92016-02-10 20:34:27 +000083// Translates for the sensor values to convert raw index pulses into something
84// with proper units.
85
86// TODO(comran): Template these methods since there is a lot of repetition here.
87double hall_translate(double in) {
88 // Turn voltage from our 3-state halls into a ratio that the loop can use.
89 return in / 5.0;
90}
91
Comran Morshed9a9948c2016-01-16 15:58:04 +000092double drivetrain_translate(int32_t in) {
Comran Morshed6c6a0a92016-01-17 12:45:16 +000093 return -static_cast<double>(in) / (256.0 /*cpr*/ * 4.0 /*4x*/) *
Comran Morshed225f0b92016-02-10 20:34:27 +000094 constants::Values::kDrivetrainEncoderRatio *
Austin Schuh9f77fd22016-02-21 02:53:58 -080095 control_loops::drivetrain::kWheelRadius * 2.0 * M_PI;
Comran Morshed9a9948c2016-01-16 15:58:04 +000096}
97
98double drivetrain_velocity_translate(double in) {
99 return (1.0 / in) / 256.0 /*cpr*/ *
Comran Morshed225f0b92016-02-10 20:34:27 +0000100 constants::Values::kDrivetrainEncoderRatio *
Austin Schuh9f77fd22016-02-21 02:53:58 -0800101 control_loops::drivetrain::kWheelRadius * 2.0 * M_PI;
Comran Morshed9a9948c2016-01-16 15:58:04 +0000102}
103
Comran Morshed225f0b92016-02-10 20:34:27 +0000104double shooter_translate(int32_t in) {
Comran Morshed5bb12112016-02-16 13:48:57 +0000105 return -static_cast<double>(in) / (128.0 /*cpr*/ * 4.0 /*4x*/) *
Comran Morshed225f0b92016-02-10 20:34:27 +0000106 constants::Values::kShooterEncoderRatio * (2 * M_PI /*radians*/);
107}
Comran Morshed9a9948c2016-01-16 15:58:04 +0000108
Comran Morshed225f0b92016-02-10 20:34:27 +0000109double intake_translate(int32_t in) {
Austin Schuh9f77fd22016-02-21 02:53:58 -0800110 return static_cast<double>(in) / (512.0 /*cpr*/ * 4.0 /*4x*/) *
Comran Morshed225f0b92016-02-10 20:34:27 +0000111 constants::Values::kIntakeEncoderRatio * (2 * M_PI /*radians*/);
112}
113
114double shoulder_translate(int32_t in) {
115 return -static_cast<double>(in) / (512.0 /*cpr*/ * 4.0 /*4x*/) *
116 constants::Values::kShoulderEncoderRatio * (2 * M_PI /*radians*/);
117}
118
119double wrist_translate(int32_t in) {
120 return -static_cast<double>(in) / (512.0 /*cpr*/ * 4.0 /*4x*/) *
121 constants::Values::kWristEncoderRatio * (2 * M_PI /*radians*/);
122}
123
124double intake_pot_translate(double voltage) {
125 return voltage * constants::Values::kIntakePotRatio *
Comran Morshed5bb12112016-02-16 13:48:57 +0000126 (10.0 /*turns*/ / 5.0 /*volts*/) * (2 * M_PI /*radians*/);
Comran Morshed225f0b92016-02-10 20:34:27 +0000127}
128
129double shoulder_pot_translate(double voltage) {
130 return voltage * constants::Values::kShoulderPotRatio *
Comran Morshed5bb12112016-02-16 13:48:57 +0000131 (3.0 /*turns*/ / 5.0 /*volts*/) * (2 * M_PI /*radians*/);
Comran Morshed225f0b92016-02-10 20:34:27 +0000132}
133
134double wrist_pot_translate(double voltage) {
135 return voltage * constants::Values::kWristPotRatio *
Comran Morshed5bb12112016-02-16 13:48:57 +0000136 (3.0 /*turns*/ / 5.0 /*volts*/) * (2 * M_PI /*radians*/);
Comran Morshed9a9948c2016-01-16 15:58:04 +0000137}
138
Comran Morshed1b764322016-02-14 20:18:12 +0000139constexpr double kMaxDrivetrainEncoderPulsesPerSecond =
140 5600.0 /* CIM free speed RPM */ * 14.0 / 48.0 /* 1st reduction */ * 28.0 /
141 50.0 /* 2nd reduction (high gear) */ * 30.0 / 44.0 /* encoder gears */ /
142 60.0 /* seconds per minute */ * 256.0 /* CPR */ * 4 /* edges per cycle */;
143
144constexpr double kMaxShooterEncoderPulsesPerSecond =
145 18700.0 /* 775pro free speed RPM */ * 12.0 /
146 18.0 /* motor to encoder reduction */ / 60.0 /* seconds per minute */ *
147 128.0 /* CPR */ * 4 /* edges per cycle */;
148
149double kMaxDrivetrainShooterEncoderPulsesPerSecond = ::std::max(
150 kMaxDrivetrainEncoderPulsesPerSecond, kMaxShooterEncoderPulsesPerSecond);
151
152constexpr double kMaxSuperstructureEncoderPulsesPerSecond =
153 18700.0 /* 775pro free speed RPM */ * 12.0 /
154 56.0 /* motor to encoder reduction */ / 60.0 /* seconds per minute */ *
155 512.0 /* CPR */ * 4 /* index pulse every quarter cycle */;
Comran Morshed9a9948c2016-01-16 15:58:04 +0000156
Comran Morshed225f0b92016-02-10 20:34:27 +0000157// Class to send position messages with sensor readings to our loops.
Comran Morshed9a9948c2016-01-16 15:58:04 +0000158class SensorReader {
159 public:
160 SensorReader() {
161 // Set it to filter out anything shorter than 1/4 of the minimum pulse width
162 // we should ever see.
Comran Morshed1b764322016-02-14 20:18:12 +0000163 drivetrain_shooter_encoder_filter_.SetPeriodNanoSeconds(
164 static_cast<int>(1 / 4.0 /* built-in tolerance */ /
165 kMaxDrivetrainShooterEncoderPulsesPerSecond * 1e9 +
166 0.5));
167 superstructure_encoder_filter_.SetPeriodNanoSeconds(
168 static_cast<int>(1 / 4.0 /* built-in tolerance */ /
169 kMaxSuperstructureEncoderPulsesPerSecond * 1e9 +
170 0.5));
Comran Morshed9a9948c2016-01-16 15:58:04 +0000171 hall_filter_.SetPeriodNanoSeconds(100000);
172 }
173
Comran Morshed225f0b92016-02-10 20:34:27 +0000174 // Drivetrain setters.
Comran Morshed9a9948c2016-01-16 15:58:04 +0000175 void set_drivetrain_left_encoder(::std::unique_ptr<Encoder> encoder) {
Comran Morshed1b764322016-02-14 20:18:12 +0000176 drivetrain_shooter_encoder_filter_.Add(encoder.get());
Comran Morshed9a9948c2016-01-16 15:58:04 +0000177 drivetrain_left_encoder_ = ::std::move(encoder);
Comran Morshed9a9948c2016-01-16 15:58:04 +0000178 }
179
180 void set_drivetrain_right_encoder(::std::unique_ptr<Encoder> encoder) {
Comran Morshed1b764322016-02-14 20:18:12 +0000181 drivetrain_shooter_encoder_filter_.Add(encoder.get());
Comran Morshed9a9948c2016-01-16 15:58:04 +0000182 drivetrain_right_encoder_ = ::std::move(encoder);
Comran Morshed9a9948c2016-01-16 15:58:04 +0000183 }
184
Comran Morshed225f0b92016-02-10 20:34:27 +0000185 void set_drivetrain_left_hall(::std::unique_ptr<AnalogInput> analog) {
186 drivetrain_left_hall_ = ::std::move(analog);
Comran Morshed9a9948c2016-01-16 15:58:04 +0000187 }
188
Comran Morshed225f0b92016-02-10 20:34:27 +0000189 void set_drivetrain_right_hall(::std::unique_ptr<AnalogInput> analog) {
190 drivetrain_right_hall_ = ::std::move(analog);
Comran Morshed9a9948c2016-01-16 15:58:04 +0000191 }
192
Comran Morshed225f0b92016-02-10 20:34:27 +0000193 // Shooter setters.
194 void set_shooter_left_encoder(::std::unique_ptr<Encoder> encoder) {
Comran Morshed1b764322016-02-14 20:18:12 +0000195 drivetrain_shooter_encoder_filter_.Add(encoder.get());
Comran Morshed225f0b92016-02-10 20:34:27 +0000196 shooter_left_encoder_ = ::std::move(encoder);
Comran Morshed9a9948c2016-01-16 15:58:04 +0000197 }
198
Comran Morshed225f0b92016-02-10 20:34:27 +0000199 void set_shooter_right_encoder(::std::unique_ptr<Encoder> encoder) {
Comran Morshed1b764322016-02-14 20:18:12 +0000200 drivetrain_shooter_encoder_filter_.Add(encoder.get());
Comran Morshed225f0b92016-02-10 20:34:27 +0000201 shooter_right_encoder_ = ::std::move(encoder);
202 }
203
204 // Intake setters.
205 void set_intake_encoder(::std::unique_ptr<Encoder> encoder) {
Comran Morshed1b764322016-02-14 20:18:12 +0000206 superstructure_encoder_filter_.Add(encoder.get());
Comran Morshed225f0b92016-02-10 20:34:27 +0000207 intake_encoder_.set_encoder(::std::move(encoder));
208 }
209
210 void set_intake_potentiometer(::std::unique_ptr<AnalogInput> potentiometer) {
211 intake_encoder_.set_potentiometer(::std::move(potentiometer));
212 }
213
214 void set_intake_index(::std::unique_ptr<DigitalInput> index) {
Comran Morshed1b764322016-02-14 20:18:12 +0000215 superstructure_encoder_filter_.Add(index.get());
Comran Morshed225f0b92016-02-10 20:34:27 +0000216 intake_encoder_.set_index(::std::move(index));
217 }
218
219 // Shoulder setters.
220 void set_shoulder_encoder(::std::unique_ptr<Encoder> encoder) {
Comran Morshed1b764322016-02-14 20:18:12 +0000221 superstructure_encoder_filter_.Add(encoder.get());
Comran Morshed225f0b92016-02-10 20:34:27 +0000222 shoulder_encoder_.set_encoder(::std::move(encoder));
223 }
224
225 void set_shoulder_potentiometer(
226 ::std::unique_ptr<AnalogInput> potentiometer) {
227 shoulder_encoder_.set_potentiometer(::std::move(potentiometer));
228 }
229
230 void set_shoulder_index(::std::unique_ptr<DigitalInput> index) {
Comran Morshed1b764322016-02-14 20:18:12 +0000231 superstructure_encoder_filter_.Add(index.get());
Comran Morshed225f0b92016-02-10 20:34:27 +0000232 shoulder_encoder_.set_index(::std::move(index));
233 }
234
235 // Wrist setters.
236 void set_wrist_encoder(::std::unique_ptr<Encoder> encoder) {
Comran Morshed1b764322016-02-14 20:18:12 +0000237 superstructure_encoder_filter_.Add(encoder.get());
Comran Morshed225f0b92016-02-10 20:34:27 +0000238 wrist_encoder_.set_encoder(::std::move(encoder));
239 }
240
241 void set_wrist_potentiometer(::std::unique_ptr<AnalogInput> potentiometer) {
242 wrist_encoder_.set_potentiometer(::std::move(potentiometer));
243 }
244
245 void set_wrist_index(::std::unique_ptr<DigitalInput> index) {
Comran Morshed1b764322016-02-14 20:18:12 +0000246 superstructure_encoder_filter_.Add(index.get());
Comran Morshed225f0b92016-02-10 20:34:27 +0000247 wrist_encoder_.set_index(::std::move(index));
Comran Morshed9a9948c2016-01-16 15:58:04 +0000248 }
249
Comran Morshedaa0573c2016-03-05 19:05:54 +0000250 // Ball detector setter.
251 void set_ball_detector(::std::unique_ptr<AnalogInput> analog) {
252 ball_detector_ = ::std::move(analog);
253 }
254
Brian Silverman68cb5c22016-03-20 18:11:14 -0700255 // Autonomous mode switch setter.
256 void set_autonomous_mode(int i, ::std::unique_ptr<DigitalInput> sensor) {
257 autonomous_modes_.at(i) = ::std::move(sensor);
258 }
259
Comran Morshedaa0573c2016-03-05 19:05:54 +0000260
Comran Morshed9a9948c2016-01-16 15:58:04 +0000261 // All of the DMA-related set_* calls must be made before this, and it doesn't
262 // hurt to do all of them.
Comran Morshed9a9948c2016-01-16 15:58:04 +0000263
Comran Morshed6c6a0a92016-01-17 12:45:16 +0000264 void set_dma(::std::unique_ptr<DMA> dma) {
Comran Morshed9a9948c2016-01-16 15:58:04 +0000265 dma_synchronizer_.reset(
266 new ::frc971::wpilib::DMASynchronizer(::std::move(dma)));
Comran Morshed225f0b92016-02-10 20:34:27 +0000267 dma_synchronizer_->Add(&intake_encoder_);
268 dma_synchronizer_->Add(&shoulder_encoder_);
269 dma_synchronizer_->Add(&wrist_encoder_);
Comran Morshed9a9948c2016-01-16 15:58:04 +0000270 }
271
272 void operator()() {
273 ::aos::SetCurrentThreadName("SensorReader");
274
275 my_pid_ = getpid();
276 ds_ =
277#ifdef WPILIB2015
278 DriverStation::GetInstance();
279#else
280 &DriverStation::GetInstance();
281#endif
282
Comran Morshed9a9948c2016-01-16 15:58:04 +0000283 dma_synchronizer_->Start();
284
285 ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(5),
286 ::aos::time::Time::InMS(4));
287
288 ::aos::SetCurrentThreadRealtimePriority(40);
289 while (run_) {
290 {
291 const int iterations = phased_loop.SleepUntilNext();
292 if (iterations != 1) {
293 LOG(WARNING, "SensorReader skipped %d iterations\n", iterations - 1);
294 }
295 }
296 RunIteration();
297 }
Comran Morshed9a9948c2016-01-16 15:58:04 +0000298 }
299
300 void RunIteration() {
301 ::frc971::wpilib::SendRobotState(my_pid_, ds_);
302
303 const auto &values = constants::GetValues();
304
305 {
306 auto drivetrain_message = drivetrain_queue.position.MakeMessage();
307 drivetrain_message->right_encoder =
Austin Schuh9f77fd22016-02-21 02:53:58 -0800308 drivetrain_translate(-drivetrain_right_encoder_->GetRaw());
Comran Morshed9a9948c2016-01-16 15:58:04 +0000309 drivetrain_message->left_encoder =
310 -drivetrain_translate(drivetrain_left_encoder_->GetRaw());
311 drivetrain_message->left_speed =
312 drivetrain_velocity_translate(drivetrain_left_encoder_->GetPeriod());
313 drivetrain_message->right_speed =
314 drivetrain_velocity_translate(drivetrain_right_encoder_->GetPeriod());
315
Comran Morshed9a9948c2016-01-16 15:58:04 +0000316 drivetrain_message->left_shifter_position =
Comran Morshed225f0b92016-02-10 20:34:27 +0000317 hall_translate(drivetrain_left_hall_->GetVoltage());
Comran Morshed9a9948c2016-01-16 15:58:04 +0000318 drivetrain_message->right_shifter_position =
Comran Morshed225f0b92016-02-10 20:34:27 +0000319 hall_translate(drivetrain_right_hall_->GetVoltage());
Comran Morshed9a9948c2016-01-16 15:58:04 +0000320
321 drivetrain_message.Send();
322 }
323
Comran Morshed9a9948c2016-01-16 15:58:04 +0000324 dma_synchronizer_->RunIteration();
Comran Morshed225f0b92016-02-10 20:34:27 +0000325
326 {
327 auto shooter_message = shooter_queue.position.MakeMessage();
328 shooter_message->theta_left =
Austin Schuh9f77fd22016-02-21 02:53:58 -0800329 shooter_translate(-shooter_left_encoder_->GetRaw());
Comran Morshed225f0b92016-02-10 20:34:27 +0000330 shooter_message->theta_right =
331 shooter_translate(shooter_right_encoder_->GetRaw());
332 shooter_message.Send();
333 }
334
335 {
336 auto superstructure_message = superstructure_queue.position.MakeMessage();
337 CopyPotAndIndexPosition(intake_encoder_, &superstructure_message->intake,
338 intake_translate, intake_pot_translate, false,
339 values.intake.pot_offset);
340 CopyPotAndIndexPosition(shoulder_encoder_,
341 &superstructure_message->shoulder,
342 shoulder_translate, shoulder_pot_translate, false,
343 values.shoulder.pot_offset);
344 CopyPotAndIndexPosition(wrist_encoder_, &superstructure_message->wrist,
Austin Schuh9f77fd22016-02-21 02:53:58 -0800345 wrist_translate, wrist_pot_translate, true,
Comran Morshed225f0b92016-02-10 20:34:27 +0000346 values.wrist.pot_offset);
347
348 superstructure_message.Send();
349 }
Comran Morshedaa0573c2016-03-05 19:05:54 +0000350
351 {
352 auto ball_detector_message =
353 ::y2016::sensors::ball_detector.MakeMessage();
354 ball_detector_message->voltage = ball_detector_->GetVoltage();
355 LOG_STRUCT(DEBUG, "ball detector", *ball_detector_message);
356 ball_detector_message.Send();
357 }
Brian Silverman68cb5c22016-03-20 18:11:14 -0700358
359 {
360 auto auto_mode_message = ::y2016::actors::auto_mode.MakeMessage();
361 auto_mode_message->mode = 0;
362 for (size_t i = 0; i < autonomous_modes_.size(); ++i) {
363 if (autonomous_modes_[i]->Get()) {
364 auto_mode_message->mode |= 1 << i;
365 }
366 }
367 LOG_STRUCT(DEBUG, "auto mode", *auto_mode_message);
368 auto_mode_message.Send();
369 }
Comran Morshed9a9948c2016-01-16 15:58:04 +0000370 }
371
372 void Quit() { run_ = false; }
373
374 private:
Comran Morshed225f0b92016-02-10 20:34:27 +0000375 void CopyPotAndIndexPosition(
376 const ::frc971::wpilib::DMAEncoderAndPotentiometer &encoder,
377 ::frc971::PotAndIndexPosition *position,
378 ::std::function<double(int32_t)> encoder_translate,
379 ::std::function<double(double)> potentiometer_translate, bool reverse,
380 double pot_offset) {
381 const double multiplier = reverse ? -1.0 : 1.0;
382 position->encoder =
383 multiplier * encoder_translate(encoder.polled_encoder_value());
384 position->pot = multiplier * potentiometer_translate(
385 encoder.polled_potentiometer_voltage()) +
386 pot_offset;
387 position->latched_encoder =
388 multiplier * encoder_translate(encoder.last_encoder_value());
389 position->latched_pot =
390 multiplier *
391 potentiometer_translate(encoder.last_potentiometer_voltage()) +
392 pot_offset;
393 position->index_pulses = encoder.index_posedge_count();
394 }
395
Comran Morshed9a9948c2016-01-16 15:58:04 +0000396 int32_t my_pid_;
397 DriverStation *ds_;
398
399 ::std::unique_ptr<::frc971::wpilib::DMASynchronizer> dma_synchronizer_;
400
Comran Morshed225f0b92016-02-10 20:34:27 +0000401 ::std::unique_ptr<Encoder> drivetrain_left_encoder_,
402 drivetrain_right_encoder_;
403 ::std::unique_ptr<AnalogInput> drivetrain_left_hall_, drivetrain_right_hall_;
404
405 ::std::unique_ptr<Encoder> shooter_left_encoder_, shooter_right_encoder_;
Comran Morshedb79c4242016-02-06 18:27:26 +0000406 ::frc971::wpilib::DMAEncoderAndPotentiometer intake_encoder_,
407 shoulder_encoder_, wrist_encoder_;
Comran Morshedaa0573c2016-03-05 19:05:54 +0000408 ::std::unique_ptr<AnalogInput> ball_detector_;
Comran Morshed9a9948c2016-01-16 15:58:04 +0000409
Brian Silverman68cb5c22016-03-20 18:11:14 -0700410 ::std::array<::std::unique_ptr<DigitalInput>, 4> autonomous_modes_;
411
Comran Morshed9a9948c2016-01-16 15:58:04 +0000412 ::std::atomic<bool> run_{true};
Comran Morshed1b764322016-02-14 20:18:12 +0000413 DigitalGlitchFilter drivetrain_shooter_encoder_filter_, hall_filter_,
414 superstructure_encoder_filter_;
Comran Morshed9a9948c2016-01-16 15:58:04 +0000415};
416
417class SolenoidWriter {
418 public:
419 SolenoidWriter(const ::std::unique_ptr<::frc971::wpilib::BufferedPcm> &pcm)
420 : pcm_(pcm),
Comran Morshedb79c4242016-02-06 18:27:26 +0000421 drivetrain_(".frc971.control_loops.drivetrain_queue.output"),
Austin Schuh843412b2016-03-20 16:48:46 -0700422 shooter_(".y2016.control_loops.shooter.shooter_queue.output"),
423 superstructure_(
424 ".y2016.control_loops.superstructure_queue.output") {
425 }
Comran Morshed9a9948c2016-01-16 15:58:04 +0000426
Campbell Crowley1ab5fab2016-02-21 13:39:31 -0800427 void set_compressor(::std::unique_ptr<Compressor> compressor) {
428 compressor_ = ::std::move(compressor);
Comran Morshed9a9948c2016-01-16 15:58:04 +0000429 }
430
Comran Morshed71466fe2016-04-21 20:21:14 -0700431 void set_drivetrain_shifter(
Comran Morshed9a9948c2016-01-16 15:58:04 +0000432 ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> s) {
Comran Morshed71466fe2016-04-21 20:21:14 -0700433 drivetrain_shifter_ = ::std::move(s);
Comran Morshed9a9948c2016-01-16 15:58:04 +0000434 }
435
Comran Morshed71466fe2016-04-21 20:21:14 -0700436 void set_climber_trigger(
Comran Morshed9a9948c2016-01-16 15:58:04 +0000437 ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> s) {
Comran Morshed71466fe2016-04-21 20:21:14 -0700438 climber_trigger_ = ::std::move(s);
Comran Morshed9a9948c2016-01-16 15:58:04 +0000439 }
440
Austin Schuh843412b2016-03-20 16:48:46 -0700441 void set_traverse(
442 ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> s) {
443 traverse_ = ::std::move(s);
444 }
445
446 void set_traverse_latch(
447 ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> s) {
448 traverse_latch_ = ::std::move(s);
449 }
450
Comran Morshedb79c4242016-02-06 18:27:26 +0000451 void set_shooter_clamp(
452 ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> s) {
453 shooter_clamp_ = ::std::move(s);
454 }
455
456 void set_shooter_pusher(
457 ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> s) {
458 shooter_pusher_ = ::std::move(s);
459 }
460
Austin Schuhe0729a62016-03-12 21:54:17 -0800461 void set_lights(
462 ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> s) {
463 lights_ = ::std::move(s);
464 }
465
Austin Schuh8b89d332016-03-24 20:19:12 -0700466 void set_flashlight(::std::unique_ptr<Relay> relay) {
467 flashlight_ = ::std::move(relay);
468 }
469
Comran Morshed9a9948c2016-01-16 15:58:04 +0000470 void operator()() {
Campbell Crowley1ab5fab2016-02-21 13:39:31 -0800471 compressor_->Start();
Comran Morshed9a9948c2016-01-16 15:58:04 +0000472 ::aos::SetCurrentThreadName("Solenoids");
473 ::aos::SetCurrentThreadRealtimePriority(27);
474
475 ::aos::time::PhasedLoop phased_loop(::aos::time::Time::InMS(20),
476 ::aos::time::Time::InMS(1));
477
478 while (run_) {
479 {
480 const int iterations = phased_loop.SleepUntilNext();
481 if (iterations != 1) {
482 LOG(DEBUG, "Solenoids skipped %d iterations\n", iterations - 1);
483 }
484 }
485
486 {
Comran Morshed9a9948c2016-01-16 15:58:04 +0000487 drivetrain_.FetchLatest();
488 if (drivetrain_.get()) {
489 LOG_STRUCT(DEBUG, "solenoids", *drivetrain_);
Comran Morshed71466fe2016-04-21 20:21:14 -0700490 drivetrain_shifter_->Set(
491 !(drivetrain_->left_high || drivetrain_->right_high));
Comran Morshed9a9948c2016-01-16 15:58:04 +0000492 }
493 }
494
495 {
Comran Morshedb79c4242016-02-06 18:27:26 +0000496 shooter_.FetchLatest();
497 if (shooter_.get()) {
498 LOG_STRUCT(DEBUG, "solenoids", *shooter_);
499 shooter_clamp_->Set(shooter_->clamp_open);
500 shooter_pusher_->Set(shooter_->push_to_shooter);
Austin Schuhe0729a62016-03-12 21:54:17 -0800501 lights_->Set(shooter_->lights_on);
Austin Schuhb2c33382016-04-03 16:09:17 -0700502 if (shooter_->forwards_flashlight) {
503 if (shooter_->backwards_flashlight) {
504 flashlight_->Set(Relay::kOn);
505 } else {
506 flashlight_->Set(Relay::kReverse);
507 }
508 } else {
509 if (shooter_->backwards_flashlight) {
510 flashlight_->Set(Relay::kForward);
511 } else {
512 flashlight_->Set(Relay::kOff);
513 }
514 }
Comran Morshedb79c4242016-02-06 18:27:26 +0000515 }
516 }
517
518 {
Austin Schuh843412b2016-03-20 16:48:46 -0700519 superstructure_.FetchLatest();
520 if (superstructure_.get()) {
Comran Morshed71466fe2016-04-21 20:21:14 -0700521 LOG_STRUCT(DEBUG, "solenoids", *superstructure_);
522
523 climber_trigger_->Set(superstructure_->unfold_climber);
524
Austin Schuh843412b2016-03-20 16:48:46 -0700525 traverse_->Set(superstructure_->traverse_down);
526 traverse_latch_->Set(superstructure_->traverse_unlatched);
527 }
528 }
529
530 {
Comran Morshed9a9948c2016-01-16 15:58:04 +0000531 ::frc971::wpilib::PneumaticsToLog to_log;
532 {
Campbell Crowley1ab5fab2016-02-21 13:39:31 -0800533 to_log.compressor_on = compressor_->Enabled();
Comran Morshed9a9948c2016-01-16 15:58:04 +0000534 }
535
536 pcm_->Flush();
537 to_log.read_solenoids = pcm_->GetAll();
538 LOG_STRUCT(DEBUG, "pneumatics info", to_log);
539 }
540 }
541 }
542
543 void Quit() { run_ = false; }
544
545 private:
546 const ::std::unique_ptr<::frc971::wpilib::BufferedPcm> &pcm_;
547
Comran Morshed71466fe2016-04-21 20:21:14 -0700548 ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> drivetrain_shifter_,
549 shooter_clamp_, shooter_pusher_, lights_, traverse_, traverse_latch_,
550 climber_trigger_;
Austin Schuh8b89d332016-03-24 20:19:12 -0700551 ::std::unique_ptr<Relay> flashlight_;
Campbell Crowley1ab5fab2016-02-21 13:39:31 -0800552 ::std::unique_ptr<Compressor> compressor_;
Comran Morshed9a9948c2016-01-16 15:58:04 +0000553
Comran Morshed9a9948c2016-01-16 15:58:04 +0000554 ::aos::Queue<::frc971::control_loops::DrivetrainQueue::Output> drivetrain_;
Comran Morshed3263e8f2016-02-14 17:55:45 +0000555 ::aos::Queue<::y2016::control_loops::shooter::ShooterQueue::Output> shooter_;
Austin Schuh843412b2016-03-20 16:48:46 -0700556 ::aos::Queue<
557 ::y2016::control_loops::SuperstructureQueue::Output>
558 superstructure_;
Comran Morshed9a9948c2016-01-16 15:58:04 +0000559
560 ::std::atomic<bool> run_{true};
561};
562
563class DrivetrainWriter : public ::frc971::wpilib::LoopOutputHandler {
564 public:
Comran Morshed225f0b92016-02-10 20:34:27 +0000565 void set_drivetrain_left_talon(::std::unique_ptr<Talon> t) {
566 drivetrain_left_talon_ = ::std::move(t);
Comran Morshed9a9948c2016-01-16 15:58:04 +0000567 }
568
Comran Morshed225f0b92016-02-10 20:34:27 +0000569 void set_drivetrain_right_talon(::std::unique_ptr<Talon> t) {
570 drivetrain_right_talon_ = ::std::move(t);
Comran Morshed9a9948c2016-01-16 15:58:04 +0000571 }
572
573 private:
574 virtual void Read() override {
575 ::frc971::control_loops::drivetrain_queue.output.FetchAnother();
576 }
577
578 virtual void Write() override {
579 auto &queue = ::frc971::control_loops::drivetrain_queue.output;
580 LOG_STRUCT(DEBUG, "will output", *queue);
Austin Schuhcaa1ee92016-02-27 14:45:37 -0800581 drivetrain_left_talon_->Set(queue->left_voltage / 12.0);
582 drivetrain_right_talon_->Set(-queue->right_voltage / 12.0);
Comran Morshed9a9948c2016-01-16 15:58:04 +0000583 }
584
585 virtual void Stop() override {
586 LOG(WARNING, "drivetrain output too old\n");
Comran Morshed225f0b92016-02-10 20:34:27 +0000587 drivetrain_left_talon_->Disable();
588 drivetrain_right_talon_->Disable();
Comran Morshed9a9948c2016-01-16 15:58:04 +0000589 }
590
Comran Morshed225f0b92016-02-10 20:34:27 +0000591 ::std::unique_ptr<Talon> drivetrain_left_talon_, drivetrain_right_talon_;
592};
593
594class ShooterWriter : public ::frc971::wpilib::LoopOutputHandler {
595 public:
596 void set_shooter_left_talon(::std::unique_ptr<Talon> t) {
597 shooter_left_talon_ = ::std::move(t);
598 }
599
600 void set_shooter_right_talon(::std::unique_ptr<Talon> t) {
601 shooter_right_talon_ = ::std::move(t);
602 }
603
604 private:
605 virtual void Read() override {
606 ::y2016::control_loops::shooter::shooter_queue.output.FetchAnother();
607 }
608
609 virtual void Write() override {
610 auto &queue = ::y2016::control_loops::shooter::shooter_queue.output;
611 LOG_STRUCT(DEBUG, "will output", *queue);
Austin Schuhcaa1ee92016-02-27 14:45:37 -0800612
Comran Morshed225f0b92016-02-10 20:34:27 +0000613 shooter_left_talon_->Set(queue->voltage_left / 12.0);
Austin Schuhcaa1ee92016-02-27 14:45:37 -0800614 shooter_right_talon_->Set(-queue->voltage_right / 12.0);
Comran Morshed225f0b92016-02-10 20:34:27 +0000615 }
616
617 virtual void Stop() override {
618 LOG(WARNING, "Shooter output too old.\n");
619 shooter_left_talon_->Disable();
620 shooter_right_talon_->Disable();
621 }
622
623 ::std::unique_ptr<Talon> shooter_left_talon_, shooter_right_talon_;
624};
625
626class SuperstructureWriter : public ::frc971::wpilib::LoopOutputHandler {
627 public:
628 void set_intake_talon(::std::unique_ptr<Talon> t) {
629 intake_talon_ = ::std::move(t);
630 }
631
632 void set_shoulder_talon(::std::unique_ptr<Talon> t) {
633 shoulder_talon_ = ::std::move(t);
634 }
635
636 void set_wrist_talon(::std::unique_ptr<Talon> t) {
637 wrist_talon_ = ::std::move(t);
638 }
639
Campbell Crowleyd4fd6552016-02-21 17:53:46 -0800640 void set_top_rollers_talon(::std::unique_ptr<Talon> t) {
641 top_rollers_talon_ = ::std::move(t);
642 }
643
644 void set_bottom_rollers_talon(::std::unique_ptr<Talon> t) {
645 bottom_rollers_talon_ = ::std::move(t);
Comran Morshedf4cd7642016-02-15 20:40:49 +0000646 }
647
Comran Morshed71466fe2016-04-21 20:21:14 -0700648 void set_climber_talon(::std::unique_ptr<Talon> t) {
649 climber_talon_ = ::std::move(t);
650 }
651
Comran Morshed225f0b92016-02-10 20:34:27 +0000652 private:
653 virtual void Read() override {
654 ::y2016::control_loops::superstructure_queue.output.FetchAnother();
655 }
656
657 virtual void Write() override {
658 auto &queue = ::y2016::control_loops::superstructure_queue.output;
659 LOG_STRUCT(DEBUG, "will output", *queue);
Austin Schuha9992ff2016-02-28 21:59:23 -0800660 intake_talon_->Set(::aos::Clip(queue->voltage_intake, -kMaxBringupPower,
661 kMaxBringupPower) /
662 12.0);
663 shoulder_talon_->Set(::aos::Clip(-queue->voltage_shoulder,
664 -kMaxBringupPower, kMaxBringupPower) /
665 12.0);
666 wrist_talon_->Set(
667 ::aos::Clip(queue->voltage_wrist, -kMaxBringupPower, kMaxBringupPower) /
668 12.0);
Austin Schuhcaa1ee92016-02-27 14:45:37 -0800669 top_rollers_talon_->Set(-queue->voltage_top_rollers / 12.0);
670 bottom_rollers_talon_->Set(-queue->voltage_bottom_rollers / 12.0);
Comran Morshed71466fe2016-04-21 20:21:14 -0700671 climber_talon_->Set(-queue->voltage_climber / 12.0);
Comran Morshed225f0b92016-02-10 20:34:27 +0000672 }
673
674 virtual void Stop() override {
675 LOG(WARNING, "Superstructure output too old.\n");
676 intake_talon_->Disable();
677 shoulder_talon_->Disable();
678 wrist_talon_->Disable();
679 }
680
Comran Morshedf4cd7642016-02-15 20:40:49 +0000681 ::std::unique_ptr<Talon> intake_talon_, shoulder_talon_, wrist_talon_,
Comran Morshed71466fe2016-04-21 20:21:14 -0700682 top_rollers_talon_, bottom_rollers_talon_, climber_talon_;
Comran Morshed9a9948c2016-01-16 15:58:04 +0000683};
684
Comran Morshed9a9948c2016-01-16 15:58:04 +0000685class WPILibRobot : public ::frc971::wpilib::WPILibRobotBase {
686 public:
687 ::std::unique_ptr<Encoder> make_encoder(int index) {
688 return make_unique<Encoder>(10 + index * 2, 11 + index * 2, false,
689 Encoder::k4X);
690 }
691
692 void Run() override {
693 ::aos::InitNRT();
694 ::aos::SetCurrentThreadName("StartCompetition");
695
696 ::frc971::wpilib::JoystickSender joystick_sender;
697 ::std::thread joystick_thread(::std::ref(joystick_sender));
698
699 ::frc971::wpilib::PDPFetcher pdp_fetcher;
700 ::std::thread pdp_fetcher_thread(::std::ref(pdp_fetcher));
701 SensorReader reader;
702
Austin Schuh9f77fd22016-02-21 02:53:58 -0800703 reader.set_drivetrain_left_encoder(make_encoder(5));
704 reader.set_drivetrain_right_encoder(make_encoder(6));
705 reader.set_drivetrain_left_hall(make_unique<AnalogInput>(5));
706 reader.set_drivetrain_right_hall(make_unique<AnalogInput>(6));
Comran Morshed225f0b92016-02-10 20:34:27 +0000707
Austin Schuhf0c05762016-04-03 16:06:49 -0700708 reader.set_shooter_left_encoder(make_encoder(7));
709 reader.set_shooter_right_encoder(make_encoder(-3));
Comran Morshed225f0b92016-02-10 20:34:27 +0000710
711 reader.set_intake_encoder(make_encoder(0));
712 reader.set_intake_index(make_unique<DigitalInput>(0));
713 reader.set_intake_potentiometer(make_unique<AnalogInput>(0));
714
Austin Schuhf0c05762016-04-03 16:06:49 -0700715 reader.set_shoulder_encoder(make_encoder(4));
Austin Schuh9f77fd22016-02-21 02:53:58 -0800716 reader.set_shoulder_index(make_unique<DigitalInput>(2));
717 reader.set_shoulder_potentiometer(make_unique<AnalogInput>(2));
Comran Morshed225f0b92016-02-10 20:34:27 +0000718
Austin Schuh9f77fd22016-02-21 02:53:58 -0800719 reader.set_wrist_encoder(make_encoder(1));
720 reader.set_wrist_index(make_unique<DigitalInput>(1));
721 reader.set_wrist_potentiometer(make_unique<AnalogInput>(1));
Comran Morshed9a9948c2016-01-16 15:58:04 +0000722
Comran Morshedaa0573c2016-03-05 19:05:54 +0000723 reader.set_ball_detector(make_unique<AnalogInput>(7));
724
Brian Silverman68cb5c22016-03-20 18:11:14 -0700725 reader.set_autonomous_mode(0, make_unique<DigitalInput>(9));
726 reader.set_autonomous_mode(1, make_unique<DigitalInput>(8));
727 reader.set_autonomous_mode(2, make_unique<DigitalInput>(7));
728 reader.set_autonomous_mode(3, make_unique<DigitalInput>(6));
729
Comran Morshed9a9948c2016-01-16 15:58:04 +0000730 reader.set_dma(make_unique<DMA>());
731 ::std::thread reader_thread(::std::ref(reader));
732
733 ::frc971::wpilib::GyroSender gyro_sender;
734 ::std::thread gyro_thread(::std::ref(gyro_sender));
735
Austin Schuhf0c05762016-04-03 16:06:49 -0700736 auto imu_trigger = make_unique<DigitalInput>(3);
737 ::frc971::wpilib::ADIS16448 imu(SPI::Port::kMXP, imu_trigger.get());
Brian Silverman5f17a972016-02-28 01:49:32 -0500738 ::std::thread imu_thread(::std::ref(imu));
Brian Silverman5f17a972016-02-28 01:49:32 -0500739
Comran Morshed9a9948c2016-01-16 15:58:04 +0000740 DrivetrainWriter drivetrain_writer;
Comran Morshed225f0b92016-02-10 20:34:27 +0000741 drivetrain_writer.set_drivetrain_left_talon(
Comran Morshed9a9948c2016-01-16 15:58:04 +0000742 ::std::unique_ptr<Talon>(new Talon(5)));
Comran Morshed225f0b92016-02-10 20:34:27 +0000743 drivetrain_writer.set_drivetrain_right_talon(
Austin Schuh0c2b58c2016-02-21 17:23:46 -0800744 ::std::unique_ptr<Talon>(new Talon(4)));
Comran Morshed9a9948c2016-01-16 15:58:04 +0000745 ::std::thread drivetrain_writer_thread(::std::ref(drivetrain_writer));
746
Comran Morshed225f0b92016-02-10 20:34:27 +0000747 ShooterWriter shooter_writer;
748 shooter_writer.set_shooter_left_talon(
Austin Schuh0c2b58c2016-02-21 17:23:46 -0800749 ::std::unique_ptr<Talon>(new Talon(9)));
Comran Morshed225f0b92016-02-10 20:34:27 +0000750 shooter_writer.set_shooter_right_talon(
Austin Schuh0c2b58c2016-02-21 17:23:46 -0800751 ::std::unique_ptr<Talon>(new Talon(8)));
Comran Morshed225f0b92016-02-10 20:34:27 +0000752 ::std::thread shooter_writer_thread(::std::ref(shooter_writer));
753
754 SuperstructureWriter superstructure_writer;
755 superstructure_writer.set_intake_talon(
Austin Schuh0c2b58c2016-02-21 17:23:46 -0800756 ::std::unique_ptr<Talon>(new Talon(3)));
Comran Morshed225f0b92016-02-10 20:34:27 +0000757 superstructure_writer.set_shoulder_talon(
Austin Schuh0c2b58c2016-02-21 17:23:46 -0800758 ::std::unique_ptr<Talon>(new Talon(6)));
Comran Morshed225f0b92016-02-10 20:34:27 +0000759 superstructure_writer.set_wrist_talon(
Austin Schuh0c2b58c2016-02-21 17:23:46 -0800760 ::std::unique_ptr<Talon>(new Talon(2)));
Campbell Crowleyd4fd6552016-02-21 17:53:46 -0800761 superstructure_writer.set_top_rollers_talon(
Austin Schuh0c2b58c2016-02-21 17:23:46 -0800762 ::std::unique_ptr<Talon>(new Talon(1)));
Austin Schuhcaa1ee92016-02-27 14:45:37 -0800763 superstructure_writer.set_bottom_rollers_talon(
764 ::std::unique_ptr<Talon>(new Talon(0)));
Comran Morshed71466fe2016-04-21 20:21:14 -0700765 superstructure_writer.set_climber_talon(
766 ::std::unique_ptr<Talon>(new Talon(7)));
Comran Morshed225f0b92016-02-10 20:34:27 +0000767 ::std::thread superstructure_writer_thread(
768 ::std::ref(superstructure_writer));
769
Comran Morshed9a9948c2016-01-16 15:58:04 +0000770 ::std::unique_ptr<::frc971::wpilib::BufferedPcm> pcm(
771 new ::frc971::wpilib::BufferedPcm());
772 SolenoidWriter solenoid_writer(pcm);
Comran Morshed71466fe2016-04-21 20:21:14 -0700773 solenoid_writer.set_drivetrain_shifter(pcm->MakeSolenoid(0));
Austin Schuh843412b2016-03-20 16:48:46 -0700774 solenoid_writer.set_traverse_latch(pcm->MakeSolenoid(2));
775 solenoid_writer.set_traverse(pcm->MakeSolenoid(3));
Austin Schuhcaa1ee92016-02-27 14:45:37 -0800776 solenoid_writer.set_shooter_clamp(pcm->MakeSolenoid(4));
777 solenoid_writer.set_shooter_pusher(pcm->MakeSolenoid(5));
Austin Schuhe0729a62016-03-12 21:54:17 -0800778 solenoid_writer.set_lights(pcm->MakeSolenoid(6));
Comran Morshed71466fe2016-04-21 20:21:14 -0700779 solenoid_writer.set_climber_trigger(pcm->MakeSolenoid(1));
Austin Schuh8b89d332016-03-24 20:19:12 -0700780 solenoid_writer.set_flashlight(make_unique<Relay>(0));
Comran Morshed9a9948c2016-01-16 15:58:04 +0000781
Campbell Crowley1ab5fab2016-02-21 13:39:31 -0800782 solenoid_writer.set_compressor(make_unique<Compressor>());
783
Comran Morshed9a9948c2016-01-16 15:58:04 +0000784 ::std::thread solenoid_thread(::std::ref(solenoid_writer));
785
786 // Wait forever. Not much else to do...
787 while (true) {
788 const int r = select(0, nullptr, nullptr, nullptr, nullptr);
789 if (r != 0) {
790 PLOG(WARNING, "infinite select failed");
791 } else {
792 PLOG(WARNING, "infinite select succeeded??\n");
793 }
794 }
795
796 LOG(ERROR, "Exiting WPILibRobot\n");
797
798 joystick_sender.Quit();
799 joystick_thread.join();
800 pdp_fetcher.Quit();
801 pdp_fetcher_thread.join();
802 reader.Quit();
803 reader_thread.join();
804 gyro_sender.Quit();
805 gyro_thread.join();
Brian Silverman5f17a972016-02-28 01:49:32 -0500806 imu.Quit();
807 imu_thread.join();
Comran Morshed9a9948c2016-01-16 15:58:04 +0000808
809 drivetrain_writer.Quit();
810 drivetrain_writer_thread.join();
Comran Morshed225f0b92016-02-10 20:34:27 +0000811 shooter_writer.Quit();
812 shooter_writer_thread.join();
813 superstructure_writer.Quit();
814 superstructure_writer_thread.join();
Comran Morshed9a9948c2016-01-16 15:58:04 +0000815 solenoid_writer.Quit();
816 solenoid_thread.join();
817
818 ::aos::Cleanup();
819 }
820};
821
822} // namespace wpilib
Comran Morshed6c6a0a92016-01-17 12:45:16 +0000823} // namespace y2016
Comran Morshed9a9948c2016-01-16 15:58:04 +0000824
Comran Morshed6c6a0a92016-01-17 12:45:16 +0000825AOS_ROBOT_CLASS(::y2016::wpilib::WPILibRobot);