Comran Morshed | 5323ecb | 2015-12-26 20:50:55 +0000 | [diff] [blame] | 1 | #include "frc971/control_loops/drivetrain/drivetrain.h" |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 2 | |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 3 | #include <sched.h> |
Austin Schuh | d749d93 | 2020-12-30 21:38:40 -0800 | [diff] [blame] | 4 | #include <stdio.h> |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 5 | #include <cmath> |
| 6 | #include <memory> |
| 7 | #include "Eigen/Dense" |
| 8 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 9 | #include "aos/logging/logging.h" |
Austin Schuh | 3a37846 | 2019-01-04 21:48:04 -0800 | [diff] [blame] | 10 | #include "frc971/control_loops/drivetrain/down_estimator.h" |
Austin Schuh | 3a37846 | 2019-01-04 21:48:04 -0800 | [diff] [blame] | 11 | #include "frc971/control_loops/drivetrain/drivetrain_config.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 12 | #include "frc971/control_loops/drivetrain/drivetrain_goal_generated.h" |
| 13 | #include "frc971/control_loops/drivetrain/drivetrain_output_generated.h" |
| 14 | #include "frc971/control_loops/drivetrain/drivetrain_position_generated.h" |
| 15 | #include "frc971/control_loops/drivetrain/drivetrain_status_generated.h" |
Comran Morshed | 5323ecb | 2015-12-26 20:50:55 +0000 | [diff] [blame] | 16 | #include "frc971/control_loops/drivetrain/polydrivetrain.h" |
| 17 | #include "frc971/control_loops/drivetrain/ssdrivetrain.h" |
Austin Schuh | 3a37846 | 2019-01-04 21:48:04 -0800 | [diff] [blame] | 18 | #include "frc971/control_loops/runge_kutta.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 19 | #include "frc971/queues/gyro_generated.h" |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 20 | #include "frc971/shifter_hall_effect.h" |
Austin Schuh | ac17fba | 2020-03-28 15:55:33 -0700 | [diff] [blame] | 21 | #include "frc971/wpilib/imu_batch_generated.h" |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 22 | |
Austin Schuh | 9993fb3 | 2017-03-15 20:17:46 -0700 | [diff] [blame] | 23 | using ::aos::monotonic_clock; |
| 24 | namespace chrono = ::std::chrono; |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 25 | |
Comran Morshed | 5323ecb | 2015-12-26 20:50:55 +0000 | [diff] [blame] | 26 | namespace frc971 { |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 27 | namespace control_loops { |
Austin Schuh | 6197a18 | 2015-11-28 16:04:40 -0800 | [diff] [blame] | 28 | namespace drivetrain { |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 29 | |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 30 | DrivetrainFilters::DrivetrainFilters(const DrivetrainConfig<double> &dt_config, |
| 31 | ::aos::EventLoop *event_loop, |
| 32 | LocalizerInterface *localizer) |
| 33 | : dt_config_(dt_config), |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 34 | localizer_control_fetcher_( |
| 35 | event_loop->MakeFetcher<LocalizerControl>("/drivetrain")), |
Austin Schuh | 73b6e3b | 2019-05-27 16:37:15 -0700 | [diff] [blame] | 36 | imu_values_fetcher_( |
Austin Schuh | ac17fba | 2020-03-28 15:55:33 -0700 | [diff] [blame] | 37 | event_loop->MakeFetcher<::frc971::IMUValuesBatch>("/drivetrain")), |
Austin Schuh | 1ea89bb | 2019-05-27 16:59:59 -0700 | [diff] [blame] | 38 | gyro_reading_fetcher_( |
| 39 | event_loop->MakeFetcher<::frc971::sensors::GyroReading>( |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 40 | "/drivetrain")), |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 41 | down_estimator_(dt_config_), |
James Kuszmaul | 3431d62 | 2019-02-17 17:07:44 -0800 | [diff] [blame] | 42 | localizer_(localizer), |
Austin Schuh | 4156560 | 2016-02-28 20:10:49 -0800 | [diff] [blame] | 43 | kf_(dt_config_.make_kf_drivetrain_loop()), |
Austin Schuh | 093535c | 2016-03-05 23:21:00 -0800 | [diff] [blame] | 44 | left_gear_(dt_config_.default_high_gear ? Gear::HIGH : Gear::LOW), |
| 45 | right_gear_(dt_config_.default_high_gear ? Gear::HIGH : Gear::LOW), |
| 46 | left_high_requested_(dt_config_.default_high_gear), |
| 47 | right_high_requested_(dt_config_.default_high_gear) { |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 48 | last_voltage_.setZero(); |
| 49 | last_last_voltage_.setZero(); |
| 50 | aos::controls::HPolytope<0>::Init(); |
James Kuszmaul | 30aca50 | 2020-01-19 15:05:33 -0800 | [diff] [blame] | 51 | event_loop->OnRun([this]() { |
| 52 | // On the first fetch, make sure that we are caught all the way up to the |
| 53 | // present. |
| 54 | imu_values_fetcher_.Fetch(); |
| 55 | }); |
James Kuszmaul | 2215d92 | 2020-02-11 17:17:26 -0800 | [diff] [blame] | 56 | if (dt_config.is_simulated) { |
| 57 | down_estimator_.assume_perfect_gravity(); |
| 58 | } |
Austin Schuh | 209f170 | 2015-11-29 17:03:00 -0800 | [diff] [blame] | 59 | } |
| 60 | |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 61 | flatbuffers::Offset<LocalizerState> DrivetrainFilters::PopulateLocalizerState( |
| 62 | flatbuffers::FlatBufferBuilder *fbb) { |
| 63 | return localizer_->PopulateStatus(fbb); |
| 64 | } |
| 65 | flatbuffers::Offset<ImuZeroerState> DrivetrainFilters::PopulateImuZeroerState( |
| 66 | flatbuffers::FlatBufferBuilder *fbb) { |
| 67 | return imu_zeroer_.PopulateStatus(fbb); |
Austin Schuh | 093535c | 2016-03-05 23:21:00 -0800 | [diff] [blame] | 68 | } |
| 69 | |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 70 | flatbuffers::Offset<DownEstimatorState> |
| 71 | DrivetrainFilters::PopulateDownEstimatorState( |
| 72 | flatbuffers::FlatBufferBuilder *fbb, |
| 73 | aos::monotonic_clock::time_point monotonic_now) { |
| 74 | return down_estimator_.PopulateStatus(fbb, monotonic_now); |
Austin Schuh | 093535c | 2016-03-05 23:21:00 -0800 | [diff] [blame] | 75 | } |
| 76 | |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 77 | void DrivetrainFilters::Reset(aos::monotonic_clock::time_point monotonic_now, |
| 78 | const drivetrain::Position *position) { |
| 79 | // If all the sensors got reset (e.g., due to wpilib_interface restarting), |
| 80 | // reset the localizer and down estimator to avoid weird jumps in the |
| 81 | // filters. |
| 82 | down_estimator_.Reset(); |
| 83 | // Just reset the localizer to the current state, except for the encoders. |
| 84 | LocalizerInterface::Ekf::State X_hat = localizer_->Xhat(); |
| 85 | X_hat(LocalizerInterface::StateIdx::kLeftEncoder) = position->left_encoder(); |
| 86 | X_hat(LocalizerInterface::StateIdx::kRightEncoder) = |
| 87 | position->right_encoder(); |
| 88 | localizer_->Reset(monotonic_now, X_hat); |
| 89 | } |
Austin Schuh | 9993fb3 | 2017-03-15 20:17:46 -0700 | [diff] [blame] | 90 | |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 91 | void DrivetrainFilters::Correct(aos::monotonic_clock::time_point monotonic_now, |
| 92 | const drivetrain::Position *position) { |
Austin Schuh | 093535c | 2016-03-05 23:21:00 -0800 | [diff] [blame] | 93 | // TODO(austin): Put gear detection logic here. |
| 94 | switch (dt_config_.shifter_type) { |
| 95 | case ShifterType::SIMPLE_SHIFTER: |
| 96 | // Force the right controller for simple shifters since we assume that |
| 97 | // gear switching is instantaneous. |
| 98 | if (left_high_requested_) { |
| 99 | left_gear_ = Gear::HIGH; |
| 100 | } else { |
| 101 | left_gear_ = Gear::LOW; |
| 102 | } |
| 103 | if (right_high_requested_) { |
| 104 | right_gear_ = Gear::HIGH; |
| 105 | } else { |
| 106 | right_gear_ = Gear::LOW; |
| 107 | } |
| 108 | break; |
| 109 | case ShifterType::HALL_EFFECT_SHIFTER: |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 110 | left_gear_ = ComputeGear(position->left_shifter_position(), |
Austin Schuh | 093535c | 2016-03-05 23:21:00 -0800 | [diff] [blame] | 111 | dt_config_.left_drive, left_high_requested_); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 112 | right_gear_ = ComputeGear(position->right_shifter_position(), |
Austin Schuh | 093535c | 2016-03-05 23:21:00 -0800 | [diff] [blame] | 113 | dt_config_.right_drive, right_high_requested_); |
| 114 | break; |
Adam Snaider | 18f4417 | 2016-10-22 15:30:21 -0700 | [diff] [blame] | 115 | case ShifterType::NO_SHIFTER: |
| 116 | break; |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 117 | } |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 118 | |
James Kuszmaul | 3e1bb27 | 2020-01-17 18:38:19 -0800 | [diff] [blame] | 119 | while (imu_values_fetcher_.FetchNext()) { |
Austin Schuh | ac17fba | 2020-03-28 15:55:33 -0700 | [diff] [blame] | 120 | CHECK(imu_values_fetcher_->has_readings()); |
James Kuszmaul | 3e1bb27 | 2020-01-17 18:38:19 -0800 | [diff] [blame] | 121 | last_gyro_time_ = monotonic_now; |
Austin Schuh | ac17fba | 2020-03-28 15:55:33 -0700 | [diff] [blame] | 122 | for (const IMUValues *value : *imu_values_fetcher_->readings()) { |
| 123 | imu_zeroer_.InsertMeasurement(*value); |
| 124 | if (!imu_zeroer_.Zeroed()) { |
| 125 | continue; |
| 126 | } |
| 127 | const aos::monotonic_clock::time_point reading_time( |
| 128 | std::chrono::nanoseconds(value->monotonic_timestamp_ns())); |
| 129 | if (last_imu_update_ == aos::monotonic_clock::min_time) { |
| 130 | last_imu_update_ = reading_time; |
| 131 | } |
| 132 | down_estimator_.Predict(imu_zeroer_.ZeroedGyro(), |
| 133 | imu_zeroer_.ZeroedAccel(), |
| 134 | reading_time - last_imu_update_); |
James Kuszmaul | 3e1bb27 | 2020-01-17 18:38:19 -0800 | [diff] [blame] | 135 | last_imu_update_ = reading_time; |
| 136 | } |
James Kuszmaul | 3e1bb27 | 2020-01-17 18:38:19 -0800 | [diff] [blame] | 137 | } |
Diana Burgess | d0180f1 | 2018-03-21 21:24:17 -0700 | [diff] [blame] | 138 | |
James Kuszmaul | 3e1bb27 | 2020-01-17 18:38:19 -0800 | [diff] [blame] | 139 | bool got_imu_reading = false; |
| 140 | if (imu_values_fetcher_.get() != nullptr) { |
James Kuszmaul | b7f45bb | 2020-02-26 20:27:48 -0800 | [diff] [blame] | 141 | imu_zeroer_.ProcessMeasurements(); |
James Kuszmaul | 3e1bb27 | 2020-01-17 18:38:19 -0800 | [diff] [blame] | 142 | got_imu_reading = true; |
Austin Schuh | ac17fba | 2020-03-28 15:55:33 -0700 | [diff] [blame] | 143 | CHECK(imu_values_fetcher_->has_readings()); |
| 144 | const IMUValues *value = imu_values_fetcher_->readings()->Get( |
| 145 | imu_values_fetcher_->readings()->size() - 1); |
Diana Burgess | d0180f1 | 2018-03-21 21:24:17 -0700 | [diff] [blame] | 146 | switch (dt_config_.imu_type) { |
| 147 | case IMUType::IMU_X: |
Austin Schuh | ac17fba | 2020-03-28 15:55:33 -0700 | [diff] [blame] | 148 | last_accel_ = -value->accelerometer_x(); |
Diana Burgess | d0180f1 | 2018-03-21 21:24:17 -0700 | [diff] [blame] | 149 | break; |
Austin Schuh | e7f6ddf | 2019-03-22 20:29:49 -0700 | [diff] [blame] | 150 | case IMUType::IMU_FLIPPED_X: |
Austin Schuh | ac17fba | 2020-03-28 15:55:33 -0700 | [diff] [blame] | 151 | last_accel_ = value->accelerometer_x(); |
Austin Schuh | e7f6ddf | 2019-03-22 20:29:49 -0700 | [diff] [blame] | 152 | break; |
Diana Burgess | d0180f1 | 2018-03-21 21:24:17 -0700 | [diff] [blame] | 153 | case IMUType::IMU_Y: |
Austin Schuh | ac17fba | 2020-03-28 15:55:33 -0700 | [diff] [blame] | 154 | last_accel_ = -value->accelerometer_y(); |
Diana Burgess | d0180f1 | 2018-03-21 21:24:17 -0700 | [diff] [blame] | 155 | break; |
James Kuszmaul | 7f55f07 | 2020-03-01 10:21:26 -0800 | [diff] [blame] | 156 | case IMUType::IMU_Z: |
Austin Schuh | ac17fba | 2020-03-28 15:55:33 -0700 | [diff] [blame] | 157 | last_accel_ = value->accelerometer_z(); |
James Kuszmaul | 7f55f07 | 2020-03-01 10:21:26 -0800 | [diff] [blame] | 158 | break; |
Diana Burgess | d0180f1 | 2018-03-21 21:24:17 -0700 | [diff] [blame] | 159 | } |
Austin Schuh | 05c5a61 | 2016-04-02 15:10:25 -0700 | [diff] [blame] | 160 | } |
Austin Schuh | 05c5a61 | 2016-04-02 15:10:25 -0700 | [diff] [blame] | 161 | |
Austin Schuh | 093535c | 2016-03-05 23:21:00 -0800 | [diff] [blame] | 162 | // TODO(austin): Signal the current gear to both loops. |
| 163 | |
Campbell Crowley | 2527ed2 | 2017-02-17 21:10:02 -0800 | [diff] [blame] | 164 | switch (dt_config_.gyro_type) { |
| 165 | case GyroType::IMU_X_GYRO: |
James Kuszmaul | 3e1bb27 | 2020-01-17 18:38:19 -0800 | [diff] [blame] | 166 | if (got_imu_reading) { |
| 167 | last_gyro_rate_ = imu_zeroer_.ZeroedGyro().x(); |
Campbell Crowley | 2527ed2 | 2017-02-17 21:10:02 -0800 | [diff] [blame] | 168 | } |
| 169 | break; |
| 170 | case GyroType::IMU_Y_GYRO: |
James Kuszmaul | 3e1bb27 | 2020-01-17 18:38:19 -0800 | [diff] [blame] | 171 | if (got_imu_reading) { |
| 172 | last_gyro_rate_ = imu_zeroer_.ZeroedGyro().y(); |
Campbell Crowley | 2527ed2 | 2017-02-17 21:10:02 -0800 | [diff] [blame] | 173 | } |
| 174 | break; |
| 175 | case GyroType::IMU_Z_GYRO: |
James Kuszmaul | 3e1bb27 | 2020-01-17 18:38:19 -0800 | [diff] [blame] | 176 | if (got_imu_reading) { |
| 177 | last_gyro_rate_ = imu_zeroer_.ZeroedGyro().z(); |
Campbell Crowley | 2527ed2 | 2017-02-17 21:10:02 -0800 | [diff] [blame] | 178 | } |
| 179 | break; |
Austin Schuh | 90b43b4 | 2019-01-04 07:45:05 +1100 | [diff] [blame] | 180 | case GyroType::FLIPPED_IMU_Z_GYRO: |
James Kuszmaul | 3e1bb27 | 2020-01-17 18:38:19 -0800 | [diff] [blame] | 181 | if (got_imu_reading) { |
| 182 | last_gyro_rate_ = -imu_zeroer_.ZeroedGyro().z(); |
Austin Schuh | 90b43b4 | 2019-01-04 07:45:05 +1100 | [diff] [blame] | 183 | } |
| 184 | break; |
Campbell Crowley | 2527ed2 | 2017-02-17 21:10:02 -0800 | [diff] [blame] | 185 | case GyroType::SPARTAN_GYRO: |
Austin Schuh | 1ea89bb | 2019-05-27 16:59:59 -0700 | [diff] [blame] | 186 | if (gyro_reading_fetcher_.Fetch()) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 187 | last_gyro_rate_ = gyro_reading_fetcher_->velocity(); |
Austin Schuh | 9993fb3 | 2017-03-15 20:17:46 -0700 | [diff] [blame] | 188 | last_gyro_time_ = monotonic_now; |
Campbell Crowley | 2527ed2 | 2017-02-17 21:10:02 -0800 | [diff] [blame] | 189 | } |
| 190 | break; |
| 191 | case GyroType::FLIPPED_SPARTAN_GYRO: |
Austin Schuh | 1ea89bb | 2019-05-27 16:59:59 -0700 | [diff] [blame] | 192 | if (gyro_reading_fetcher_.Fetch()) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 193 | last_gyro_rate_ = -gyro_reading_fetcher_->velocity(); |
Austin Schuh | 9993fb3 | 2017-03-15 20:17:46 -0700 | [diff] [blame] | 194 | last_gyro_time_ = monotonic_now; |
Campbell Crowley | 2527ed2 | 2017-02-17 21:10:02 -0800 | [diff] [blame] | 195 | } |
| 196 | break; |
| 197 | default: |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 198 | AOS_LOG(FATAL, "invalid gyro configured"); |
Campbell Crowley | 2527ed2 | 2017-02-17 21:10:02 -0800 | [diff] [blame] | 199 | break; |
Austin Schuh | 9ab4d9d | 2016-02-16 23:55:44 -0800 | [diff] [blame] | 200 | } |
| 201 | |
James Kuszmaul | ddc6970 | 2021-03-24 21:55:03 -0700 | [diff] [blame^] | 202 | ready_ = imu_zeroer_.Zeroed(); |
| 203 | |
| 204 | // TODO(james): How aggressively can we fault here? If we fault to |
| 205 | // aggressively, we might have issues during startup if wpilib_interface takes |
| 206 | // too long to start publishing IMU measurements. |
Austin Schuh | 9993fb3 | 2017-03-15 20:17:46 -0700 | [diff] [blame] | 207 | if (monotonic_now > last_gyro_time_ + chrono::milliseconds(20)) { |
| 208 | last_gyro_rate_ = 0.0; |
| 209 | } |
| 210 | |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 211 | localizer_->Update( |
| 212 | {last_last_voltage_(kLeftVoltage), last_last_voltage_(kRightVoltage)}, |
| 213 | monotonic_now, position->left_encoder(), position->right_encoder(), |
| 214 | down_estimator_.avg_recent_yaw_rates(), |
| 215 | down_estimator_.avg_recent_accel()); |
| 216 | |
| 217 | // If we get a new message setting the absolute position, then reset the |
| 218 | // localizer. |
| 219 | if (localizer_control_fetcher_.Fetch()) { |
| 220 | VLOG(1) << "localizer_control " |
| 221 | << aos::FlatbufferToJson(localizer_control_fetcher_.get()); |
| 222 | localizer_->ResetPosition( |
| 223 | monotonic_now, localizer_control_fetcher_->x(), |
| 224 | localizer_control_fetcher_->y(), localizer_control_fetcher_->theta(), |
| 225 | localizer_control_fetcher_->theta_uncertainty(), |
| 226 | !localizer_control_fetcher_->keep_current_theta()); |
| 227 | } |
| 228 | |
| 229 | kf_.set_index(ControllerIndexFromGears()); |
| 230 | |
Austin Schuh | 6613a07 | 2016-01-06 19:54:48 -0800 | [diff] [blame] | 231 | { |
Diana Burgess | d0180f1 | 2018-03-21 21:24:17 -0700 | [diff] [blame] | 232 | Eigen::Matrix<double, 4, 1> Y; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 233 | Y << position->left_encoder(), position->right_encoder(), last_gyro_rate_, |
Diana Burgess | d0180f1 | 2018-03-21 21:24:17 -0700 | [diff] [blame] | 234 | last_accel_; |
Austin Schuh | 6613a07 | 2016-01-06 19:54:48 -0800 | [diff] [blame] | 235 | kf_.Correct(Y); |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 236 | } |
| 237 | } |
| 238 | |
| 239 | Eigen::Matrix<double, 2, 1> DrivetrainFilters::VoltageError() const { |
| 240 | static_assert(kLeftError + 1 == kRightError); |
| 241 | Eigen::Matrix<double, 2, 2> error_K; |
| 242 | error_K << kf_.controller().K(kLeftVoltage, kLeftError), 0.0, 0.0, |
| 243 | kf_.controller().K(kRightVoltage, kRightError); |
| 244 | const Eigen::Matrix<double, 2, 1> voltage_error = |
| 245 | error_K * kf_.X_hat().block<2, 1>(kLeftError, 0); |
| 246 | return voltage_error; |
| 247 | } |
| 248 | |
| 249 | void DrivetrainFilters::UpdateObserver(Eigen::Matrix<double, 2, 1> U) { |
| 250 | last_last_voltage_ = last_voltage_; |
| 251 | |
| 252 | kf_.UpdateObserver(last_voltage_, dt_config_.dt); |
| 253 | |
| 254 | last_voltage_ = U; |
| 255 | } |
| 256 | |
| 257 | int DrivetrainFilters::ControllerIndexFromGears() const { |
| 258 | if (MaybeHigh(left_gear_)) { |
| 259 | if (MaybeHigh(right_gear_)) { |
| 260 | return 3; |
| 261 | } else { |
| 262 | return 2; |
| 263 | } |
| 264 | } else { |
| 265 | if (MaybeHigh(right_gear_)) { |
| 266 | return 1; |
| 267 | } else { |
| 268 | return 0; |
James Kuszmaul | 891f4f1 | 2020-10-31 17:13:23 -0700 | [diff] [blame] | 269 | } |
Austin Schuh | 6613a07 | 2016-01-06 19:54:48 -0800 | [diff] [blame] | 270 | } |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 271 | } |
| 272 | flatbuffers::Offset<GearLogging> DrivetrainFilters::CreateGearLogging( |
| 273 | flatbuffers::FlatBufferBuilder *fbb) const { |
| 274 | GearLogging::Builder gear_logging_builder(*fbb); |
| 275 | gear_logging_builder.add_left_state(static_cast<uint32_t>(left_gear_)); |
| 276 | gear_logging_builder.add_right_state(static_cast<uint32_t>(right_gear_)); |
| 277 | gear_logging_builder.add_left_loop_high(MaybeHigh(left_gear_)); |
| 278 | gear_logging_builder.add_right_loop_high(MaybeHigh(right_gear_)); |
| 279 | gear_logging_builder.add_controller_index(ControllerIndexFromGears()); |
| 280 | return gear_logging_builder.Finish(); |
| 281 | } |
Austin Schuh | 6613a07 | 2016-01-06 19:54:48 -0800 | [diff] [blame] | 282 | |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 283 | Gear DrivetrainFilters::ComputeGear( |
| 284 | double shifter_position, const constants::ShifterHallEffect &shifter_config, |
| 285 | bool high_requested) const { |
| 286 | if (shifter_position < shifter_config.clear_low) { |
| 287 | return Gear::LOW; |
| 288 | } else if (shifter_position > shifter_config.clear_high) { |
| 289 | return Gear::HIGH; |
| 290 | } else { |
| 291 | if (high_requested) { |
| 292 | return Gear::SHIFTING_UP; |
| 293 | } else { |
| 294 | return Gear::SHIFTING_DOWN; |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | DrivetrainLoop::DrivetrainLoop(const DrivetrainConfig<double> &dt_config, |
| 300 | ::aos::EventLoop *event_loop, |
| 301 | LocalizerInterface *localizer, |
| 302 | const ::std::string &name) |
| 303 | : aos::controls::ControlLoop<Goal, Position, Status, Output>(event_loop, |
| 304 | name), |
| 305 | dt_config_(dt_config), |
| 306 | filters_(dt_config, event_loop, localizer), |
| 307 | dt_openloop_(dt_config_, filters_.kf()), |
| 308 | dt_closedloop_(dt_config_, filters_.kf(), localizer), |
| 309 | dt_spline_(dt_config_), |
| 310 | dt_line_follow_(dt_config_, localizer->target_selector()) { |
| 311 | event_loop->SetRuntimeRealtimePriority(30); |
| 312 | } |
| 313 | |
| 314 | void DrivetrainLoop::RunIteration( |
| 315 | const drivetrain::Goal *goal, const drivetrain::Position *position, |
| 316 | aos::Sender<drivetrain::Output>::Builder *output, |
| 317 | aos::Sender<drivetrain::Status>::Builder *status) { |
| 318 | const monotonic_clock::time_point monotonic_now = |
| 319 | event_loop()->monotonic_now(); |
| 320 | |
| 321 | if (!has_been_enabled_ && output) { |
| 322 | has_been_enabled_ = true; |
| 323 | } |
| 324 | |
| 325 | if (WasReset()) { |
| 326 | filters_.Reset(monotonic_now, position); |
| 327 | } |
| 328 | |
| 329 | filters_.Correct(monotonic_now, position); |
| 330 | |
| 331 | // Set the gear-logging parts of the status |
| 332 | CHECK(status); |
| 333 | flatbuffers::Offset<GearLogging> gear_logging_offset = |
| 334 | filters_.CreateGearLogging(status->fbb()); |
| 335 | |
| 336 | dt_openloop_.SetPosition(position, filters_.left_gear(), |
| 337 | filters_.right_gear()); |
Austin Schuh | 093535c | 2016-03-05 23:21:00 -0800 | [diff] [blame] | 338 | |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 339 | ControllerType controller_type = ControllerType::POLYDRIVE; |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 340 | if (goal) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 341 | controller_type = goal->controller_type(); |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 342 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 343 | dt_closedloop_.SetGoal(goal); |
| 344 | dt_openloop_.SetGoal(goal->wheel(), goal->throttle(), goal->quickturn(), |
| 345 | goal->highgear()); |
| 346 | dt_spline_.SetGoal(goal); |
| 347 | dt_line_follow_.SetGoal(monotonic_now, goal); |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 348 | } |
| 349 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 350 | dt_openloop_.Update(robot_state().voltage_battery()); |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 351 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 352 | dt_closedloop_.Update(output != nullptr && |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 353 | controller_type == ControllerType::MOTION_PROFILE); |
Austin Schuh | 78379ea | 2019-01-04 20:39:45 -0800 | [diff] [blame] | 354 | |
James Kuszmaul | e39cbcf | 2019-02-27 20:48:34 -0800 | [diff] [blame] | 355 | const Eigen::Matrix<double, 5, 1> trajectory_state = |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 356 | filters_.trajectory_state(); |
James Kuszmaul | e39cbcf | 2019-02-27 20:48:34 -0800 | [diff] [blame] | 357 | |
James Kuszmaul | 897ef1a | 2020-10-25 17:51:10 -0700 | [diff] [blame] | 358 | { |
| 359 | // TODO(james): The regular Kalman Filter's voltage error terms are |
| 360 | // currently unusable--either don't use voltage error at all for the spline |
| 361 | // following code, or use the EKF's voltage error estimates. |
| 362 | const Eigen::Matrix<double, 2, 1> voltage_error = |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 363 | 0 * filters_.VoltageError(); |
James Kuszmaul | 897ef1a | 2020-10-25 17:51:10 -0700 | [diff] [blame] | 364 | dt_spline_.Update( |
| 365 | output != nullptr && controller_type == ControllerType::SPLINE_FOLLOWER, |
| 366 | trajectory_state, voltage_error); |
| 367 | } |
James Kuszmaul | e39cbcf | 2019-02-27 20:48:34 -0800 | [diff] [blame] | 368 | |
James Kuszmaul | 38e7964 | 2019-03-09 15:48:27 -0800 | [diff] [blame] | 369 | dt_line_follow_.Update(monotonic_now, trajectory_state); |
Alex Perry | a71badb | 2019-02-06 19:40:41 -0800 | [diff] [blame] | 370 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 371 | OutputT output_struct; |
| 372 | |
Austin Schuh | 78379ea | 2019-01-04 20:39:45 -0800 | [diff] [blame] | 373 | switch (controller_type) { |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 374 | case ControllerType::POLYDRIVE: |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 375 | dt_openloop_.SetOutput(output != nullptr ? &output_struct : nullptr); |
Austin Schuh | 78379ea | 2019-01-04 20:39:45 -0800 | [diff] [blame] | 376 | break; |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 377 | case ControllerType::MOTION_PROFILE: |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 378 | dt_closedloop_.SetOutput(output != nullptr ? &output_struct : nullptr); |
Austin Schuh | 78379ea | 2019-01-04 20:39:45 -0800 | [diff] [blame] | 379 | break; |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 380 | case ControllerType::SPLINE_FOLLOWER: |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 381 | dt_spline_.SetOutput(output != nullptr ? &output_struct : nullptr); |
Alex Perry | 731b460 | 2019-02-02 22:13:01 -0800 | [diff] [blame] | 382 | break; |
Austin Schuh | 872723c | 2019-12-25 14:38:09 -0800 | [diff] [blame] | 383 | case ControllerType::LINE_FOLLOWER: |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 384 | if (!dt_line_follow_.SetOutput(output != nullptr ? &output_struct |
| 385 | : nullptr)) { |
James Kuszmaul | 5bc6fc9 | 2019-03-01 21:50:06 -0800 | [diff] [blame] | 386 | // If the line follow drivetrain was unable to execute (generally due to |
| 387 | // not having a target), execute the regular teleop drivetrain. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 388 | dt_openloop_.SetOutput(output != nullptr ? &output_struct : nullptr); |
James Kuszmaul | 5bc6fc9 | 2019-03-01 21:50:06 -0800 | [diff] [blame] | 389 | } |
James Kuszmaul | e39cbcf | 2019-02-27 20:48:34 -0800 | [diff] [blame] | 390 | break; |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 391 | } |
| 392 | |
Austin Schuh | 093535c | 2016-03-05 23:21:00 -0800 | [diff] [blame] | 393 | // The output should now contain the shift request. |
| 394 | |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 395 | // set the output status of the control loop state |
| 396 | if (status) { |
Austin Schuh | 093535c | 2016-03-05 23:21:00 -0800 | [diff] [blame] | 397 | Eigen::Matrix<double, 2, 1> linear = |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 398 | dt_config_.LeftRightToLinear(filters_.DrivetrainXHat()); |
Austin Schuh | 093535c | 2016-03-05 23:21:00 -0800 | [diff] [blame] | 399 | Eigen::Matrix<double, 2, 1> angular = |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 400 | dt_config_.LeftRightToAngular(filters_.DrivetrainXHat()); |
Austin Schuh | 093535c | 2016-03-05 23:21:00 -0800 | [diff] [blame] | 401 | |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 402 | angular(0, 0) = filters_.localizer_theta(); |
Austin Schuh | 093535c | 2016-03-05 23:21:00 -0800 | [diff] [blame] | 403 | |
| 404 | Eigen::Matrix<double, 4, 1> gyro_left_right = |
Austin Schuh | d91c0d2 | 2016-10-15 21:24:28 -0700 | [diff] [blame] | 405 | dt_config_.AngularLinearToLeftRight(linear, angular); |
Austin Schuh | 093535c | 2016-03-05 23:21:00 -0800 | [diff] [blame] | 406 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 407 | const flatbuffers::Offset<CIMLogging> cim_logging_offset = |
James Kuszmaul | af5dfad | 2020-01-03 20:02:54 -0800 | [diff] [blame] | 408 | dt_openloop_.PopulateShiftingStatus(status->fbb()); |
| 409 | |
| 410 | const flatbuffers::Offset<PolyDriveLogging> poly_drive_logging_offset = |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 411 | dt_openloop_.PopulateStatus(status->fbb()); |
Austin Schuh | 093535c | 2016-03-05 23:21:00 -0800 | [diff] [blame] | 412 | |
James Kuszmaul | 3e1bb27 | 2020-01-17 18:38:19 -0800 | [diff] [blame] | 413 | const flatbuffers::Offset<DownEstimatorState> down_estimator_state_offset = |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 414 | filters_.PopulateDownEstimatorState(status->fbb(), monotonic_now); |
James Kuszmaul | 2215d92 | 2020-02-11 17:17:26 -0800 | [diff] [blame] | 415 | |
James Kuszmaul | 3c5b4d3 | 2020-02-11 17:22:14 -0800 | [diff] [blame] | 416 | const flatbuffers::Offset<LocalizerState> localizer_offset = |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 417 | filters_.PopulateLocalizerState(status->fbb()); |
James Kuszmaul | 3c5b4d3 | 2020-02-11 17:22:14 -0800 | [diff] [blame] | 418 | |
James Kuszmaul | 2215d92 | 2020-02-11 17:17:26 -0800 | [diff] [blame] | 419 | const flatbuffers::Offset<ImuZeroerState> zeroer_offset = |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 420 | filters_.PopulateImuZeroerState(status->fbb()); |
James Kuszmaul | 3e1bb27 | 2020-01-17 18:38:19 -0800 | [diff] [blame] | 421 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 422 | flatbuffers::Offset<LineFollowLogging> line_follow_logging_offset = |
| 423 | dt_line_follow_.PopulateStatus(status); |
| 424 | flatbuffers::Offset<TrajectoryLogging> trajectory_logging_offset = |
| 425 | dt_spline_.MakeTrajectoryLogging(status); |
Austin Schuh | 093535c | 2016-03-05 23:21:00 -0800 | [diff] [blame] | 426 | |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 427 | Status::Builder builder = status->MakeBuilder<Status>(); |
Austin Schuh | 3a37846 | 2019-01-04 21:48:04 -0800 | [diff] [blame] | 428 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 429 | dt_closedloop_.PopulateStatus(&builder); |
Austin Schuh | 3a37846 | 2019-01-04 21:48:04 -0800 | [diff] [blame] | 430 | |
Austin Schuh | 95771d9 | 2021-01-23 14:42:25 -0800 | [diff] [blame] | 431 | builder.add_estimated_left_position(gyro_left_right(kLeftPosition)); |
| 432 | builder.add_estimated_right_position(gyro_left_right(kRightPosition)); |
Austin Schuh | 4156560 | 2016-02-28 20:10:49 -0800 | [diff] [blame] | 433 | |
Austin Schuh | 95771d9 | 2021-01-23 14:42:25 -0800 | [diff] [blame] | 434 | builder.add_estimated_left_velocity(gyro_left_right(kLeftVelocity)); |
| 435 | builder.add_estimated_right_velocity(gyro_left_right(kRightVelocity)); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 436 | |
| 437 | if (dt_spline_.enable()) { |
| 438 | dt_spline_.PopulateStatus(&builder); |
| 439 | } else { |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 440 | builder.add_robot_speed((filters_.DrivetrainXHat(kLeftVelocity) + |
| 441 | filters_.DrivetrainXHat(kRightVelocity)) / |
| 442 | 2.0); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 443 | builder.add_output_was_capped(dt_closedloop_.output_was_capped()); |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 444 | builder.add_uncapped_left_voltage( |
| 445 | filters_.DrivetrainUUncapped(kLeftVoltage)); |
| 446 | builder.add_uncapped_right_voltage( |
| 447 | filters_.DrivetrainUUncapped(kRightVoltage)); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 448 | } |
| 449 | |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 450 | builder.add_left_voltage_error(filters_.DrivetrainXHat(kLeftError)); |
| 451 | builder.add_right_voltage_error(filters_.DrivetrainXHat(kRightError)); |
| 452 | builder.add_estimated_angular_velocity_error( |
| 453 | filters_.DrivetrainXHat(kAngularError)); |
| 454 | builder.add_estimated_heading(filters_.localizer_theta()); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 455 | |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 456 | builder.add_x(filters_.x()); |
| 457 | builder.add_y(filters_.y()); |
| 458 | builder.add_theta(::aos::math::NormalizeAngle(filters_.localizer_theta())); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 459 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 460 | builder.add_cim_logging(cim_logging_offset); |
James Kuszmaul | af5dfad | 2020-01-03 20:02:54 -0800 | [diff] [blame] | 461 | builder.add_poly_drive_logging(poly_drive_logging_offset); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 462 | builder.add_gear_logging(gear_logging_offset); |
| 463 | builder.add_line_follow_logging(line_follow_logging_offset); |
| 464 | builder.add_trajectory_logging(trajectory_logging_offset); |
James Kuszmaul | 3e1bb27 | 2020-01-17 18:38:19 -0800 | [diff] [blame] | 465 | builder.add_down_estimator(down_estimator_state_offset); |
James Kuszmaul | 3c5b4d3 | 2020-02-11 17:22:14 -0800 | [diff] [blame] | 466 | builder.add_localizer(localizer_offset); |
James Kuszmaul | 2215d92 | 2020-02-11 17:17:26 -0800 | [diff] [blame] | 467 | builder.add_zeroing(zeroer_offset); |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 468 | status->Send(builder.Finish()); |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 469 | } |
Austin Schuh | 209f170 | 2015-11-29 17:03:00 -0800 | [diff] [blame] | 470 | |
James Kuszmaul | ddc6970 | 2021-03-24 21:55:03 -0700 | [diff] [blame^] | 471 | // If the filters aren't ready/valid, then disable all outputs (currently, |
| 472 | // this only happens if the IMU is faulted or has not zeroed). |
| 473 | // TODO(james): Add exceptions so that during competitive play the driver |
| 474 | // can retain minimal control of the robot. |
| 475 | if (!filters_.Ready()) { |
| 476 | output_struct.left_voltage = 0.0; |
| 477 | output_struct.right_voltage = 0.0; |
| 478 | } |
| 479 | |
Austin Schuh | 209f170 | 2015-11-29 17:03:00 -0800 | [diff] [blame] | 480 | double left_voltage = 0.0; |
| 481 | double right_voltage = 0.0; |
| 482 | if (output) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 483 | left_voltage = output_struct.left_voltage; |
| 484 | right_voltage = output_struct.right_voltage; |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 485 | filters_.set_left_high_requested(output_struct.left_high); |
| 486 | filters_.set_right_high_requested(output_struct.right_high); |
Austin Schuh | 209f170 | 2015-11-29 17:03:00 -0800 | [diff] [blame] | 487 | } |
| 488 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 489 | const double scalar = robot_state().voltage_battery() / 12.0; |
Austin Schuh | 209f170 | 2015-11-29 17:03:00 -0800 | [diff] [blame] | 490 | |
| 491 | left_voltage *= scalar; |
| 492 | right_voltage *= scalar; |
| 493 | |
Austin Schuh | 209f170 | 2015-11-29 17:03:00 -0800 | [diff] [blame] | 494 | // To validate, look at the following: |
| 495 | |
| 496 | // Observed - dx/dt velocity for left, right. |
| 497 | |
| 498 | // Angular velocity error compared to the gyro |
| 499 | // Gyro heading vs left-right |
| 500 | // Voltage error. |
| 501 | |
Austin Schuh | fb0f35c | 2021-02-14 21:25:29 -0800 | [diff] [blame] | 502 | { |
| 503 | Eigen::Matrix<double, 2, 1> U; |
| 504 | U(kLeftVoltage) = left_voltage; |
| 505 | U(kRightVoltage) = right_voltage; |
| 506 | filters_.UpdateObserver(U); |
| 507 | } |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 508 | |
| 509 | if (output) { |
| 510 | output->Send(Output::Pack(*output->fbb(), &output_struct)); |
| 511 | } |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 512 | } |
| 513 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 514 | flatbuffers::Offset<Output> DrivetrainLoop::Zero( |
| 515 | aos::Sender<Output>::Builder *output) { |
| 516 | Output::Builder builder = output->MakeBuilder<Output>(); |
| 517 | builder.add_left_voltage(0); |
| 518 | builder.add_right_voltage(0); |
| 519 | builder.add_left_high(dt_config_.default_high_gear); |
| 520 | builder.add_right_high(dt_config_.default_high_gear); |
| 521 | return builder.Finish(); |
Adam Snaider | bc918b6 | 2016-02-27 21:03:39 -0800 | [diff] [blame] | 522 | } |
| 523 | |
Austin Schuh | 6197a18 | 2015-11-28 16:04:40 -0800 | [diff] [blame] | 524 | } // namespace drivetrain |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 525 | } // namespace control_loops |
Comran Morshed | 5323ecb | 2015-12-26 20:50:55 +0000 | [diff] [blame] | 526 | } // namespace frc971 |