blob: f137235658469aac851710472dd31a0b26b001d1 [file] [log] [blame]
Brian Silverman17f503e2015-08-02 18:17:18 -07001#include "y2014/control_loops/shooter/shooter.h"
2
3#include <stdio.h>
4
5#include <algorithm>
6#include <limits>
7
8#include "aos/common/controls/control_loops.q.h"
9#include "aos/common/logging/logging.h"
10#include "aos/common/logging/queue_logging.h"
11
12#include "y2014/constants.h"
13#include "y2014/control_loops/shooter/shooter_motor_plant.h"
14
15namespace frc971 {
16namespace control_loops {
17
18using ::aos::time::Time;
19
20void ZeroedStateFeedbackLoop::CapU() {
21 const double old_voltage = voltage_;
22 voltage_ += U(0, 0);
23
24 uncapped_voltage_ = voltage_;
25
26 // Make sure that reality and the observer can't get too far off. There is a
27 // delay by one cycle between the applied voltage and X_hat(2, 0), so compare
28 // against last cycle's voltage.
29 if (X_hat(2, 0) > last_voltage_ + 4.0) {
30 voltage_ -= X_hat(2, 0) - (last_voltage_ + 4.0);
31 LOG(DEBUG, "Capping due to runaway\n");
32 } else if (X_hat(2, 0) < last_voltage_ - 4.0) {
33 voltage_ += X_hat(2, 0) - (last_voltage_ - 4.0);
34 LOG(DEBUG, "Capping due to runaway\n");
35 }
36
37 voltage_ = std::min(max_voltage_, voltage_);
38 voltage_ = std::max(-max_voltage_, voltage_);
39 mutable_U(0, 0) = voltage_ - old_voltage;
40
41 LOG_STRUCT(DEBUG, "output", ShooterVoltageToLog(X_hat(2, 0), voltage_));
42
43 last_voltage_ = voltage_;
44 capped_goal_ = false;
45}
46
47void ZeroedStateFeedbackLoop::CapGoal() {
48 if (uncapped_voltage() > max_voltage_) {
49 double dx;
50 if (controller_index() == 0) {
51 dx = (uncapped_voltage() - max_voltage_) /
52 (K(0, 0) - A(1, 0) * K(0, 2) / A(1, 2));
53 mutable_R(0, 0) -= dx;
54 mutable_R(2, 0) -= -A(1, 0) / A(1, 2) * dx;
55 } else {
56 dx = (uncapped_voltage() - max_voltage_) / K(0, 0);
57 mutable_R(0, 0) -= dx;
58 }
59 capped_goal_ = true;
60 LOG_STRUCT(DEBUG, "to prevent windup", ShooterMovingGoal(dx));
61 } else if (uncapped_voltage() < -max_voltage_) {
62 double dx;
63 if (controller_index() == 0) {
64 dx = (uncapped_voltage() + max_voltage_) /
65 (K(0, 0) - A(1, 0) * K(0, 2) / A(1, 2));
66 mutable_R(0, 0) -= dx;
67 mutable_R(2, 0) -= -A(1, 0) / A(1, 2) * dx;
68 } else {
69 dx = (uncapped_voltage() + max_voltage_) / K(0, 0);
70 mutable_R(0, 0) -= dx;
71 }
72 capped_goal_ = true;
73 LOG_STRUCT(DEBUG, "to prevent windup", ShooterMovingGoal(dx));
74 } else {
75 capped_goal_ = false;
76 }
77}
78
79void ZeroedStateFeedbackLoop::RecalculatePowerGoal() {
80 if (controller_index() == 0) {
81 mutable_R(2, 0) = (-A(1, 0) / A(1, 2) * R(0, 0) - A(1, 1) / A(1, 2) * R(1, 0));
82 } else {
83 mutable_R(2, 0) = -A(1, 1) / A(1, 2) * R(1, 0);
84 }
85}
86
87void ZeroedStateFeedbackLoop::SetCalibration(double encoder_val,
88 double known_position) {
89 double old_position = absolute_position();
90 double previous_offset = offset_;
91 offset_ = known_position - encoder_val;
92 double doffset = offset_ - previous_offset;
93 mutable_X_hat(0, 0) += doffset;
94 // Offset our measurements because the offset is baked into them.
95 // This is safe because if we got here, it means position != nullptr, which
96 // means we already set Y to something and it won't just get overwritten.
97 mutable_Y(0, 0) += doffset;
98 // Offset the goal so we don't move.
99 mutable_R(0, 0) += doffset;
100 if (controller_index() == 0) {
101 mutable_R(2, 0) += -A(1, 0) / A(1, 2) * (doffset);
102 }
103 LOG_STRUCT(
104 DEBUG, "sensor edge (fake?)",
105 ShooterChangeCalibration(encoder_val, known_position, old_position,
106 absolute_position(), previous_offset, offset_));
107}
108
109ShooterMotor::ShooterMotor(control_loops::ShooterGroup *my_shooter)
110 : aos::controls::ControlLoop<control_loops::ShooterGroup>(my_shooter),
111 shooter_(MakeShooterLoop()),
112 state_(STATE_INITIALIZE),
113 loading_problem_end_time_(0, 0),
114 load_timeout_(0, 0),
115 shooter_brake_set_time_(0, 0),
116 unload_timeout_(0, 0),
117 shot_end_time_(0, 0),
118 cycles_not_moved_(0),
119 shot_count_(0),
120 zeroed_(false),
121 distal_posedge_validation_cycles_left_(0),
122 proximal_posedge_validation_cycles_left_(0),
123 last_distal_current_(true),
124 last_proximal_current_(true) {}
125
126double ShooterMotor::PowerToPosition(double power) {
127 const frc971::constants::Values &values = constants::GetValues();
128 double maxpower = 0.5 * kSpringConstant *
129 (kMaxExtension * kMaxExtension -
130 (kMaxExtension - values.shooter.upper_limit) *
131 (kMaxExtension - values.shooter.upper_limit));
132 if (power < 0) {
133 LOG_STRUCT(WARNING, "negative power", PowerAdjustment(power, 0));
134 power = 0;
135 } else if (power > maxpower) {
136 LOG_STRUCT(WARNING, "power too high", PowerAdjustment(power, maxpower));
137 power = maxpower;
138 }
139
140 double mp = kMaxExtension * kMaxExtension - (power + power) / kSpringConstant;
141 double new_pos = 0.10;
142 if (mp < 0) {
143 LOG(ERROR,
144 "Power calculation has negative number before square root (%f).\n", mp);
145 } else {
146 new_pos = kMaxExtension - ::std::sqrt(mp);
147 }
148
149 new_pos = ::std::min(::std::max(new_pos, values.shooter.lower_limit),
150 values.shooter.upper_limit);
151 return new_pos;
152}
153
154double ShooterMotor::PositionToPower(double position) {
155 double power = kSpringConstant * position * (kMaxExtension - position / 2.0);
156 return power;
157}
158
159void ShooterMotor::CheckCalibrations(
160 const control_loops::ShooterGroup::Position *position) {
161 CHECK_NOTNULL(position);
162 const frc971::constants::Values &values = constants::GetValues();
163
164 // TODO(austin): Validate that this is the right edge.
165 // If we see a posedge on any of the hall effects,
166 if (position->pusher_proximal.posedge_count != last_proximal_posedge_count_ &&
167 !last_proximal_current_) {
168 proximal_posedge_validation_cycles_left_ = 2;
169 }
170 if (proximal_posedge_validation_cycles_left_ > 0) {
171 if (position->pusher_proximal.current) {
172 --proximal_posedge_validation_cycles_left_;
173 if (proximal_posedge_validation_cycles_left_ == 0) {
174 shooter_.SetCalibration(
175 position->pusher_proximal.posedge_value,
176 values.shooter.pusher_proximal.upper_angle);
177
178 LOG(DEBUG, "Setting calibration using proximal sensor\n");
179 zeroed_ = true;
180 }
181 } else {
182 proximal_posedge_validation_cycles_left_ = 0;
183 }
184 }
185
186 if (position->pusher_distal.posedge_count != last_distal_posedge_count_ &&
187 !last_distal_current_) {
188 distal_posedge_validation_cycles_left_ = 2;
189 }
190 if (distal_posedge_validation_cycles_left_ > 0) {
191 if (position->pusher_distal.current) {
192 --distal_posedge_validation_cycles_left_;
193 if (distal_posedge_validation_cycles_left_ == 0) {
194 shooter_.SetCalibration(
195 position->pusher_distal.posedge_value,
196 values.shooter.pusher_distal.upper_angle);
197
198 LOG(DEBUG, "Setting calibration using distal sensor\n");
199 zeroed_ = true;
200 }
201 } else {
202 distal_posedge_validation_cycles_left_ = 0;
203 }
204 }
205}
206
207// Positive is out, and positive power is out.
208void ShooterMotor::RunIteration(
209 const control_loops::ShooterGroup::Goal *goal,
210 const control_loops::ShooterGroup::Position *position,
211 control_loops::ShooterGroup::Output *output,
212 control_loops::ShooterGroup::Status *status) {
213 constexpr double dt = 0.01;
214
215 if (goal && ::std::isnan(goal->shot_power)) {
216 state_ = STATE_ESTOP;
217 LOG(ERROR, "Estopping because got a shot power of NAN.\n");
218 }
219
220 // we must always have these or we have issues.
221 if (status == NULL) {
222 if (output) output->voltage = 0;
223 LOG(ERROR, "Thought I would just check for null and die.\n");
224 return;
225 }
226 status->ready = false;
227
228 if (WasReset()) {
229 state_ = STATE_INITIALIZE;
230 last_distal_current_ = position->pusher_distal.current;
231 last_proximal_current_ = position->pusher_proximal.current;
232 }
233 if (position) {
234 shooter_.CorrectPosition(position->position);
235 }
236
237 // Disable the motors now so that all early returns will return with the
238 // motors disabled.
239 if (output) output->voltage = 0;
240
241 const frc971::constants::Values &values = constants::GetValues();
242
243 // Don't even let the control loops run.
244 bool shooter_loop_disable = false;
245
246 const bool disabled =
247 !::aos::joystick_state.get() || !::aos::joystick_state->enabled;
248
249 // If true, move the goal if we saturate.
250 bool cap_goal = false;
251
252 // TODO(austin): Move the offset if we see or don't see a hall effect when we
253 // expect to see one.
254 // Probably not needed yet.
255
256 if (position) {
257 int last_controller_index = shooter_.controller_index();
258 if (position->plunger && position->latch) {
259 // Use the controller without the spring if the latch is set and the
260 // plunger is back
261 shooter_.set_controller_index(1);
262 } else {
263 // Otherwise use the controller with the spring.
264 shooter_.set_controller_index(0);
265 }
266 if (shooter_.controller_index() != last_controller_index) {
267 shooter_.RecalculatePowerGoal();
268 }
269 }
270
271 switch (state_) {
272 case STATE_INITIALIZE:
273 if (position) {
274 // Reinitialize the internal filter state.
275 shooter_.InitializeState(position->position);
276
277 // Start off with the assumption that we are at the value
278 // futhest back given our sensors.
279 if (position->pusher_distal.current) {
280 shooter_.SetCalibration(position->position,
281 values.shooter.pusher_distal.lower_angle);
282 } else if (position->pusher_proximal.current) {
283 shooter_.SetCalibration(position->position,
284 values.shooter.pusher_proximal.upper_angle);
285 } else {
286 shooter_.SetCalibration(position->position,
287 values.shooter.upper_limit);
288 }
289
290 // Go to the current position.
291 shooter_.SetGoalPosition(shooter_.absolute_position(), 0.0);
292 // If the plunger is all the way back, we want to be latched.
293 latch_piston_ = position->plunger;
294 brake_piston_ = false;
295 if (position->latch == latch_piston_) {
296 state_ = STATE_REQUEST_LOAD;
297 } else {
298 shooter_loop_disable = true;
299 LOG(DEBUG,
300 "Not moving on until the latch has moved to avoid a crash\n");
301 }
302 } else {
303 // If we can't start yet because we don't know where we are, set the
304 // latch and brake to their defaults.
305 latch_piston_ = true;
306 brake_piston_ = true;
307 }
308 break;
309 case STATE_REQUEST_LOAD:
310 if (position) {
311 zeroed_ = false;
312 if (position->pusher_distal.current ||
313 position->pusher_proximal.current) {
314 // We started on the sensor, back up until we are found.
315 // If the plunger is all the way back and not latched, it won't be
316 // there for long.
317 state_ = STATE_LOAD_BACKTRACK;
318
319 // The plunger is already back and latched. Don't release it.
320 if (position->plunger && position->latch) {
321 latch_piston_ = true;
322 } else {
323 latch_piston_ = false;
324 }
325 } else if (position->plunger && position->latch) {
326 // The plunger is back and we are latched. We most likely got here
327 // from Initialize, in which case we want to 'load' again anyways to
328 // zero.
329 Load();
330 latch_piston_ = true;
331 } else {
332 // Off the sensor, start loading.
333 Load();
334 latch_piston_ = false;
335 }
336 }
337
338 // Hold our current position.
339 shooter_.SetGoalPosition(shooter_.absolute_position(), 0.0);
340 brake_piston_ = false;
341 break;
342 case STATE_LOAD_BACKTRACK:
343 // If we are here, then that means we started past the edge where we want
344 // to zero. Move backwards until we don't see the sensor anymore.
345 // The plunger is contacting the pusher (or will be shortly).
346
347 if (!disabled) {
348 shooter_.SetGoalPosition(
349 shooter_.goal_position() + values.shooter.zeroing_speed * dt,
350 values.shooter.zeroing_speed);
351 }
352 cap_goal = true;
353 shooter_.set_max_voltage(4.0);
354
355 if (position) {
356 if (!position->pusher_distal.current &&
357 !position->pusher_proximal.current) {
358 Load();
359 }
360 latch_piston_ = position->plunger;
361 }
362
363 brake_piston_ = false;
364 break;
365 case STATE_LOAD:
366 // If we are disabled right now, reset the timer.
367 if (disabled) {
368 Load();
369 // Latch defaults to true when disabled. Leave it latched until we have
370 // useful sensor data.
371 latch_piston_ = true;
372 }
373 if (output == nullptr) {
374 load_timeout_ += ::aos::controls::kLoopFrequency;
375 }
376 // Go to 0, which should be the latch position, or trigger a hall effect
377 // on the way. If we don't see edges where we are supposed to, the
378 // offset will be updated by code above.
379 shooter_.SetGoalPosition(0.0, 0.0);
380
381 if (position) {
382 CheckCalibrations(position);
383
384 // Latch if the plunger is far enough back to trigger the hall effect.
385 // This happens when the distal sensor is triggered.
386 latch_piston_ = position->pusher_distal.current || position->plunger;
387
388 // Check if we are latched and back. Make sure the plunger is all the
389 // way back as well.
390 if (position->plunger && position->latch &&
391 position->pusher_distal.current) {
392 if (!zeroed_) {
393 state_ = STATE_REQUEST_LOAD;
394 } else {
395 state_ = STATE_PREPARE_SHOT;
396 }
397 } else if (position->plunger &&
398 ::std::abs(shooter_.absolute_position() -
399 shooter_.goal_position()) < 0.001) {
400 // We are at the goal, but not latched.
401 state_ = STATE_LOADING_PROBLEM;
402 loading_problem_end_time_ = Time::Now() + kLoadProblemEndTimeout;
403 }
404 }
405 if (load_timeout_ < Time::Now()) {
406 if (position) {
407 if (!position->pusher_distal.current ||
408 !position->pusher_proximal.current) {
409 state_ = STATE_ESTOP;
410 LOG(ERROR, "Estopping because took too long to load.\n");
411 }
412 }
413 }
414 brake_piston_ = false;
415 break;
416 case STATE_LOADING_PROBLEM:
417 if (disabled) {
418 state_ = STATE_REQUEST_LOAD;
419 break;
420 }
421 // We got to the goal, but the latch hasn't registered as down. It might
422 // be stuck, or on it's way but not there yet.
423 if (Time::Now() > loading_problem_end_time_) {
424 // Timeout by unloading.
425 Unload();
426 } else if (position && position->plunger && position->latch) {
427 // If both trigger, we are latched.
428 state_ = STATE_PREPARE_SHOT;
429 }
430 // Move a bit further back to help it trigger.
431 // If the latch is slow due to the air flowing through the tubes or
432 // inertia, but is otherwise free, this won't have much time to do
433 // anything and is safe. Otherwise this gives us a bit more room to free
434 // up the latch.
435 shooter_.SetGoalPosition(values.shooter.lower_limit, 0.0);
436 if (position) {
437 LOG(DEBUG, "Waiting on latch: plunger %d, latch: %d\n",
438 position->plunger, position->latch);
439 }
440
441 latch_piston_ = true;
442 brake_piston_ = false;
443 break;
444 case STATE_PREPARE_SHOT:
445 // Move the shooter to the shot power set point and then lock the brake.
446 // TODO(austin): Timeout. Low priority.
447
448 if (goal) {
449 shooter_.SetGoalPosition(PowerToPosition(goal->shot_power), 0.0);
450 }
451
452 LOG(DEBUG, "PDIFF: absolute_position: %.2f, pow: %.2f\n",
453 shooter_.absolute_position(),
454 goal ? PowerToPosition(goal->shot_power)
455 : ::std::numeric_limits<double>::quiet_NaN());
456 if (goal &&
457 ::std::abs(shooter_.absolute_position() -
458 PowerToPosition(goal->shot_power)) < 0.001 &&
459 ::std::abs(shooter_.absolute_velocity()) < 0.005) {
460 // We are there, set the brake and move on.
461 latch_piston_ = true;
462 brake_piston_ = true;
463 shooter_brake_set_time_ = Time::Now() + kShooterBrakeSetTime;
464 state_ = STATE_READY;
465 } else {
466 latch_piston_ = true;
467 brake_piston_ = false;
468 }
469 if (goal && goal->unload_requested) {
470 Unload();
471 }
472 break;
473 case STATE_READY:
474 LOG(DEBUG, "In ready\n");
475 // Wait until the brake is set, and a shot is requested or the shot power
476 // is changed.
477 if (Time::Now() > shooter_brake_set_time_) {
478 status->ready = true;
479 // We have waited long enough for the brake to set, turn the shooter
480 // control loop off.
481 shooter_loop_disable = true;
482 LOG(DEBUG, "Brake is now set\n");
483 if (goal && goal->shot_requested && !disabled) {
484 LOG(DEBUG, "Shooting now\n");
485 shooter_loop_disable = true;
486 shot_end_time_ = Time::Now() + kShotEndTimeout;
487 firing_starting_position_ = shooter_.absolute_position();
488 state_ = STATE_FIRE;
489 }
490 }
491 if (state_ == STATE_READY && goal &&
492 ::std::abs(shooter_.absolute_position() -
493 PowerToPosition(goal->shot_power)) > 0.002) {
494 // TODO(austin): Add a state to release the brake.
495
496 // TODO(austin): Do we want to set the brake here or after shooting?
497 // Depends on air usage.
498 status->ready = false;
499 LOG(DEBUG, "Preparing shot again.\n");
500 state_ = STATE_PREPARE_SHOT;
501 }
502
503 if (goal) {
504 shooter_.SetGoalPosition(PowerToPosition(goal->shot_power), 0.0);
505 }
506
507 latch_piston_ = true;
508 brake_piston_ = true;
509
510 if (goal && goal->unload_requested) {
511 Unload();
512 }
513 break;
514
515 case STATE_FIRE:
516 if (disabled) {
517 if (position) {
518 if (position->plunger) {
519 // If disabled and the plunger is still back there, reset the
520 // timeout.
521 shot_end_time_ = Time::Now() + kShotEndTimeout;
522 }
523 }
524 }
525 shooter_loop_disable = true;
526 // Count the number of contiguous cycles during which we haven't moved.
527 if (::std::abs(last_position_.position - shooter_.absolute_position()) <
528 0.0005) {
529 ++cycles_not_moved_;
530 } else {
531 cycles_not_moved_ = 0;
532 }
533
534 // If we have moved any amount since the start and the shooter has now
535 // been still for a couple cycles, the shot finished.
536 // Also move on if it times out.
537 if ((::std::abs(firing_starting_position_ -
538 shooter_.absolute_position()) > 0.0005 &&
539 cycles_not_moved_ > 3) ||
540 Time::Now() > shot_end_time_) {
541 state_ = STATE_REQUEST_LOAD;
542 ++shot_count_;
543 }
544 latch_piston_ = false;
545 brake_piston_ = true;
546 break;
547 case STATE_UNLOAD:
548 // Reset the timeouts.
549 if (disabled) Unload();
550
551 // If it is latched and the plunger is back, move the pusher back to catch
552 // the plunger.
553 bool all_back;
554 if (position) {
555 all_back = position->plunger && position->latch;
556 } else {
557 all_back = last_position_.plunger && last_position_.latch;
558 }
559
560 if (all_back) {
561 // Pull back to 0, 0.
562 shooter_.SetGoalPosition(0.0, 0.0);
563 if (shooter_.absolute_position() < 0.005) {
564 // When we are close enough, 'fire'.
565 latch_piston_ = false;
566 } else {
567 latch_piston_ = true;
568
569 if (position) {
570 CheckCalibrations(position);
571 }
572 }
573 } else {
574 // The plunger isn't all the way back, or it is and it is unlatched, so
575 // we can now unload.
576 shooter_.SetGoalPosition(shooter_.absolute_position(), 0.0);
577 latch_piston_ = false;
578 state_ = STATE_UNLOAD_MOVE;
579 unload_timeout_ = Time::Now() + kUnloadTimeout;
580 }
581
582 if (Time::Now() > unload_timeout_) {
583 // We have been stuck trying to unload for way too long, give up and
584 // turn everything off.
585 state_ = STATE_ESTOP;
586 LOG(ERROR, "Estopping because took too long to unload.\n");
587 }
588
589 brake_piston_ = false;
590 break;
591 case STATE_UNLOAD_MOVE: {
592 if (disabled) {
593 unload_timeout_ = Time::Now() + kUnloadTimeout;
594 shooter_.SetGoalPosition(shooter_.absolute_position(), 0.0);
595 }
596 cap_goal = true;
597 shooter_.set_max_voltage(6.0);
598
599 // Slowly move back until we hit the upper limit.
600 // If we were at the limit last cycle, we are done unloading.
601 // This is because if we saturate, we might hit the limit before we are
602 // actually there.
603 if (shooter_.goal_position() >= values.shooter.upper_limit) {
604 shooter_.SetGoalPosition(values.shooter.upper_limit, 0.0);
605 // We don't want the loop fighting the spring when we are unloaded.
606 // Turn it off.
607 shooter_loop_disable = true;
608 state_ = STATE_READY_UNLOAD;
609 } else {
610 shooter_.SetGoalPosition(
611 ::std::min(
612 values.shooter.upper_limit,
613 shooter_.goal_position() + values.shooter.unload_speed * dt),
614 values.shooter.unload_speed);
615 }
616
617 latch_piston_ = false;
618 brake_piston_ = false;
619 } break;
620 case STATE_READY_UNLOAD:
621 if (goal && goal->load_requested) {
622 state_ = STATE_REQUEST_LOAD;
623 }
624 // If we are ready to load again,
625 shooter_loop_disable = true;
626
627 latch_piston_ = false;
628 brake_piston_ = false;
629 break;
630
631 case STATE_ESTOP:
632 LOG(WARNING, "estopped\n");
633 // Totally lost, go to a safe state.
634 shooter_loop_disable = true;
635 latch_piston_ = true;
636 brake_piston_ = true;
637 break;
638 }
639
640 if (!shooter_loop_disable) {
641 LOG_STRUCT(DEBUG, "running the loop",
642 ShooterStatusToLog(shooter_.goal_position(),
643 shooter_.absolute_position()));
644 if (!cap_goal) {
645 shooter_.set_max_voltage(12.0);
646 }
647 shooter_.Update(output == NULL);
648 if (cap_goal) {
649 shooter_.CapGoal();
650 }
651 // We don't really want to output anything if we went through everything
652 // assuming the motors weren't working.
653 if (output) output->voltage = shooter_.voltage();
654 } else {
655 shooter_.Update(true);
656 shooter_.ZeroPower();
657 if (output) output->voltage = 0.0;
658 }
659
660 status->hard_stop_power = PositionToPower(shooter_.absolute_position());
661
662 if (output) {
663 output->latch_piston = latch_piston_;
664 output->brake_piston = brake_piston_;
665 }
666
667 if (position) {
668 LOG_STRUCT(DEBUG, "internal state",
669 ShooterStateToLog(
670 shooter_.absolute_position(), shooter_.absolute_velocity(),
671 state_, position->latch, position->pusher_proximal.current,
672 position->pusher_distal.current, position->plunger,
673 brake_piston_, latch_piston_));
674
675 last_position_ = *position;
676
677 last_distal_posedge_count_ = position->pusher_distal.posedge_count;
678 last_proximal_posedge_count_ = position->pusher_proximal.posedge_count;
679 last_distal_current_ = position->pusher_distal.current;
680 last_proximal_current_ = position->pusher_proximal.current;
681 }
682
683 status->shots = shot_count_;
684}
685
686void ShooterMotor::ZeroOutputs() {
687 queue_group()->output.MakeWithBuilder()
688 .voltage(0)
689 .latch_piston(latch_piston_)
690 .brake_piston(brake_piston_)
691 .Send();
692}
693
694} // namespace control_loops
695} // namespace frc971