Comran Morshed | fab3200 | 2015-08-30 14:48:54 +0000 | [diff] [blame^] | 1 | #include "bot3/control_loops/intake/intake.h" |
| 2 | |
| 3 | #include "bot3/control_loops/intake/intake.q.h" |
| 4 | |
| 5 | namespace bot3 { |
| 6 | namespace control_loops { |
| 7 | |
| 8 | Intake::Intake(control_loops::IntakeQueue *intake) |
| 9 | : aos::controls::ControlLoop<control_loops::IntakeQueue>(intake) {} |
| 10 | |
| 11 | void 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 |