Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 1 | #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" |
| 19 | #undef ERROR |
| 20 | |
| 21 | #include "aos/commonmath.h" |
| 22 | #include "aos/init.h" |
| 23 | #include "aos/logging/logging.h" |
| 24 | #include "aos/logging/queue_logging.h" |
| 25 | #include "aos/make_unique.h" |
Austin Schuh | c2ee66b | 2019-02-19 13:37:46 -0800 | [diff] [blame] | 26 | #include "aos/robot_state/robot_state.q.h" |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 27 | #include "aos/time/time.h" |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 28 | #include "aos/util/log_interval.h" |
| 29 | #include "aos/util/phased_loop.h" |
| 30 | #include "aos/util/wrapping_counter.h" |
Brian Silverman | c41fb86 | 2019-03-02 21:14:46 -0800 | [diff] [blame] | 31 | #include "ctre/phoenix/motorcontrol/can/TalonSRX.h" |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 32 | #include "frc971/autonomous/auto.q.h" |
| 33 | #include "frc971/control_loops/drivetrain/drivetrain.q.h" |
| 34 | #include "frc971/wpilib/ADIS16448.h" |
Austin Schuh | c1d6f83 | 2019-02-15 23:22:17 -0800 | [diff] [blame] | 35 | #include "frc971/wpilib/buffered_pcm.h" |
| 36 | #include "frc971/wpilib/buffered_solenoid.h" |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 37 | #include "frc971/wpilib/dma.h" |
Sabina Davis | d004fd6 | 2019-02-02 23:51:46 -0800 | [diff] [blame] | 38 | #include "frc971/wpilib/drivetrain_writer.h" |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 39 | #include "frc971/wpilib/encoder_and_potentiometer.h" |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 40 | #include "frc971/wpilib/joystick_sender.h" |
| 41 | #include "frc971/wpilib/logging.q.h" |
| 42 | #include "frc971/wpilib/loop_output_handler.h" |
| 43 | #include "frc971/wpilib/pdp_fetcher.h" |
Sabina Davis | adc5854 | 2019-02-01 22:23:00 -0800 | [diff] [blame] | 44 | #include "frc971/wpilib/sensor_reader.h" |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 45 | #include "frc971/wpilib/wpilib_robot_base.h" |
Sabina Davis | 7be49f3 | 2019-02-02 00:30:19 -0800 | [diff] [blame] | 46 | #include "y2019/constants.h" |
Brian Silverman | c41fb86 | 2019-03-02 21:14:46 -0800 | [diff] [blame] | 47 | #include "y2019/control_loops/drivetrain/camera.q.h" |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 48 | #include "y2019/control_loops/superstructure/superstructure.q.h" |
Brian Silverman | f8b7525 | 2019-02-24 16:13:58 -0800 | [diff] [blame] | 49 | #include "y2019/jevois/spi.h" |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 50 | |
| 51 | #ifndef M_PI |
| 52 | #define M_PI 3.14159265358979323846 |
| 53 | #endif |
| 54 | |
| 55 | using ::frc971::control_loops::drivetrain_queue; |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 56 | using ::y2019::control_loops::superstructure::superstructure_queue; |
Sabina Davis | 7be49f3 | 2019-02-02 00:30:19 -0800 | [diff] [blame] | 57 | using ::y2019::constants::Values; |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 58 | using ::aos::monotonic_clock; |
| 59 | namespace chrono = ::std::chrono; |
| 60 | using aos::make_unique; |
| 61 | |
| 62 | namespace y2019 { |
| 63 | namespace wpilib { |
| 64 | namespace { |
| 65 | |
| 66 | constexpr double kMaxBringupPower = 12.0; |
| 67 | |
| 68 | // TODO(Brian): Fix the interpretation of the result of GetRaw here and in the |
| 69 | // DMA stuff and then removing the * 2.0 in *_translate. |
| 70 | // The low bit is direction. |
| 71 | |
| 72 | // TODO(brian): Use ::std::max instead once we have C++14 so that can be |
| 73 | // constexpr. |
| 74 | template <typename T> |
| 75 | constexpr T max(T a, T b) { |
| 76 | return (a > b) ? a : b; |
| 77 | } |
| 78 | |
| 79 | template <typename T, typename... Rest> |
| 80 | constexpr T max(T a, T b, T c, Rest... rest) { |
| 81 | return max(max(a, b), c, rest...); |
| 82 | } |
| 83 | |
| 84 | double drivetrain_translate(int32_t in) { |
Sabina Davis | 7be49f3 | 2019-02-02 00:30:19 -0800 | [diff] [blame] | 85 | return ((static_cast<double>(in) / |
| 86 | Values::kDrivetrainEncoderCountsPerRevolution()) * |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 87 | (2.0 * M_PI)) * |
| 88 | Values::kDrivetrainEncoderRatio() * |
Sabina Davis | 7be49f3 | 2019-02-02 00:30:19 -0800 | [diff] [blame] | 89 | control_loops::drivetrain::kWheelRadius; |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | double drivetrain_velocity_translate(double in) { |
Sabina Davis | 7be49f3 | 2019-02-02 00:30:19 -0800 | [diff] [blame] | 93 | return (((1.0 / in) / Values::kDrivetrainCyclesPerRevolution()) * |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 94 | (2.0 * M_PI)) * |
| 95 | Values::kDrivetrainEncoderRatio() * |
Sabina Davis | 7be49f3 | 2019-02-02 00:30:19 -0800 | [diff] [blame] | 96 | control_loops::drivetrain::kWheelRadius; |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 97 | } |
| 98 | |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 99 | double elevator_pot_translate(double voltage) { |
| 100 | return voltage * Values::kElevatorPotRatio() * |
Austin Schuh | ed7f863 | 2019-02-15 23:12:20 -0800 | [diff] [blame] | 101 | (10.0 /*turns*/ / 5.0 /*volts*/) * (2 * M_PI /*radians*/); |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | double wrist_pot_translate(double voltage) { |
Austin Schuh | ed7f863 | 2019-02-15 23:12:20 -0800 | [diff] [blame] | 105 | return voltage * Values::kWristPotRatio() * (5.0 /*turns*/ / 5.0 /*volts*/) * |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 106 | (2 * M_PI /*radians*/); |
| 107 | } |
| 108 | |
| 109 | double stilts_pot_translate(double voltage) { |
| 110 | return voltage * Values::kStiltsPotRatio() * |
| 111 | (10.0 /*turns*/ / 5.0 /*volts*/) * (2 * M_PI /*radians*/); |
| 112 | } |
| 113 | |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 114 | constexpr double kMaxFastEncoderPulsesPerSecond = |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 115 | max(Values::kMaxDrivetrainEncoderPulsesPerSecond(), |
| 116 | Values::kMaxIntakeEncoderPulsesPerSecond()); |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 117 | static_assert(kMaxFastEncoderPulsesPerSecond <= 1300000, |
| 118 | "fast encoders are too fast"); |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 119 | constexpr double kMaxMediumEncoderPulsesPerSecond = |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 120 | max(Values::kMaxElevatorEncoderPulsesPerSecond(), |
| 121 | Values::kMaxWristEncoderPulsesPerSecond()); |
Theo Bafrali | 00e4227 | 2019-02-12 01:07:46 -0800 | [diff] [blame] | 122 | |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 123 | static_assert(kMaxMediumEncoderPulsesPerSecond <= 400000, |
| 124 | "medium encoders are too fast"); |
| 125 | |
| 126 | // Class to send position messages with sensor readings to our loops. |
Sabina Davis | adc5854 | 2019-02-01 22:23:00 -0800 | [diff] [blame] | 127 | class SensorReader : public ::frc971::wpilib::SensorReader { |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 128 | public: |
| 129 | SensorReader() { |
| 130 | // Set to filter out anything shorter than 1/4 of the minimum pulse width |
| 131 | // we should ever see. |
Austin Schuh | 45a549f | 2019-02-02 15:43:56 -0800 | [diff] [blame] | 132 | UpdateFastEncoderFilterHz(kMaxFastEncoderPulsesPerSecond); |
| 133 | UpdateMediumEncoderFilterHz(kMaxMediumEncoderPulsesPerSecond); |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 134 | } |
| 135 | |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 136 | // Elevator |
| 137 | |
| 138 | void set_elevator_encoder(::std::unique_ptr<frc::Encoder> encoder) { |
| 139 | medium_encoder_filter_.Add(encoder.get()); |
| 140 | elevator_encoder_.set_encoder(::std::move(encoder)); |
| 141 | } |
| 142 | |
| 143 | void set_elevator_absolute_pwm( |
| 144 | ::std::unique_ptr<frc::DigitalInput> absolute_pwm) { |
| 145 | elevator_encoder_.set_absolute_pwm(::std::move(absolute_pwm)); |
| 146 | } |
| 147 | |
| 148 | void set_elevator_potentiometer( |
| 149 | ::std::unique_ptr<frc::AnalogInput> potentiometer) { |
| 150 | elevator_encoder_.set_potentiometer(::std::move(potentiometer)); |
| 151 | } |
| 152 | |
| 153 | // Intake |
| 154 | |
| 155 | void set_intake_encoder(::std::unique_ptr<frc::Encoder> encoder) { |
| 156 | medium_encoder_filter_.Add(encoder.get()); |
| 157 | intake_encoder_.set_encoder(::std::move(encoder)); |
| 158 | } |
| 159 | |
| 160 | void set_intake_absolute_pwm( |
| 161 | ::std::unique_ptr<frc::DigitalInput> absolute_pwm) { |
| 162 | intake_encoder_.set_absolute_pwm(::std::move(absolute_pwm)); |
| 163 | } |
| 164 | |
| 165 | // Wrist |
| 166 | |
| 167 | void set_wrist_encoder(::std::unique_ptr<frc::Encoder> encoder) { |
| 168 | medium_encoder_filter_.Add(encoder.get()); |
| 169 | wrist_encoder_.set_encoder(::std::move(encoder)); |
| 170 | } |
| 171 | |
| 172 | void set_wrist_absolute_pwm( |
| 173 | ::std::unique_ptr<frc::DigitalInput> absolute_pwm) { |
| 174 | wrist_encoder_.set_absolute_pwm(::std::move(absolute_pwm)); |
| 175 | } |
| 176 | |
| 177 | void set_wrist_potentiometer( |
| 178 | ::std::unique_ptr<frc::AnalogInput> potentiometer) { |
| 179 | wrist_encoder_.set_potentiometer(::std::move(potentiometer)); |
| 180 | } |
| 181 | |
| 182 | // Stilts |
| 183 | |
| 184 | void set_stilts_encoder(::std::unique_ptr<frc::Encoder> encoder) { |
| 185 | medium_encoder_filter_.Add(encoder.get()); |
| 186 | stilts_encoder_.set_encoder(::std::move(encoder)); |
| 187 | } |
| 188 | |
| 189 | void set_stilts_absolute_pwm( |
| 190 | ::std::unique_ptr<frc::DigitalInput> absolute_pwm) { |
| 191 | stilts_encoder_.set_absolute_pwm(::std::move(absolute_pwm)); |
| 192 | } |
| 193 | |
| 194 | void set_stilts_potentiometer( |
| 195 | ::std::unique_ptr<frc::AnalogInput> potentiometer) { |
| 196 | stilts_encoder_.set_potentiometer(::std::move(potentiometer)); |
| 197 | } |
| 198 | |
Austin Schuh | 461e118 | 2019-02-17 14:56:44 -0800 | [diff] [blame] | 199 | // Vacuum pressure sensor |
| 200 | void set_vacuum_sensor(int port) { |
| 201 | vacuum_sensor_ = make_unique<frc::AnalogInput>(port); |
| 202 | } |
| 203 | |
Sabina Davis | 399dbd8 | 2019-02-01 23:06:08 -0800 | [diff] [blame] | 204 | void RunIteration() override { |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 205 | { |
| 206 | auto drivetrain_message = drivetrain_queue.position.MakeMessage(); |
| 207 | drivetrain_message->left_encoder = |
| 208 | drivetrain_translate(drivetrain_left_encoder_->GetRaw()); |
| 209 | drivetrain_message->left_speed = |
| 210 | drivetrain_velocity_translate(drivetrain_left_encoder_->GetPeriod()); |
| 211 | |
| 212 | drivetrain_message->right_encoder = |
| 213 | -drivetrain_translate(drivetrain_right_encoder_->GetRaw()); |
| 214 | drivetrain_message->right_speed = -drivetrain_velocity_translate( |
| 215 | drivetrain_right_encoder_->GetPeriod()); |
| 216 | |
| 217 | drivetrain_message.Send(); |
| 218 | } |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 219 | const auto values = constants::GetValues(); |
| 220 | |
| 221 | { |
| 222 | auto superstructure_message = superstructure_queue.position.MakeMessage(); |
| 223 | |
| 224 | // Elevator |
| 225 | CopyPosition(elevator_encoder_, &superstructure_message->elevator, |
| 226 | Values::kElevatorEncoderCountsPerRevolution(), |
| 227 | Values::kElevatorEncoderRatio(), elevator_pot_translate, |
| 228 | false, values.elevator.potentiometer_offset); |
| 229 | // Intake |
| 230 | CopyPosition(intake_encoder_, &superstructure_message->intake_joint, |
| 231 | Values::kIntakeEncoderCountsPerRevolution(), |
| 232 | Values::kIntakeEncoderRatio(), false); |
| 233 | |
| 234 | // Wrist |
| 235 | CopyPosition(wrist_encoder_, &superstructure_message->wrist, |
| 236 | Values::kWristEncoderCountsPerRevolution(), |
| 237 | Values::kWristEncoderRatio(), wrist_pot_translate, false, |
| 238 | values.wrist.potentiometer_offset); |
| 239 | |
| 240 | // Stilts |
| 241 | CopyPosition(stilts_encoder_, &superstructure_message->stilts, |
| 242 | Values::kStiltsEncoderCountsPerRevolution(), |
| 243 | Values::kStiltsEncoderRatio(), stilts_pot_translate, false, |
| 244 | values.stilts.potentiometer_offset); |
| 245 | |
Austin Schuh | 461e118 | 2019-02-17 14:56:44 -0800 | [diff] [blame] | 246 | // Suction |
| 247 | constexpr float kMinVoltage = 0.5; |
| 248 | constexpr float kMaxVoltage = 2.1; |
| 249 | superstructure_message->suction_pressure = |
| 250 | (vacuum_sensor_->GetVoltage() - kMinVoltage) / |
| 251 | (kMaxVoltage - kMinVoltage); |
| 252 | |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 253 | superstructure_message.Send(); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | private: |
| 258 | ::frc971::wpilib::AbsoluteEncoderAndPotentiometer elevator_encoder_, |
| 259 | wrist_encoder_, stilts_encoder_; |
| 260 | |
Austin Schuh | 461e118 | 2019-02-17 14:56:44 -0800 | [diff] [blame] | 261 | ::std::unique_ptr<frc::AnalogInput> vacuum_sensor_; |
| 262 | |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 263 | ::frc971::wpilib::AbsoluteEncoder intake_encoder_; |
| 264 | // TODO(sabina): Add wrist and elevator hall effects. |
| 265 | }; |
| 266 | |
Brian Silverman | f8b7525 | 2019-02-24 16:13:58 -0800 | [diff] [blame] | 267 | class CameraReader { |
| 268 | public: |
| 269 | CameraReader() = default; |
| 270 | CameraReader(const CameraReader &) = delete; |
| 271 | CameraReader &operator=(const CameraReader &) = delete; |
| 272 | |
| 273 | void set_spi(frc::SPI *spi) { |
| 274 | spi_ = spi; |
| 275 | spi_->SetClockRate(1e6); |
| 276 | spi_->SetChipSelectActiveHigh(); |
| 277 | spi_->SetClockActiveLow(); |
| 278 | spi_->SetSampleDataOnFalling(); |
| 279 | // It ignores you if you try changing this... |
| 280 | spi_->SetMSBFirst(); |
| 281 | } |
| 282 | |
Brian Silverman | 7ecf067 | 2019-03-02 15:30:03 -0800 | [diff] [blame] | 283 | void set_activate_usb(std::unique_ptr<frc::DigitalInput> activate_usb) { |
| 284 | activate_usb_ = std::move(activate_usb); |
| 285 | } |
| 286 | |
| 287 | void set_activate_passthrough( |
| 288 | std::unique_ptr<frc::DigitalInput> activate_passthrough) { |
| 289 | activate_passthrough_ = std::move(activate_passthrough); |
| 290 | } |
| 291 | |
Brian Silverman | f8b7525 | 2019-02-24 16:13:58 -0800 | [diff] [blame] | 292 | void DoSpiTransaction() { |
| 293 | using namespace frc971::jevois; |
| 294 | RoborioToTeensy to_teensy{}; |
| 295 | to_teensy.realtime_now = aos::realtime_clock::now(); |
Brian Silverman | 7ecf067 | 2019-03-02 15:30:03 -0800 | [diff] [blame] | 296 | if (activate_usb_ && !activate_usb_->Get()) { |
| 297 | to_teensy.camera_command = CameraCommand::kUsb; |
| 298 | } else if (activate_passthrough_ && !activate_passthrough_->Get()) { |
| 299 | to_teensy.camera_command = CameraCommand::kCameraPassthrough; |
| 300 | } else { |
| 301 | to_teensy.camera_command = CameraCommand::kNormal; |
| 302 | } |
Brian Silverman | f8b7525 | 2019-02-24 16:13:58 -0800 | [diff] [blame] | 303 | |
| 304 | std::array<char, spi_transfer_size() + 1> to_send{}; |
| 305 | { |
| 306 | const auto to_send_data = |
| 307 | gsl::make_span(to_send).last<spi_transfer_size()>(); |
| 308 | const auto encoded = SpiPackToTeensy(to_teensy); |
| 309 | std::copy(encoded.begin(), encoded.end(), to_send_data.begin()); |
| 310 | } |
| 311 | rx_clearer_.ClearRxFifo(); |
| 312 | // First, send recieve a dummy byte because the Teensy can't control what it |
| 313 | // sends for the first byte. |
| 314 | std::array<char, spi_transfer_size() + 1> to_receive; |
| 315 | DoTransaction(to_send, to_receive); |
| 316 | const auto unpacked = SpiUnpackToRoborio( |
| 317 | gsl::make_span(to_receive).last(spi_transfer_size())); |
| 318 | if (!unpacked) { |
| 319 | LOG(INFO, "Decoding SPI data failed\n"); |
| 320 | return; |
| 321 | } |
| 322 | |
Brian Silverman | c41fb86 | 2019-03-02 21:14:46 -0800 | [diff] [blame] | 323 | const auto now = aos::monotonic_clock::now(); |
| 324 | for (const auto &received : unpacked->frames) { |
| 325 | auto to_send = control_loops::drivetrain::camera_frames.MakeMessage(); |
| 326 | to_send->timestamp = |
James Kuszmaul | 85ffeb8 | 2019-03-03 19:41:44 -0800 | [diff] [blame^] | 327 | std::chrono::nanoseconds((now - received.age).time_since_epoch()) |
Brian Silverman | c41fb86 | 2019-03-02 21:14:46 -0800 | [diff] [blame] | 328 | .count(); |
| 329 | to_send->num_targets = received.targets.size(); |
| 330 | for (size_t i = 0; i < received.targets.size(); ++i) { |
| 331 | to_send->targets[i].distance = received.targets[i].distance; |
| 332 | to_send->targets[i].height = received.targets[i].height; |
| 333 | to_send->targets[i].heading = received.targets[i].heading; |
| 334 | to_send->targets[i].skew = received.targets[i].skew; |
| 335 | } |
| 336 | to_send->camera = received.camera_index; |
Austin Schuh | bb52eec | 2019-03-03 18:32:14 -0800 | [diff] [blame] | 337 | LOG_STRUCT(DEBUG, "camera_frames", *to_send); |
Brian Silverman | c41fb86 | 2019-03-02 21:14:46 -0800 | [diff] [blame] | 338 | to_send.Send(); |
| 339 | } |
Brian Silverman | f8b7525 | 2019-02-24 16:13:58 -0800 | [diff] [blame] | 340 | |
| 341 | if (dummy_spi_) { |
| 342 | uint8_t dummy_send, dummy_receive; |
| 343 | dummy_spi_->Transaction(&dummy_send, &dummy_receive, 1); |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | void DoTransaction(gsl::span<char> to_send, gsl::span<char> to_receive) { |
| 348 | CHECK_EQ(to_send.size(), to_receive.size()); |
| 349 | const auto result = spi_->Transaction( |
| 350 | reinterpret_cast<uint8_t *>(to_send.data()), |
| 351 | reinterpret_cast<uint8_t *>(to_receive.data()), to_send.size()); |
| 352 | if (result == to_send.size()) { |
| 353 | return; |
| 354 | } |
| 355 | if (result == -1) { |
| 356 | LOG(INFO, "SPI::Transaction of %zd bytes failed\n", to_send.size()); |
| 357 | return; |
| 358 | } |
| 359 | LOG(FATAL, "SPI::Transaction returned something weird\n"); |
| 360 | } |
| 361 | |
| 362 | void SetDummySPI(frc::SPI::Port port) { |
| 363 | dummy_spi_.reset(new frc::SPI(port)); |
| 364 | // Pick the same settings here in case the roboRIO decides to try something |
| 365 | // stupid when switching. |
| 366 | if (dummy_spi_) { |
| 367 | dummy_spi_->SetClockRate(1e5); |
| 368 | dummy_spi_->SetChipSelectActiveLow(); |
| 369 | dummy_spi_->SetClockActiveLow(); |
| 370 | dummy_spi_->SetSampleDataOnFalling(); |
| 371 | dummy_spi_->SetMSBFirst(); |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | private: |
| 376 | frc::SPI *spi_ = nullptr; |
| 377 | ::std::unique_ptr<frc::SPI> dummy_spi_; |
| 378 | |
Brian Silverman | 7ecf067 | 2019-03-02 15:30:03 -0800 | [diff] [blame] | 379 | std::unique_ptr<frc::DigitalInput> activate_usb_; |
| 380 | std::unique_ptr<frc::DigitalInput> activate_passthrough_; |
| 381 | |
Brian Silverman | f8b7525 | 2019-02-24 16:13:58 -0800 | [diff] [blame] | 382 | frc971::wpilib::SpiRxClearer rx_clearer_; |
| 383 | }; |
| 384 | |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 385 | class SuperstructureWriter : public ::frc971::wpilib::LoopOutputHandler { |
| 386 | public: |
| 387 | void set_elevator_victor(::std::unique_ptr<::frc::VictorSP> t) { |
| 388 | elevator_victor_ = ::std::move(t); |
| 389 | } |
| 390 | |
Austin Schuh | 461e118 | 2019-02-17 14:56:44 -0800 | [diff] [blame] | 391 | void set_suction_victor(::std::unique_ptr<::frc::VictorSP> t) { |
| 392 | suction_victor_ = ::std::move(t); |
| 393 | } |
| 394 | |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 395 | void set_intake_victor(::std::unique_ptr<::frc::VictorSP> t) { |
| 396 | intake_victor_ = ::std::move(t); |
| 397 | } |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 398 | |
| 399 | void set_wrist_victor(::std::unique_ptr<::frc::VictorSP> t) { |
| 400 | wrist_victor_ = ::std::move(t); |
| 401 | } |
| 402 | |
| 403 | void set_stilts_victor(::std::unique_ptr<::frc::VictorSP> t) { |
| 404 | stilts_victor_ = ::std::move(t); |
| 405 | } |
| 406 | |
| 407 | private: |
Austin Schuh | 461e118 | 2019-02-17 14:56:44 -0800 | [diff] [blame] | 408 | void Read() override { |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 409 | ::y2019::control_loops::superstructure::superstructure_queue.output |
| 410 | .FetchAnother(); |
| 411 | } |
| 412 | |
Austin Schuh | 461e118 | 2019-02-17 14:56:44 -0800 | [diff] [blame] | 413 | void Write() override { |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 414 | auto &queue = |
| 415 | ::y2019::control_loops::superstructure::superstructure_queue.output; |
| 416 | LOG_STRUCT(DEBUG, "will output", *queue); |
Austin Schuh | 3e3d4ba | 2019-02-15 23:14:52 -0800 | [diff] [blame] | 417 | elevator_victor_->SetSpeed(::aos::Clip(queue->elevator_voltage, |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 418 | -kMaxBringupPower, |
| 419 | kMaxBringupPower) / |
| 420 | 12.0); |
| 421 | |
Austin Schuh | 3e3d4ba | 2019-02-15 23:14:52 -0800 | [diff] [blame] | 422 | intake_victor_->SetSpeed(::aos::Clip(queue->intake_joint_voltage, |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 423 | -kMaxBringupPower, kMaxBringupPower) / |
| 424 | 12.0); |
| 425 | |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 426 | wrist_victor_->SetSpeed(::aos::Clip(-queue->wrist_voltage, |
| 427 | -kMaxBringupPower, kMaxBringupPower) / |
| 428 | 12.0); |
| 429 | |
Austin Schuh | 3e3d4ba | 2019-02-15 23:14:52 -0800 | [diff] [blame] | 430 | stilts_victor_->SetSpeed(::aos::Clip(queue->stilts_voltage, |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 431 | -kMaxBringupPower, kMaxBringupPower) / |
| 432 | 12.0); |
Austin Schuh | 461e118 | 2019-02-17 14:56:44 -0800 | [diff] [blame] | 433 | |
Austin Schuh | c2ee66b | 2019-02-19 13:37:46 -0800 | [diff] [blame] | 434 | ::aos::robot_state.FetchLatest(); |
| 435 | const double battery_voltage = |
| 436 | ::aos::robot_state.get() ? ::aos::robot_state->voltage_battery : 12.0; |
| 437 | |
| 438 | // Throw a fast low pass filter on the battery voltage so we don't respond |
| 439 | // too fast to noise. |
| 440 | filtered_battery_voltage_ = |
| 441 | 0.5 * filtered_battery_voltage_ + 0.5 * battery_voltage; |
| 442 | |
| 443 | suction_victor_->SetSpeed(::aos::Clip( |
| 444 | queue->pump_voltage / filtered_battery_voltage_, -1.0, 1.0)); |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 445 | } |
| 446 | |
Austin Schuh | 461e118 | 2019-02-17 14:56:44 -0800 | [diff] [blame] | 447 | void Stop() override { |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 448 | LOG(WARNING, "Superstructure output too old.\n"); |
| 449 | |
| 450 | elevator_victor_->SetDisabled(); |
| 451 | intake_victor_->SetDisabled(); |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 452 | wrist_victor_->SetDisabled(); |
| 453 | stilts_victor_->SetDisabled(); |
Austin Schuh | 461e118 | 2019-02-17 14:56:44 -0800 | [diff] [blame] | 454 | suction_victor_->SetDisabled(); |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | ::std::unique_ptr<::frc::VictorSP> elevator_victor_, intake_victor_, |
Austin Schuh | 461e118 | 2019-02-17 14:56:44 -0800 | [diff] [blame] | 458 | wrist_victor_, stilts_victor_, suction_victor_; |
Austin Schuh | c2ee66b | 2019-02-19 13:37:46 -0800 | [diff] [blame] | 459 | |
| 460 | double filtered_battery_voltage_ = 12.0; |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 461 | }; |
| 462 | |
Austin Schuh | c1d6f83 | 2019-02-15 23:22:17 -0800 | [diff] [blame] | 463 | class SolenoidWriter { |
| 464 | public: |
| 465 | SolenoidWriter() |
| 466 | : superstructure_( |
| 467 | ".y2019.control_loops.superstructure.superstructure_queue.output") { |
| 468 | } |
| 469 | |
Austin Schuh | 461e118 | 2019-02-17 14:56:44 -0800 | [diff] [blame] | 470 | void set_big_suction_cup(int index0, int index1) { |
| 471 | big_suction_cup0_ = pcm_.MakeSolenoid(index0); |
| 472 | big_suction_cup1_ = pcm_.MakeSolenoid(index1); |
Austin Schuh | c1d6f83 | 2019-02-15 23:22:17 -0800 | [diff] [blame] | 473 | } |
Austin Schuh | 461e118 | 2019-02-17 14:56:44 -0800 | [diff] [blame] | 474 | void set_small_suction_cup(int index0, int index1) { |
| 475 | small_suction_cup0_ = pcm_.MakeSolenoid(index0); |
| 476 | small_suction_cup1_ = pcm_.MakeSolenoid(index1); |
Austin Schuh | c1d6f83 | 2019-02-15 23:22:17 -0800 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | void set_intake_roller_talon( |
| 480 | ::std::unique_ptr<::ctre::phoenix::motorcontrol::can::TalonSRX> t) { |
| 481 | intake_rollers_talon_ = ::std::move(t); |
Austin Schuh | 23a5163 | 2019-02-19 16:50:36 -0800 | [diff] [blame] | 482 | intake_rollers_talon_->ConfigContinuousCurrentLimit(10.0, 0); |
Austin Schuh | c1d6f83 | 2019-02-15 23:22:17 -0800 | [diff] [blame] | 483 | intake_rollers_talon_->EnableCurrentLimit(true); |
| 484 | } |
| 485 | |
| 486 | void operator()() { |
| 487 | ::aos::SetCurrentThreadName("Solenoids"); |
| 488 | ::aos::SetCurrentThreadRealtimePriority(27); |
| 489 | |
| 490 | ::aos::time::PhasedLoop phased_loop(::std::chrono::milliseconds(20), |
| 491 | ::std::chrono::milliseconds(1)); |
| 492 | |
| 493 | while (run_) { |
| 494 | { |
| 495 | const int iterations = phased_loop.SleepUntilNext(); |
| 496 | if (iterations != 1) { |
| 497 | LOG(DEBUG, "Solenoids skipped %d iterations\n", iterations - 1); |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | { |
| 502 | superstructure_.FetchLatest(); |
| 503 | if (superstructure_.get()) { |
| 504 | LOG_STRUCT(DEBUG, "solenoids", *superstructure_); |
| 505 | |
Tyler Chatow | 7db827f | 2019-02-24 00:10:13 -0800 | [diff] [blame] | 506 | big_suction_cup0_->Set(!superstructure_->intake_suction_bottom); |
| 507 | big_suction_cup1_->Set(!superstructure_->intake_suction_bottom); |
| 508 | small_suction_cup0_->Set(superstructure_->intake_suction_top); |
| 509 | small_suction_cup1_->Set(superstructure_->intake_suction_top); |
Austin Schuh | c1d6f83 | 2019-02-15 23:22:17 -0800 | [diff] [blame] | 510 | |
| 511 | intake_rollers_talon_->Set( |
| 512 | ctre::phoenix::motorcontrol::ControlMode::PercentOutput, |
| 513 | ::aos::Clip(superstructure_->intake_roller_voltage, |
| 514 | -kMaxBringupPower, kMaxBringupPower) / |
| 515 | 12.0); |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | { |
| 520 | ::frc971::wpilib::PneumaticsToLog to_log; |
| 521 | |
| 522 | pcm_.Flush(); |
| 523 | to_log.read_solenoids = pcm_.GetAll(); |
| 524 | LOG_STRUCT(DEBUG, "pneumatics info", to_log); |
| 525 | } |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | void Quit() { run_ = false; } |
| 530 | |
| 531 | private: |
| 532 | ::frc971::wpilib::BufferedPcm pcm_; |
| 533 | |
Austin Schuh | 461e118 | 2019-02-17 14:56:44 -0800 | [diff] [blame] | 534 | ::std::unique_ptr<::frc971::wpilib::BufferedSolenoid> big_suction_cup0_, |
| 535 | big_suction_cup1_, small_suction_cup0_, small_suction_cup1_; |
Austin Schuh | c1d6f83 | 2019-02-15 23:22:17 -0800 | [diff] [blame] | 536 | |
| 537 | ::std::unique_ptr<::ctre::phoenix::motorcontrol::can::TalonSRX> |
| 538 | intake_rollers_talon_; |
| 539 | |
| 540 | ::aos::Queue< |
| 541 | ::y2019::control_loops::superstructure::SuperstructureQueue::Output> |
| 542 | superstructure_; |
| 543 | |
| 544 | ::std::atomic<bool> run_{true}; |
| 545 | }; |
| 546 | |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 547 | class WPILibRobot : public ::frc971::wpilib::WPILibRobotBase { |
| 548 | public: |
| 549 | ::std::unique_ptr<frc::Encoder> make_encoder(int index) { |
| 550 | return make_unique<frc::Encoder>(10 + index * 2, 11 + index * 2, false, |
| 551 | frc::Encoder::k4X); |
| 552 | } |
| 553 | |
| 554 | void Run() override { |
| 555 | ::aos::InitNRT(); |
| 556 | ::aos::SetCurrentThreadName("StartCompetition"); |
| 557 | |
| 558 | ::frc971::wpilib::JoystickSender joystick_sender; |
| 559 | ::std::thread joystick_thread(::std::ref(joystick_sender)); |
| 560 | |
| 561 | ::frc971::wpilib::PDPFetcher pdp_fetcher; |
| 562 | ::std::thread pdp_fetcher_thread(::std::ref(pdp_fetcher)); |
| 563 | SensorReader reader; |
| 564 | |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 565 | reader.set_drivetrain_left_encoder(make_encoder(0)); |
| 566 | reader.set_drivetrain_right_encoder(make_encoder(1)); |
| 567 | |
Austin Schuh | 3e3d4ba | 2019-02-15 23:14:52 -0800 | [diff] [blame] | 568 | reader.set_elevator_encoder(make_encoder(4)); |
| 569 | reader.set_elevator_absolute_pwm(make_unique<frc::DigitalInput>(4)); |
| 570 | reader.set_elevator_potentiometer(make_unique<frc::AnalogInput>(4)); |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 571 | |
Austin Schuh | 3e3d4ba | 2019-02-15 23:14:52 -0800 | [diff] [blame] | 572 | reader.set_wrist_encoder(make_encoder(5)); |
| 573 | reader.set_wrist_absolute_pwm(make_unique<frc::DigitalInput>(5)); |
| 574 | reader.set_wrist_potentiometer(make_unique<frc::AnalogInput>(5)); |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 575 | |
Austin Schuh | 3e3d4ba | 2019-02-15 23:14:52 -0800 | [diff] [blame] | 576 | reader.set_intake_encoder(make_encoder(2)); |
| 577 | reader.set_intake_absolute_pwm(make_unique<frc::DigitalInput>(2)); |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 578 | |
Austin Schuh | 3e3d4ba | 2019-02-15 23:14:52 -0800 | [diff] [blame] | 579 | reader.set_stilts_encoder(make_encoder(3)); |
| 580 | reader.set_stilts_absolute_pwm(make_unique<frc::DigitalInput>(3)); |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 581 | reader.set_stilts_potentiometer(make_unique<frc::AnalogInput>(3)); |
| 582 | |
Austin Schuh | 3b010bc | 2019-02-24 17:25:37 -0800 | [diff] [blame] | 583 | reader.set_pwm_trigger(true); |
Austin Schuh | 461e118 | 2019-02-17 14:56:44 -0800 | [diff] [blame] | 584 | reader.set_vacuum_sensor(7); |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 585 | |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 586 | ::std::thread reader_thread(::std::ref(reader)); |
| 587 | |
Brian Silverman | f8b7525 | 2019-02-24 16:13:58 -0800 | [diff] [blame] | 588 | CameraReader camera_reader; |
| 589 | frc::SPI camera_spi(frc::SPI::Port::kOnboardCS3); |
| 590 | camera_reader.set_spi(&camera_spi); |
| 591 | camera_reader.SetDummySPI(frc::SPI::Port::kOnboardCS2); |
Brian Silverman | 7ecf067 | 2019-03-02 15:30:03 -0800 | [diff] [blame] | 592 | // Austin says 8, 9, 24, and 25 are good options to choose from for these. |
| 593 | camera_reader.set_activate_usb(make_unique<frc::DigitalInput>(24)); |
| 594 | camera_reader.set_activate_passthrough(make_unique<frc::DigitalInput>(25)); |
Brian Silverman | f8b7525 | 2019-02-24 16:13:58 -0800 | [diff] [blame] | 595 | |
Austin Schuh | 3e3d4ba | 2019-02-15 23:14:52 -0800 | [diff] [blame] | 596 | auto imu_trigger = make_unique<frc::DigitalInput>(0); |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 597 | ::frc971::wpilib::ADIS16448 imu(frc::SPI::Port::kOnboardCS1, |
| 598 | imu_trigger.get()); |
Brian Silverman | f8b7525 | 2019-02-24 16:13:58 -0800 | [diff] [blame] | 599 | imu.set_spi_idle_callback( |
| 600 | [&camera_reader]() { camera_reader.DoSpiTransaction(); }); |
Austin Schuh | 3e3d4ba | 2019-02-15 23:14:52 -0800 | [diff] [blame] | 601 | auto imu_reset = make_unique<frc::DigitalOutput>(1); |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 602 | imu.set_reset(imu_reset.get()); |
| 603 | ::std::thread imu_thread(::std::ref(imu)); |
| 604 | |
| 605 | // While as of 2/9/18 the drivetrain Victors are SPX, it appears as though |
| 606 | // they are identical, as far as DrivetrainWriter is concerned, to the SP |
| 607 | // variety so all the Victors are written as SPs. |
| 608 | |
Sabina Davis | d004fd6 | 2019-02-02 23:51:46 -0800 | [diff] [blame] | 609 | ::frc971::wpilib::DrivetrainWriter drivetrain_writer; |
| 610 | drivetrain_writer.set_left_controller0( |
Sabina Davis | 1b84afa | 2019-02-09 01:20:21 -0800 | [diff] [blame] | 611 | ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(0)), true); |
Sabina Davis | d004fd6 | 2019-02-02 23:51:46 -0800 | [diff] [blame] | 612 | drivetrain_writer.set_right_controller0( |
Sabina Davis | 1b84afa | 2019-02-09 01:20:21 -0800 | [diff] [blame] | 613 | ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(1)), false); |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 614 | ::std::thread drivetrain_writer_thread(::std::ref(drivetrain_writer)); |
| 615 | |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 616 | SuperstructureWriter superstructure_writer; |
| 617 | superstructure_writer.set_elevator_victor( |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 618 | ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(4))); |
Austin Schuh | 3e3d4ba | 2019-02-15 23:14:52 -0800 | [diff] [blame] | 619 | // TODO(austin): Do the vacuum |
Austin Schuh | 461e118 | 2019-02-17 14:56:44 -0800 | [diff] [blame] | 620 | superstructure_writer.set_suction_victor( |
| 621 | ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(6))); |
Austin Schuh | 3e3d4ba | 2019-02-15 23:14:52 -0800 | [diff] [blame] | 622 | superstructure_writer.set_intake_victor( |
| 623 | ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(2))); |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 624 | superstructure_writer.set_wrist_victor( |
| 625 | ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(5))); |
| 626 | superstructure_writer.set_stilts_victor( |
Austin Schuh | 3e3d4ba | 2019-02-15 23:14:52 -0800 | [diff] [blame] | 627 | ::std::unique_ptr<::frc::VictorSP>(new ::frc::VictorSP(3))); |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 628 | |
| 629 | ::std::thread superstructure_writer_thread( |
| 630 | ::std::ref(superstructure_writer)); |
| 631 | |
Austin Schuh | c1d6f83 | 2019-02-15 23:22:17 -0800 | [diff] [blame] | 632 | SolenoidWriter solenoid_writer; |
| 633 | solenoid_writer.set_intake_roller_talon( |
| 634 | make_unique<::ctre::phoenix::motorcontrol::can::TalonSRX>(10)); |
Austin Schuh | 461e118 | 2019-02-17 14:56:44 -0800 | [diff] [blame] | 635 | solenoid_writer.set_big_suction_cup(0, 1); |
| 636 | solenoid_writer.set_small_suction_cup(2, 3); |
Austin Schuh | c1d6f83 | 2019-02-15 23:22:17 -0800 | [diff] [blame] | 637 | |
| 638 | ::std::thread solenoid_writer_thread(::std::ref(solenoid_writer)); |
| 639 | |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 640 | // Wait forever. Not much else to do... |
| 641 | while (true) { |
| 642 | const int r = select(0, nullptr, nullptr, nullptr, nullptr); |
| 643 | if (r != 0) { |
| 644 | PLOG(WARNING, "infinite select failed"); |
| 645 | } else { |
| 646 | PLOG(WARNING, "infinite select succeeded??\n"); |
| 647 | } |
| 648 | } |
| 649 | |
| 650 | LOG(ERROR, "Exiting WPILibRobot\n"); |
| 651 | |
Austin Schuh | c1d6f83 | 2019-02-15 23:22:17 -0800 | [diff] [blame] | 652 | solenoid_writer.Quit(); |
| 653 | solenoid_writer_thread.join(); |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 654 | joystick_sender.Quit(); |
| 655 | joystick_thread.join(); |
| 656 | pdp_fetcher.Quit(); |
| 657 | pdp_fetcher_thread.join(); |
| 658 | reader.Quit(); |
| 659 | reader_thread.join(); |
| 660 | imu.Quit(); |
| 661 | imu_thread.join(); |
| 662 | |
| 663 | drivetrain_writer.Quit(); |
| 664 | drivetrain_writer_thread.join(); |
Alex Perry | 5fb5ff2 | 2019-02-09 21:53:17 -0800 | [diff] [blame] | 665 | superstructure_writer.Quit(); |
| 666 | superstructure_writer_thread.join(); |
Sabina Davis | abeae33 | 2019-02-01 21:12:57 -0800 | [diff] [blame] | 667 | |
| 668 | ::aos::Cleanup(); |
| 669 | } |
| 670 | }; |
| 671 | |
| 672 | } // namespace |
| 673 | } // namespace wpilib |
| 674 | } // namespace y2019 |
| 675 | |
| 676 | AOS_ROBOT_CLASS(::y2019::wpilib::WPILibRobot); |