blob: 4e13a40746774043fbdb592c88b8c068eabb2d9d [file] [log] [blame]
Comran Morshed5323ecb2015-12-26 20:50:55 +00001#include "frc971/control_loops/drivetrain/drivetrain.h"
Brian Silverman17f503e2015-08-02 18:17:18 -07002
3#include <stdio.h>
4#include <sched.h>
5#include <cmath>
6#include <memory>
7#include "Eigen/Dense"
8
John Park33858a32018-09-28 23:05:48 -07009#include "aos/logging/logging.h"
10#include "aos/logging/queue_logging.h"
11#include "aos/logging/matrix_logging.h"
Brian Silverman17f503e2015-08-02 18:17:18 -070012
Austin Schuh3a378462019-01-04 21:48:04 -080013#include "frc971/control_loops/drivetrain/down_estimator.h"
Comran Morshed5323ecb2015-12-26 20:50:55 +000014#include "frc971/control_loops/drivetrain/drivetrain.q.h"
Austin Schuh3a378462019-01-04 21:48:04 -080015#include "frc971/control_loops/drivetrain/drivetrain_config.h"
Comran Morshed5323ecb2015-12-26 20:50:55 +000016#include "frc971/control_loops/drivetrain/polydrivetrain.h"
17#include "frc971/control_loops/drivetrain/ssdrivetrain.h"
Austin Schuh3a378462019-01-04 21:48:04 -080018#include "frc971/control_loops/runge_kutta.h"
Brian Silverman17f503e2015-08-02 18:17:18 -070019#include "frc971/queues/gyro.q.h"
20#include "frc971/shifter_hall_effect.h"
Austin Schuh05c5a612016-04-02 15:10:25 -070021#include "frc971/wpilib/imu.q.h"
Brian Silverman17f503e2015-08-02 18:17:18 -070022
Brian Silverman17f503e2015-08-02 18:17:18 -070023using frc971::sensors::gyro_reading;
Campbell Crowley2527ed22017-02-17 21:10:02 -080024using frc971::imu_values;
Austin Schuh9993fb32017-03-15 20:17:46 -070025using ::aos::monotonic_clock;
26namespace chrono = ::std::chrono;
Brian Silverman17f503e2015-08-02 18:17:18 -070027
Comran Morshed5323ecb2015-12-26 20:50:55 +000028namespace frc971 {
Brian Silverman17f503e2015-08-02 18:17:18 -070029namespace control_loops {
Austin Schuh6197a182015-11-28 16:04:40 -080030namespace drivetrain {
Brian Silverman17f503e2015-08-02 18:17:18 -070031
Austin Schuh55a13dc2019-01-27 22:39:03 -080032DrivetrainLoop::DrivetrainLoop(const DrivetrainConfig<double> &dt_config,
33 ::aos::EventLoop *event_loop,
James Kuszmaul3431d622019-02-17 17:07:44 -080034 LocalizerInterface *localizer,
Austin Schuh55a13dc2019-01-27 22:39:03 -080035 const ::std::string &name)
Comran Morshed5323ecb2015-12-26 20:50:55 +000036 : aos::controls::ControlLoop<::frc971::control_loops::DrivetrainQueue>(
Austin Schuh55a13dc2019-01-27 22:39:03 -080037 event_loop, name),
Comran Morshed5323ecb2015-12-26 20:50:55 +000038 dt_config_(dt_config),
James Kuszmaulef428a02019-03-02 22:19:41 -080039 localizer_control_fetcher_(event_loop->MakeFetcher<LocalizerControl>(
40 ".frc971.control_loops.drivetrain.localizer_control")),
James Kuszmaul3431d622019-02-17 17:07:44 -080041 localizer_(localizer),
Austin Schuh41565602016-02-28 20:10:49 -080042 kf_(dt_config_.make_kf_drivetrain_loop()),
43 dt_openloop_(dt_config_, &kf_),
James Kuszmaul3431d622019-02-17 17:07:44 -080044 dt_closedloop_(dt_config_, &kf_, localizer_),
Alex Perry731b4602019-02-02 22:13:01 -080045 dt_spline_(dt_config_),
James Kuszmaul5bc6fc92019-03-01 21:50:06 -080046 dt_line_follow_(dt_config_, localizer->target_selector()),
Austin Schuh05c5a612016-04-02 15:10:25 -070047 down_estimator_(MakeDownEstimatorLoop()),
Austin Schuh093535c2016-03-05 23:21:00 -080048 left_gear_(dt_config_.default_high_gear ? Gear::HIGH : Gear::LOW),
49 right_gear_(dt_config_.default_high_gear ? Gear::HIGH : Gear::LOW),
50 left_high_requested_(dt_config_.default_high_gear),
51 right_high_requested_(dt_config_.default_high_gear) {
Austin Schuh209f1702015-11-29 17:03:00 -080052 ::aos::controls::HPolytope<0>::Init();
Austin Schuh05c5a612016-04-02 15:10:25 -070053 down_U_.setZero();
Austin Schuh209f1702015-11-29 17:03:00 -080054}
55
Austin Schuh093535c2016-03-05 23:21:00 -080056int DrivetrainLoop::ControllerIndexFromGears() {
57 if (MaybeHigh(left_gear_)) {
58 if (MaybeHigh(right_gear_)) {
59 return 3;
60 } else {
61 return 2;
62 }
63 } else {
64 if (MaybeHigh(right_gear_)) {
65 return 1;
66 } else {
67 return 0;
68 }
69 }
70}
71
72Gear ComputeGear(double shifter_position,
73 const constants::ShifterHallEffect &shifter_config,
74 bool high_requested) {
75 if (shifter_position < shifter_config.clear_low) {
76 return Gear::LOW;
77 } else if (shifter_position > shifter_config.clear_high) {
78 return Gear::HIGH;
79 } else {
80 if (high_requested) {
81 return Gear::SHIFTING_UP;
82 } else {
83 return Gear::SHIFTING_DOWN;
84 }
85 }
86}
87
Austin Schuh6197a182015-11-28 16:04:40 -080088void DrivetrainLoop::RunIteration(
Comran Morshed5323ecb2015-12-26 20:50:55 +000089 const ::frc971::control_loops::DrivetrainQueue::Goal *goal,
90 const ::frc971::control_loops::DrivetrainQueue::Position *position,
91 ::frc971::control_loops::DrivetrainQueue::Output *output,
92 ::frc971::control_loops::DrivetrainQueue::Status *status) {
Austin Schuh9993fb32017-03-15 20:17:46 -070093 monotonic_clock::time_point monotonic_now = monotonic_clock::now();
94
Austin Schuh5900d142016-04-03 21:35:12 -070095 if (!has_been_enabled_ && output) {
96 has_been_enabled_ = true;
97 down_estimator_.mutable_X_hat(1, 0) = 0.0;
98 }
99
Austin Schuh093535c2016-03-05 23:21:00 -0800100 // TODO(austin): Put gear detection logic here.
101 switch (dt_config_.shifter_type) {
102 case ShifterType::SIMPLE_SHIFTER:
103 // Force the right controller for simple shifters since we assume that
104 // gear switching is instantaneous.
105 if (left_high_requested_) {
106 left_gear_ = Gear::HIGH;
107 } else {
108 left_gear_ = Gear::LOW;
109 }
110 if (right_high_requested_) {
111 right_gear_ = Gear::HIGH;
112 } else {
113 right_gear_ = Gear::LOW;
114 }
115 break;
116 case ShifterType::HALL_EFFECT_SHIFTER:
117 left_gear_ = ComputeGear(position->left_shifter_position,
118 dt_config_.left_drive, left_high_requested_);
119 right_gear_ = ComputeGear(position->right_shifter_position,
120 dt_config_.right_drive, right_high_requested_);
121 break;
Adam Snaider18f44172016-10-22 15:30:21 -0700122 case ShifterType::NO_SHIFTER:
123 break;
Brian Silverman17f503e2015-08-02 18:17:18 -0700124 }
Brian Silverman17f503e2015-08-02 18:17:18 -0700125
Austin Schuhc5fceb82017-02-25 16:24:12 -0800126 kf_.set_index(ControllerIndexFromGears());
Kyle Stachowicz2f3c20f2017-07-13 16:04:05 -0700127
128 // Set the gear-logging parts of the status
129 if (status) {
130 status->gear_logging.left_state = static_cast<uint32_t>(left_gear_);
131 status->gear_logging.right_state = static_cast<uint32_t>(right_gear_);
132 status->gear_logging.left_loop_high = MaybeHigh(left_gear_);
133 status->gear_logging.right_loop_high = MaybeHigh(right_gear_);
134 status->gear_logging.controller_index = kf_.index();
Austin Schuh093535c2016-03-05 23:21:00 -0800135 }
Kyle Stachowicz2f3c20f2017-07-13 16:04:05 -0700136
Campbell Crowley2527ed22017-02-17 21:10:02 -0800137 const bool is_latest_imu_values = ::frc971::imu_values.FetchLatest();
138 if (is_latest_imu_values) {
Austin Schuh05c5a612016-04-02 15:10:25 -0700139 const double rate = -::frc971::imu_values->gyro_y;
140 const double accel_squared = ::frc971::imu_values->accelerometer_x *
141 ::frc971::imu_values->accelerometer_x +
142 ::frc971::imu_values->accelerometer_y *
143 ::frc971::imu_values->accelerometer_y +
144 ::frc971::imu_values->accelerometer_z *
145 ::frc971::imu_values->accelerometer_z;
Austin Schuhf0c05762016-04-03 16:06:49 -0700146 const double angle = ::std::atan2(::frc971::imu_values->accelerometer_x,
147 ::frc971::imu_values->accelerometer_z) +
Austin Schuh05c5a612016-04-02 15:10:25 -0700148 0.008;
Diana Burgessd0180f12018-03-21 21:24:17 -0700149
150 switch (dt_config_.imu_type) {
151 case IMUType::IMU_X:
152 last_accel_ = -::frc971::imu_values->accelerometer_x;
153 break;
Austin Schuhe7f6ddf2019-03-22 20:29:49 -0700154 case IMUType::IMU_FLIPPED_X:
155 last_accel_ = ::frc971::imu_values->accelerometer_x;
156 break;
Diana Burgessd0180f12018-03-21 21:24:17 -0700157 case IMUType::IMU_Y:
158 last_accel_ = -::frc971::imu_values->accelerometer_y;
159 break;
160 }
161
Austin Schuh05c5a612016-04-02 15:10:25 -0700162 if (accel_squared > 1.03 || accel_squared < 0.97) {
163 LOG(DEBUG, "New IMU value, rejecting reading\n");
164 } else {
165 // -y is our gyro.
Austin Schuhf0c05762016-04-03 16:06:49 -0700166 // z accel is down
167 // x accel is the front of the robot pointed down.
Austin Schuh05c5a612016-04-02 15:10:25 -0700168 Eigen::Matrix<double, 1, 1> Y;
Austin Schuhdf79d112016-10-15 21:25:32 -0700169 Y(0, 0) = angle;
Austin Schuh05c5a612016-04-02 15:10:25 -0700170 down_estimator_.Correct(Y);
171 }
172
173 LOG(DEBUG,
Lee Mracek28313b02019-02-07 19:23:36 -0500174 "New IMU value, rate is %f, angle %f, fused %f, bias "
Austin Schuh05c5a612016-04-02 15:10:25 -0700175 "%f\n",
Austin Schuh3a378462019-01-04 21:48:04 -0800176 rate, angle, down_estimator_.X_hat(0), down_estimator_.X_hat(1));
Austin Schuhdf79d112016-10-15 21:25:32 -0700177 down_U_(0, 0) = rate;
Austin Schuh05c5a612016-04-02 15:10:25 -0700178 }
Austin Schuh3ad5ed82017-02-25 21:36:19 -0800179 down_estimator_.UpdateObserver(down_U_, ::aos::controls::kLoopFrequency);
Austin Schuh05c5a612016-04-02 15:10:25 -0700180
Austin Schuh093535c2016-03-05 23:21:00 -0800181 // TODO(austin): Signal the current gear to both loops.
182
Campbell Crowley2527ed22017-02-17 21:10:02 -0800183 switch (dt_config_.gyro_type) {
184 case GyroType::IMU_X_GYRO:
185 if (is_latest_imu_values) {
186 LOG_STRUCT(DEBUG, "using", *imu_values.get());
187 last_gyro_rate_ = imu_values->gyro_x;
Austin Schuh9993fb32017-03-15 20:17:46 -0700188 last_gyro_time_ = monotonic_now;
Campbell Crowley2527ed22017-02-17 21:10:02 -0800189 }
190 break;
191 case GyroType::IMU_Y_GYRO:
192 if (is_latest_imu_values) {
193 LOG_STRUCT(DEBUG, "using", *imu_values.get());
194 last_gyro_rate_ = imu_values->gyro_y;
Austin Schuh9993fb32017-03-15 20:17:46 -0700195 last_gyro_time_ = monotonic_now;
Campbell Crowley2527ed22017-02-17 21:10:02 -0800196 }
197 break;
198 case GyroType::IMU_Z_GYRO:
199 if (is_latest_imu_values) {
200 LOG_STRUCT(DEBUG, "using", *imu_values.get());
201 last_gyro_rate_ = imu_values->gyro_z;
Austin Schuh9993fb32017-03-15 20:17:46 -0700202 last_gyro_time_ = monotonic_now;
Campbell Crowley2527ed22017-02-17 21:10:02 -0800203 }
204 break;
Austin Schuh90b43b42019-01-04 07:45:05 +1100205 case GyroType::FLIPPED_IMU_Z_GYRO:
206 if (is_latest_imu_values) {
207 LOG_STRUCT(DEBUG, "using", *imu_values.get());
208 last_gyro_rate_ = -imu_values->gyro_z;
209 last_gyro_time_ = monotonic_now;
210 }
211 break;
Campbell Crowley2527ed22017-02-17 21:10:02 -0800212 case GyroType::SPARTAN_GYRO:
213 if (gyro_reading.FetchLatest()) {
214 LOG_STRUCT(DEBUG, "using", *gyro_reading.get());
215 last_gyro_rate_ = gyro_reading->velocity;
Austin Schuh9993fb32017-03-15 20:17:46 -0700216 last_gyro_time_ = monotonic_now;
Campbell Crowley2527ed22017-02-17 21:10:02 -0800217 }
218 break;
219 case GyroType::FLIPPED_SPARTAN_GYRO:
220 if (gyro_reading.FetchLatest()) {
221 LOG_STRUCT(DEBUG, "using", *gyro_reading.get());
222 last_gyro_rate_ = -gyro_reading->velocity;
Austin Schuh9993fb32017-03-15 20:17:46 -0700223 last_gyro_time_ = monotonic_now;
Campbell Crowley2527ed22017-02-17 21:10:02 -0800224 }
225 break;
226 default:
227 LOG(FATAL, "invalid gyro configured");
228 break;
Austin Schuh9ab4d9d2016-02-16 23:55:44 -0800229 }
230
Austin Schuh9993fb32017-03-15 20:17:46 -0700231 if (monotonic_now > last_gyro_time_ + chrono::milliseconds(20)) {
232 last_gyro_rate_ = 0.0;
233 }
234
Austin Schuh6613a072016-01-06 19:54:48 -0800235 {
Diana Burgessd0180f12018-03-21 21:24:17 -0700236 Eigen::Matrix<double, 4, 1> Y;
237 Y << position->left_encoder, position->right_encoder, last_gyro_rate_,
238 last_accel_;
Austin Schuh6613a072016-01-06 19:54:48 -0800239 kf_.Correct(Y);
James Kuszmaulef428a02019-03-02 22:19:41 -0800240 // If we get a new message setting the absolute position, then reset the
241 // localizer.
242 // TODO(james): Use a watcher (instead of a fetcher) once we support it in
243 // simulation.
244 if (localizer_control_fetcher_.Fetch()) {
James Kuszmaul074429e2019-03-23 16:01:49 -0700245 LOG_STRUCT(DEBUG, "localizer_control", *localizer_control_fetcher_);
James Kuszmaul518640d2019-04-13 15:50:50 -0700246 localizer_->ResetPosition(
247 monotonic_now, localizer_control_fetcher_->x,
248 localizer_control_fetcher_->y, localizer_control_fetcher_->theta,
249 localizer_control_fetcher_->theta_uncertainty,
250 !localizer_control_fetcher_->keep_current_theta);
James Kuszmaulef428a02019-03-02 22:19:41 -0800251 }
James Kuszmaulf3add3c2019-03-02 14:55:00 -0800252 localizer_->Update({last_last_left_voltage_, last_last_right_voltage_},
253 monotonic_now, position->left_encoder,
254 position->right_encoder, last_gyro_rate_, last_accel_);
Austin Schuh6613a072016-01-06 19:54:48 -0800255 }
256
Austin Schuh093535c2016-03-05 23:21:00 -0800257 dt_openloop_.SetPosition(position, left_gear_, right_gear_);
258
Austin Schuh78379ea2019-01-04 20:39:45 -0800259 int controller_type = 0;
Brian Silverman17f503e2015-08-02 18:17:18 -0700260 if (goal) {
Austin Schuh78379ea2019-01-04 20:39:45 -0800261 controller_type = goal->controller_type;
Brian Silverman17f503e2015-08-02 18:17:18 -0700262
Austin Schuh093535c2016-03-05 23:21:00 -0800263 dt_closedloop_.SetGoal(*goal);
264 dt_openloop_.SetGoal(*goal);
Alex Perry731b4602019-02-02 22:13:01 -0800265 dt_spline_.SetGoal(*goal);
James Kuszmaul38e79642019-03-09 15:48:27 -0800266 dt_line_follow_.SetGoal(monotonic_now, *goal);
Brian Silverman17f503e2015-08-02 18:17:18 -0700267 }
268
Austin Schuheeec74a2019-01-27 20:58:59 -0800269 dt_openloop_.Update(robot_state().voltage_battery);
Brian Silverman17f503e2015-08-02 18:17:18 -0700270
Austin Schuh78379ea2019-01-04 20:39:45 -0800271 dt_closedloop_.Update(output != NULL && controller_type == 1);
272
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800273 const Eigen::Matrix<double, 5, 1> trajectory_state =
274 (Eigen::Matrix<double, 5, 1>() << localizer_->x(), localizer_->y(),
275 localizer_->theta(), localizer_->left_velocity(),
276 localizer_->right_velocity())
277 .finished();
278
279 dt_spline_.Update(output != NULL && controller_type == 2, trajectory_state);
280
James Kuszmaul38e79642019-03-09 15:48:27 -0800281 dt_line_follow_.Update(monotonic_now, trajectory_state);
Alex Perrya71badb2019-02-06 19:40:41 -0800282
Austin Schuh78379ea2019-01-04 20:39:45 -0800283 switch (controller_type) {
284 case 0:
285 dt_openloop_.SetOutput(output);
286 break;
287 case 1:
288 dt_closedloop_.SetOutput(output);
289 break;
Alex Perry731b4602019-02-02 22:13:01 -0800290 case 2:
291 dt_spline_.SetOutput(output);
292 break;
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800293 case 3:
James Kuszmaul5bc6fc92019-03-01 21:50:06 -0800294 if (!dt_line_follow_.SetOutput(output)) {
295 // If the line follow drivetrain was unable to execute (generally due to
296 // not having a target), execute the regular teleop drivetrain.
297 dt_openloop_.SetOutput(output);
298 }
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800299 break;
Brian Silverman17f503e2015-08-02 18:17:18 -0700300 }
301
Austin Schuh093535c2016-03-05 23:21:00 -0800302 // The output should now contain the shift request.
303
Brian Silverman17f503e2015-08-02 18:17:18 -0700304 // set the output status of the control loop state
305 if (status) {
Austin Schuh3a378462019-01-04 21:48:04 -0800306 status->robot_speed = (kf_.X_hat(1) + kf_.X_hat(3)) / 2.0;
Brian Silverman17f503e2015-08-02 18:17:18 -0700307
Austin Schuh093535c2016-03-05 23:21:00 -0800308 Eigen::Matrix<double, 2, 1> linear =
Austin Schuhd91c0d22016-10-15 21:24:28 -0700309 dt_config_.LeftRightToLinear(kf_.X_hat());
Austin Schuh093535c2016-03-05 23:21:00 -0800310 Eigen::Matrix<double, 2, 1> angular =
Austin Schuhd91c0d22016-10-15 21:24:28 -0700311 dt_config_.LeftRightToAngular(kf_.X_hat());
Austin Schuh093535c2016-03-05 23:21:00 -0800312
James Kuszmaul3431d622019-02-17 17:07:44 -0800313 angular(0, 0) = localizer_->theta();
Austin Schuh093535c2016-03-05 23:21:00 -0800314
315 Eigen::Matrix<double, 4, 1> gyro_left_right =
Austin Schuhd91c0d22016-10-15 21:24:28 -0700316 dt_config_.AngularLinearToLeftRight(linear, angular);
Austin Schuh093535c2016-03-05 23:21:00 -0800317
318 status->estimated_left_position = gyro_left_right(0, 0);
319 status->estimated_right_position = gyro_left_right(2, 0);
320
321 status->estimated_left_velocity = gyro_left_right(1, 0);
322 status->estimated_right_velocity = gyro_left_right(3, 0);
323 status->output_was_capped = dt_closedloop_.output_was_capped();
324 status->uncapped_left_voltage = kf_.U_uncapped(0, 0);
325 status->uncapped_right_voltage = kf_.U_uncapped(1, 0);
326
Austin Schuh3a378462019-01-04 21:48:04 -0800327 status->left_voltage_error = kf_.X_hat(4);
328 status->right_voltage_error = kf_.X_hat(5);
329 status->estimated_angular_velocity_error = kf_.X_hat(6);
James Kuszmaul3431d622019-02-17 17:07:44 -0800330 status->estimated_heading = localizer_->theta();
Austin Schuh3a378462019-01-04 21:48:04 -0800331
James Kuszmaul3431d622019-02-17 17:07:44 -0800332 status->x = localizer_->x();
333 status->y = localizer_->y();
James Kuszmaul7f1a4082019-04-14 10:50:44 -0700334 status->theta = ::aos::math::NormalizeAngle(localizer_->theta());
Austin Schuh3a378462019-01-04 21:48:04 -0800335
336 status->ground_angle = down_estimator_.X_hat(0) + dt_config_.down_offset;
Austin Schuh41565602016-02-28 20:10:49 -0800337
338 dt_openloop_.PopulateStatus(status);
Austin Schuh093535c2016-03-05 23:21:00 -0800339 dt_closedloop_.PopulateStatus(status);
Alex Perrye32eabc2019-02-08 19:51:19 -0800340 dt_spline_.PopulateStatus(status);
James Kuszmaule39cbcf2019-02-27 20:48:34 -0800341 dt_line_follow_.PopulateStatus(status);
Brian Silverman17f503e2015-08-02 18:17:18 -0700342 }
Austin Schuh209f1702015-11-29 17:03:00 -0800343
Austin Schuh209f1702015-11-29 17:03:00 -0800344 double left_voltage = 0.0;
345 double right_voltage = 0.0;
346 if (output) {
347 left_voltage = output->left_voltage;
348 right_voltage = output->right_voltage;
Austin Schuh093535c2016-03-05 23:21:00 -0800349 left_high_requested_ = output->left_high;
350 right_high_requested_ = output->right_high;
Austin Schuh209f1702015-11-29 17:03:00 -0800351 }
352
Austin Schuheeec74a2019-01-27 20:58:59 -0800353 const double scalar = robot_state().voltage_battery / 12.0;
Austin Schuh209f1702015-11-29 17:03:00 -0800354
355 left_voltage *= scalar;
356 right_voltage *= scalar;
357
Austin Schuh209f1702015-11-29 17:03:00 -0800358 // To validate, look at the following:
359
360 // Observed - dx/dt velocity for left, right.
361
362 // Angular velocity error compared to the gyro
363 // Gyro heading vs left-right
364 // Voltage error.
365
James Kuszmaulf3add3c2019-03-02 14:55:00 -0800366 last_last_left_voltage_ = last_left_voltage_;
367 last_last_right_voltage_ = last_right_voltage_;
Austin Schuh209f1702015-11-29 17:03:00 -0800368 Eigen::Matrix<double, 2, 1> U;
Austin Schuhdf79d112016-10-15 21:25:32 -0700369 U(0, 0) = last_left_voltage_;
370 U(1, 0) = last_right_voltage_;
Austin Schuh209f1702015-11-29 17:03:00 -0800371 last_left_voltage_ = left_voltage;
372 last_right_voltage_ = right_voltage;
373
Austin Schuh3a378462019-01-04 21:48:04 -0800374 last_state_ = kf_.X_hat();
375 kf_.UpdateObserver(U, dt_config_.dt);
Brian Silverman17f503e2015-08-02 18:17:18 -0700376}
377
Adam Snaiderbc918b62016-02-27 21:03:39 -0800378void DrivetrainLoop::Zero(
379 ::frc971::control_loops::DrivetrainQueue::Output *output) {
380 output->left_voltage = 0;
381 output->right_voltage = 0;
382 output->left_high = dt_config_.default_high_gear;
383 output->right_high = dt_config_.default_high_gear;
384}
385
Austin Schuh6197a182015-11-28 16:04:40 -0800386} // namespace drivetrain
Brian Silverman17f503e2015-08-02 18:17:18 -0700387} // namespace control_loops
Comran Morshed5323ecb2015-12-26 20:50:55 +0000388} // namespace frc971