blob: 122e2d21b405ab95023459abfdf656c88b69a889 [file] [log] [blame]
James Kuszmaulf254c1a2013-03-10 16:31:26 -07001#include "frc971/control_loops/drivetrain/drivetrain.h"
brians343bc112013-02-10 01:53:46 +00002
3#include <stdio.h>
4#include <sched.h>
5#include <cmath>
Austin Schuh4352ac62013-03-19 06:23:16 +00006#include <memory>
Austin Schuh2054f5f2013-10-27 14:54:10 -07007#include "Eigen/Dense"
brians343bc112013-02-10 01:53:46 +00008
brians343bc112013-02-10 01:53:46 +00009#include "aos/common/logging/logging.h"
10#include "aos/common/queue.h"
Austin Schuh2054f5f2013-10-27 14:54:10 -070011#include "aos/controls/polytope.h"
12#include "aos/common/commonmath.h"
James Kuszmaulf254c1a2013-03-10 16:31:26 -070013#include "frc971/control_loops/state_feedback_loop.h"
14#include "frc971/control_loops/drivetrain/drivetrain_motor_plant.h"
Austin Schuh2054f5f2013-10-27 14:54:10 -070015#include "frc971/control_loops/drivetrain/polydrivetrain_motor_plant.h"
James Kuszmaulf254c1a2013-03-10 16:31:26 -070016#include "frc971/control_loops/drivetrain/drivetrain.q.h"
brians343bc112013-02-10 01:53:46 +000017#include "frc971/queues/GyroAngle.q.h"
18#include "frc971/queues/Piston.q.h"
19
20using frc971::sensors::gyro;
21
22namespace frc971 {
23namespace control_loops {
24
25// Width of the robot.
26const double width = 22.0 / 100.0 * 2.54;
27
Austin Schuh2054f5f2013-10-27 14:54:10 -070028Eigen::Matrix<double, 2, 1> CoerceGoal(aos::controls::HPolytope<2> &region,
29 const Eigen::Matrix<double, 1, 2> &K,
30 double w,
31 const Eigen::Matrix<double, 2, 1> &R) {
32 if (region.IsInside(R)) {
33 return R;
34 }
35 Eigen::Matrix<double, 2, 1> parallel_vector;
36 Eigen::Matrix<double, 2, 1> perpendicular_vector;
37 perpendicular_vector = K.transpose().normalized();
38 parallel_vector << perpendicular_vector(1, 0), -perpendicular_vector(0, 0);
39
40 aos::controls::HPolytope<1> t_poly(
41 region.H() * parallel_vector,
42 region.k() - region.H() * perpendicular_vector * w);
43
44 Eigen::Matrix<double, 1, Eigen::Dynamic> vertices = t_poly.Vertices();
45 if (vertices.innerSize() > 0) {
46 double min_distance_sqr = 0;
47 Eigen::Matrix<double, 2, 1> closest_point;
48 for (int i = 0; i < vertices.innerSize(); i++) {
49 Eigen::Matrix<double, 2, 1> point;
50 point = parallel_vector * vertices(0, i) + perpendicular_vector * w;
51 const double length = (R - point).squaredNorm();
52 if (i == 0 || length < min_distance_sqr) {
53 closest_point = point;
54 min_distance_sqr = length;
55 }
56 }
57 return closest_point;
58 } else {
59 Eigen::Matrix<double, 2, Eigen::Dynamic> region_vertices =
60 region.Vertices();
61 double min_distance;
62 int closest_i = 0;
63 for (int i = 0; i < region_vertices.outerSize(); i++) {
64 const double length = ::std::abs(
65 (perpendicular_vector.transpose() * (region_vertices.col(i)))(0, 0));
66 if (i == 0 || length < min_distance) {
67 closest_i = i;
68 min_distance = length;
69 }
70 }
71 return region_vertices.col(closest_i);
72 }
73}
74
Austin Schuh4352ac62013-03-19 06:23:16 +000075class DrivetrainMotorsSS {
brians343bc112013-02-10 01:53:46 +000076 public:
Austin Schuh4352ac62013-03-19 06:23:16 +000077 DrivetrainMotorsSS ()
78 : loop_(new StateFeedbackLoop<4, 2, 2>(MakeDrivetrainLoop())) {
brians343bc112013-02-10 01:53:46 +000079 _offset = 0;
80 _integral_offset = 0;
81 _left_goal = 0.0;
82 _right_goal = 0.0;
83 _raw_left = 0.0;
84 _raw_right = 0.0;
Austin Schuh4352ac62013-03-19 06:23:16 +000085 _control_loop_driving = false;
brians343bc112013-02-10 01:53:46 +000086 }
87 void SetGoal(double left, double left_velocity, double right, double right_velocity) {
88 _left_goal = left;
89 _right_goal = right;
Austin Schuh4352ac62013-03-19 06:23:16 +000090 loop_->R << left, left_velocity, right, right_velocity;
brians343bc112013-02-10 01:53:46 +000091 }
92 void SetRawPosition(double left, double right) {
93 _raw_right = right;
94 _raw_left = left;
Austin Schuh4352ac62013-03-19 06:23:16 +000095 loop_->Y << left, right;
brians343bc112013-02-10 01:53:46 +000096 }
Austin Schuh4352ac62013-03-19 06:23:16 +000097 void SetPosition(
98 double left, double right, double gyro, bool control_loop_driving) {
brians343bc112013-02-10 01:53:46 +000099 // Decay the offset quickly because this gyro is great.
100 _offset = (0.25) * (right - left - gyro * width) / 2.0 + 0.75 * _offset;
101 const double angle_error = (_right_goal - _left_goal) / width - (_raw_right - _offset - _raw_left - _offset) / width;
Austin Schuh4352ac62013-03-19 06:23:16 +0000102 // TODO(aschuh): Add in the gyro.
103 _integral_offset = 0.0;
104 _offset = 0.0;
brians343bc112013-02-10 01:53:46 +0000105 _gyro = gyro;
Austin Schuh4352ac62013-03-19 06:23:16 +0000106 _control_loop_driving = control_loop_driving;
brians343bc112013-02-10 01:53:46 +0000107 SetRawPosition(left, right);
108 LOG(DEBUG, "Left %f->%f Right %f->%f Gyro %f aerror %f ioff %f\n", left + _offset, _left_goal, right - _offset, _right_goal, gyro, angle_error, _integral_offset);
109 }
Austin Schuh4352ac62013-03-19 06:23:16 +0000110
111 void Update(bool update_observer, bool stop_motors) {
112 loop_->Update(update_observer, stop_motors);
brians343bc112013-02-10 01:53:46 +0000113 }
114
Austin Schuh4352ac62013-03-19 06:23:16 +0000115 void SendMotors(Drivetrain::Output *output) {
116 if (output) {
117 output->left_voltage = loop_->U(0, 0);
118 output->right_voltage = loop_->U(1, 0);
brians8ad74052013-03-16 21:04:51 +0000119 }
brians343bc112013-02-10 01:53:46 +0000120 }
121 void PrintMotors() const {
122 // LOG(DEBUG, "Left Power %f Right Power %f lg %f rg %f le %f re %f gyro %f\n", U[0], U[1], R[0], R[2], Y[0], Y[1], _gyro);
Austin Schuh4352ac62013-03-19 06:23:16 +0000123 ::Eigen::Matrix<double, 4, 1> E = loop_->R - loop_->X_hat;
124 LOG(DEBUG, "E[0, 0]: %f E[1, 0] %f E[2, 0] %f E[3, 0] %f\n", E(0, 0), E(1, 0), E(2, 0), E(3, 0));
brians343bc112013-02-10 01:53:46 +0000125 }
126
127 private:
Austin Schuh4352ac62013-03-19 06:23:16 +0000128 ::std::unique_ptr<StateFeedbackLoop<4, 2, 2>> loop_;
129
brians343bc112013-02-10 01:53:46 +0000130 double _integral_offset;
131 double _offset;
132 double _gyro;
133 double _left_goal;
134 double _right_goal;
135 double _raw_left;
136 double _raw_right;
Austin Schuh4352ac62013-03-19 06:23:16 +0000137 bool _control_loop_driving;
brians343bc112013-02-10 01:53:46 +0000138};
139
Austin Schuh2054f5f2013-10-27 14:54:10 -0700140class PolyDrivetrain {
141 public:
142 PolyDrivetrain()
143 : U_Poly_((Eigen::Matrix<double, 4, 2>() << /*[[*/ 1, 0 /*]*/,
144 /*[*/ -1, 0 /*]*/,
145 /*[*/ 0, 1 /*]*/,
146 /*[*/ 0, -1 /*]]*/).finished(),
147 (Eigen::Matrix<double, 4, 1>() << /*[[*/ 12 /*]*/,
148 /*[*/ 12 /*]*/,
149 /*[*/ 12 /*]*/,
150 /*[*/ 12 /*]]*/).finished()),
151 loop_(new StateFeedbackLoop<2, 2, 2>(MakeVDrivetrainLoop())) {
152
153 ttrust_ = 1.0;
154
155 wheel_ = 0.0;
156 throttle_ = 0.0;
157 quickturn_ = false;
158 highgear_ = true;
159 }
160 void SetGoal(double wheel, double throttle, bool quickturn, bool highgear) {
161 const double kWheelNonLinearity = 0.1;
162 // Apply a sin function that's scaled to make it feel better.
163 const double angular_range = M_PI_2 * kWheelNonLinearity;
164 wheel_ = sin(angular_range * wheel) / sin(angular_range);
165 wheel_ = sin(angular_range * wheel_) / sin(angular_range);
166 throttle_ = throttle;
167 quickturn_ = quickturn;
168 highgear_ = highgear;
169 if (highgear_) {
170 loop_->set_controller_index(3);
171 } else {
172 loop_->set_controller_index(0);
173 }
174 }
175 double FilterVelocity(double throttle) {
176 const Eigen::Matrix<double, 2, 2> FF =
177 loop_->B().inverse() *
178 (Eigen::Matrix<double, 2, 2>::Identity() - loop_->A());
179
180 constexpr int kHighGearController = 3;
181 const Eigen::Matrix<double, 2, 2> FF_high =
182 loop_->controller(kHighGearController).plant.B.inverse() *
183 (Eigen::Matrix<double, 2, 2>::Identity() -
184 loop_->controller(kHighGearController).plant.A);
185
186 ::Eigen::Matrix<double, 1, 2> FF_sum = FF.colwise().sum();
187 int min_FF_sum_index;
188 const double min_FF_sum = FF_sum.minCoeff(&min_FF_sum_index);
189 const double min_K_sum = loop_->K().col(min_FF_sum_index).sum();
190 const double high_min_FF_sum = FF_high.col(0).sum();
191
192 const double adjusted_ff_voltage = ::aos::Clip(
193 throttle * 12.0 * min_FF_sum / high_min_FF_sum, -12.0, 12.0);
194 return ((adjusted_ff_voltage +
195 ttrust_ * min_K_sum * (loop_->X_hat(0, 0) + loop_->X_hat(1, 0)) /
196 2.0) /
197 (ttrust_ * min_K_sum + min_FF_sum));
198 }
199
200 void Update() {
201 // FF * X = U (steady state)
202 const Eigen::Matrix<double, 2, 2> FF =
203 loop_->B().inverse() *
204 (Eigen::Matrix<double, 2, 2>::Identity() - loop_->A());
205
206 // Invert the plant to figure out how the velocity filter would have to work
207 // out in order to filter out the forwards negative inertia.
208 // This math assumes that the left and right power and velocity are equals,
209 // and that the plant is the same on the left and right.
210 const double fvel = FilterVelocity(throttle_);
211
212 const double sign_svel = wheel_ * ((fvel > 0.0) ? 1.0 : -1.0);
213 const double svel = ::std::abs(fvel) * wheel_;
214 const double left_velocity = fvel - svel;
215 const double right_velocity = fvel + svel;
216
217 // K * R = w
218 Eigen::Matrix<double,1,2> equality_k;
219 equality_k << 1 + sign_svel, -(1 - sign_svel);
220 const double equality_w = 0.0;
221
222 // Integrate velocity to get the position.
223 // This position is used to get integral control.
224 loop_->R << left_velocity, right_velocity;
225
226 // Construct a constraint on R by manipulating the constraint on U
227 ::aos::controls::HPolytope<2> R_poly = ::aos::controls::HPolytope<2>(
228 U_Poly_.H() * (loop_->K() + FF),
229 U_Poly_.k() + U_Poly_.H() * loop_->K() * loop_->X_hat);
230
231 // Limit R back inside the box.
232 const Eigen::Matrix<double, 2, 1> boxed_R =
233 CoerceGoal(R_poly, equality_k, equality_w, loop_->R);
234
235 const Eigen::Matrix<double, 2, 1> FF_volts = FF * boxed_R;
236 const Eigen::Matrix<double, 2, 1> U_ideal =
237 loop_->K() * (boxed_R - loop_->X_hat) + FF_volts;
238
239 for (int i = 0; i < 2; i++) {
240 loop_->U[i] = ::aos::Clip(U_ideal[i], -12, 12);
241 }
242
243 // TODO(austin): Feed back?
244 loop_->X_hat = loop_->A() * loop_->X_hat + loop_->B() * loop_->U;
245 }
246
247 void SendMotors(Drivetrain::Output *output) {
248 LOG(DEBUG, "left pwm: %f right pwm: %f wheel: %f throttle: %f\n",
249 loop_->U(0, 0), loop_->U(1, 0), wheel_, throttle_);
250 output->left_voltage = loop_->U(0, 0);
251 output->right_voltage = loop_->U(1, 0);
252 if (highgear_) {
253 shifters.MakeWithBuilder().set(false).Send();
254 } else {
255 shifters.MakeWithBuilder().set(true).Send();
256 }
257 }
258
259 private:
260 const ::aos::controls::HPolytope<2> U_Poly_;
261
262 ::std::unique_ptr<StateFeedbackLoop<2, 2, 2>> loop_;
263
264 double ttrust_;
265 double wheel_;
266 double throttle_;
267 bool quickturn_;
268 bool highgear_;
269};
270
271
brians343bc112013-02-10 01:53:46 +0000272class DrivetrainMotorsOL {
273 public:
274 DrivetrainMotorsOL() {
275 _old_wheel = 0.0;
Austin Schuh2054f5f2013-10-27 14:54:10 -0700276 wheel_ = 0.0;
277 throttle_ = 0.0;
278 quickturn_ = false;
279 highgear_ = true;
brians343bc112013-02-10 01:53:46 +0000280 _neg_inertia_accumulator = 0.0;
281 _left_pwm = 0.0;
282 _right_pwm = 0.0;
283 }
284 void SetGoal(double wheel, double throttle, bool quickturn, bool highgear) {
Austin Schuh2054f5f2013-10-27 14:54:10 -0700285 wheel_ = wheel;
286 throttle_ = throttle;
287 quickturn_ = quickturn;
288 highgear_ = highgear;
brians343bc112013-02-10 01:53:46 +0000289 _left_pwm = 0.0;
290 _right_pwm = 0.0;
291 }
292 void Update(void) {
293 double overPower;
294 float sensitivity = 1.7;
295 float angular_power;
296 float linear_power;
297 double wheel;
298
Austin Schuh2054f5f2013-10-27 14:54:10 -0700299 double neg_inertia = wheel_ - _old_wheel;
300 _old_wheel = wheel_;
brians343bc112013-02-10 01:53:46 +0000301
302 double wheelNonLinearity;
Austin Schuh2054f5f2013-10-27 14:54:10 -0700303 if (highgear_) {
Brian Silverman77a76002013-03-16 20:09:00 -0700304 wheelNonLinearity = 0.1; // used to be csvReader->TURN_NONLIN_HIGH
brians343bc112013-02-10 01:53:46 +0000305 // Apply a sin function that's scaled to make it feel better.
306 const double angular_range = M_PI / 2.0 * wheelNonLinearity;
Austin Schuh2054f5f2013-10-27 14:54:10 -0700307 wheel = sin(angular_range * wheel_) / sin(angular_range);
Brian Silverman77a76002013-03-16 20:09:00 -0700308 wheel = sin(angular_range * wheel) / sin(angular_range);
brians343bc112013-02-10 01:53:46 +0000309 } else {
Brian Silvermandf43ec22013-03-16 23:48:29 -0700310 wheelNonLinearity = 0.2; // used to be csvReader->TURN_NONLIN_LOW
brians343bc112013-02-10 01:53:46 +0000311 // Apply a sin function that's scaled to make it feel better.
312 const double angular_range = M_PI / 2.0 * wheelNonLinearity;
Austin Schuh2054f5f2013-10-27 14:54:10 -0700313 wheel = sin(angular_range * wheel_) / sin(angular_range);
Brian Silverman77a76002013-03-16 20:09:00 -0700314 wheel = sin(angular_range * wheel) / sin(angular_range);
315 wheel = sin(angular_range * wheel) / sin(angular_range);
brians343bc112013-02-10 01:53:46 +0000316 }
317
Brian Silvermandf43ec22013-03-16 23:48:29 -0700318 static const double kThrottleDeadband = 0.05;
Austin Schuh2054f5f2013-10-27 14:54:10 -0700319 if (::std::abs(throttle_) < kThrottleDeadband) {
320 throttle_ = 0;
Brian Silvermandf43ec22013-03-16 23:48:29 -0700321 } else {
Austin Schuh2054f5f2013-10-27 14:54:10 -0700322 throttle_ = copysign((::std::abs(throttle_) - kThrottleDeadband) /
323 (1.0 - kThrottleDeadband), throttle_);
Brian Silvermandf43ec22013-03-16 23:48:29 -0700324 }
325
brians343bc112013-02-10 01:53:46 +0000326 double neg_inertia_scalar;
Austin Schuh2054f5f2013-10-27 14:54:10 -0700327 if (highgear_) {
Brian Silvermandf43ec22013-03-16 23:48:29 -0700328 neg_inertia_scalar = 8.0; // used to be csvReader->NEG_INTERTIA_HIGH
brians343bc112013-02-10 01:53:46 +0000329 sensitivity = 1.22; // used to be csvReader->SENSE_HIGH
330 } else {
331 if (wheel * neg_inertia > 0) {
Brian Silvermandf43ec22013-03-16 23:48:29 -0700332 neg_inertia_scalar = 5; // used to be csvReader->NEG_INERTIA_LOW_MORE
brians343bc112013-02-10 01:53:46 +0000333 } else {
Brian Silvermandf43ec22013-03-16 23:48:29 -0700334 if (::std::abs(wheel) > 0.65) {
335 neg_inertia_scalar = 5; // used to be csvReader->NEG_INTERTIA_LOW_LESS_EXT
brians343bc112013-02-10 01:53:46 +0000336 } else {
Brian Silvermandf43ec22013-03-16 23:48:29 -0700337 neg_inertia_scalar = 5; // used to be csvReader->NEG_INTERTIA_LOW_LESS
brians343bc112013-02-10 01:53:46 +0000338 }
339 }
340 sensitivity = 1.24; // used to be csvReader->SENSE_LOW
brians343bc112013-02-10 01:53:46 +0000341 }
342 double neg_inertia_power = neg_inertia * neg_inertia_scalar;
343 _neg_inertia_accumulator += neg_inertia_power;
344
345 wheel = wheel + _neg_inertia_accumulator;
346 if (_neg_inertia_accumulator > 1) {
347 _neg_inertia_accumulator -= 1;
348 } else if (_neg_inertia_accumulator < -1) {
349 _neg_inertia_accumulator += 1;
350 } else {
351 _neg_inertia_accumulator = 0;
352 }
353
Austin Schuh2054f5f2013-10-27 14:54:10 -0700354 linear_power = throttle_;
brians343bc112013-02-10 01:53:46 +0000355
Austin Schuh2054f5f2013-10-27 14:54:10 -0700356 if (quickturn_) {
brians343bc112013-02-10 01:53:46 +0000357 double qt_angular_power = wheel;
Brian Silvermandf43ec22013-03-16 23:48:29 -0700358 if (::std::abs(linear_power) < 0.2) {
brians343bc112013-02-10 01:53:46 +0000359 if (qt_angular_power > 1) qt_angular_power = 1.0;
360 if (qt_angular_power < -1) qt_angular_power = -1.0;
361 } else {
362 qt_angular_power = 0.0;
363 }
brians343bc112013-02-10 01:53:46 +0000364 overPower = 1.0;
Austin Schuh2054f5f2013-10-27 14:54:10 -0700365 if (highgear_) {
brians343bc112013-02-10 01:53:46 +0000366 sensitivity = 1.0;
367 } else {
368 sensitivity = 1.0;
369 }
370 angular_power = wheel;
371 } else {
372 overPower = 0.0;
Austin Schuh2054f5f2013-10-27 14:54:10 -0700373 angular_power = ::std::abs(throttle_) * wheel * sensitivity;
brians343bc112013-02-10 01:53:46 +0000374 }
375
376 _right_pwm = _left_pwm = linear_power;
377 _left_pwm += angular_power;
378 _right_pwm -= angular_power;
379
380 if (_left_pwm > 1.0) {
381 _right_pwm -= overPower*(_left_pwm - 1.0);
382 _left_pwm = 1.0;
383 } else if (_right_pwm > 1.0) {
384 _left_pwm -= overPower*(_right_pwm - 1.0);
385 _right_pwm = 1.0;
386 } else if (_left_pwm < -1.0) {
387 _right_pwm += overPower*(-1.0 - _left_pwm);
388 _left_pwm = -1.0;
389 } else if (_right_pwm < -1.0) {
390 _left_pwm += overPower*(-1.0 - _right_pwm);
391 _right_pwm = -1.0;
392 }
393 }
394
395 void SendMotors(Drivetrain::Output *output) {
Brian Silvermandf43ec22013-03-16 23:48:29 -0700396 LOG(DEBUG, "left pwm: %f right pwm: %f wheel: %f throttle: %f\n",
Austin Schuh2054f5f2013-10-27 14:54:10 -0700397 _left_pwm, _right_pwm, wheel_, throttle_);
brians8ad74052013-03-16 21:04:51 +0000398 if (output) {
399 output->left_voltage = _left_pwm * 12.0;
400 output->right_voltage = _right_pwm * 12.0;
401 }
Austin Schuh2054f5f2013-10-27 14:54:10 -0700402 if (highgear_) {
brians343bc112013-02-10 01:53:46 +0000403 shifters.MakeWithBuilder().set(false).Send();
404 } else {
405 shifters.MakeWithBuilder().set(true).Send();
406 }
407 }
408
409 private:
410 double _old_wheel;
Austin Schuh2054f5f2013-10-27 14:54:10 -0700411 double wheel_;
412 double throttle_;
413 bool quickturn_;
414 bool highgear_;
brians343bc112013-02-10 01:53:46 +0000415 double _neg_inertia_accumulator;
416 double _left_pwm;
417 double _right_pwm;
brians343bc112013-02-10 01:53:46 +0000418};
419
420void DrivetrainLoop::RunIteration(const Drivetrain::Goal *goal,
421 const Drivetrain::Position *position,
422 Drivetrain::Output *output,
423 Drivetrain::Status * /*status*/) {
424 // TODO(aschuh): These should be members of the class.
425 static DrivetrainMotorsSS dt_closedloop;
Austin Schuh2054f5f2013-10-27 14:54:10 -0700426 static PolyDrivetrain dt_openloop;
brians343bc112013-02-10 01:53:46 +0000427
428 bool bad_pos = false;
429 if (position == NULL) {
James Kuszmaul3f354742013-03-10 17:27:56 -0700430 LOG(WARNING, "no position\n");
brians343bc112013-02-10 01:53:46 +0000431 bad_pos = true;
432 }
433
434 double wheel = goal->steering;
435 double throttle = goal->throttle;
436 bool quickturn = goal->quickturn;
437 bool highgear = goal->highgear;
438
439 bool control_loop_driving = goal->control_loop_driving;
440 double left_goal = goal->left_goal;
441 double right_goal = goal->right_goal;
442
Austin Schuh2054f5f2013-10-27 14:54:10 -0700443 dt_closedloop.SetGoal(left_goal, goal->left_velocity_goal, right_goal,
444 goal->right_velocity_goal);
brians343bc112013-02-10 01:53:46 +0000445 if (!bad_pos) {
446 const double left_encoder = position->left_encoder;
447 const double right_encoder = position->right_encoder;
448 if (gyro.FetchLatest()) {
Austin Schuh2054f5f2013-10-27 14:54:10 -0700449 dt_closedloop.SetPosition(left_encoder, right_encoder, gyro->angle,
450 control_loop_driving);
brians343bc112013-02-10 01:53:46 +0000451 } else {
452 dt_closedloop.SetRawPosition(left_encoder, right_encoder);
453 }
454 }
Austin Schuh4352ac62013-03-19 06:23:16 +0000455 dt_closedloop.Update(position, output == NULL);
brians343bc112013-02-10 01:53:46 +0000456 dt_openloop.SetGoal(wheel, throttle, quickturn, highgear);
457 dt_openloop.Update();
Brian Silverman2845c4c2013-03-16 19:54:08 -0700458 if (control_loop_driving) {
459 dt_closedloop.SendMotors(output);
460 } else {
461 dt_openloop.SendMotors(output);
brians343bc112013-02-10 01:53:46 +0000462 }
463}
464
465} // namespace control_loops
466} // namespace frc971