blob: 935730beed38e7f3a42ee14bafc070cbde1bdcb5 [file] [log] [blame]
Comran Morshedfab32002015-08-30 14:48:54 +00001#include "bot3/control_loops/intake/intake.h"
2
3#include "bot3/control_loops/intake/intake.q.h"
4
5namespace bot3 {
6namespace control_loops {
7
8Intake::Intake(control_loops::IntakeQueue *intake)
9 : aos::controls::ControlLoop<control_loops::IntakeQueue>(intake) {}
10
11void Intake::RunIteration(
12 const control_loops::IntakeQueue::Goal *goal,
13 const control_loops::IntakeQueue::Position * /*position*/,
14 control_loops::IntakeQueue::Output *output,
15 control_loops::IntakeQueue::Status * /*status*/) {
16
17 if (output != nullptr) {
18 output->Zero();
19
20 const int16_t intake_movement = goal->movement;
21
22 if (intake_movement > 0) {
23 // Suck.
24 output->intake = kIntakeVoltageFullPower;
25 } else if (intake_movement < 0) {
26 // Spit.
27 output->intake = -kIntakeVoltageFullPower;
28 } else {
29 // Stationary.
30 output->intake = 0.0;
31 }
32 }
33}
34
35} // namespace control_loops
36} // namespace bot3