Sabina Davis | b6b987d | 2017-10-22 20:50:21 -0700 | [diff] [blame] | 1 | #include "y2017_bot3/control_loops/superstructure/superstructure.h" |
| 2 | |
| 3 | #include "aos/common/commonmath.h" |
| 4 | #include "aos/common/controls/control_loops.q.h" |
| 5 | #include "aos/common/logging/logging.h" |
| 6 | |
| 7 | namespace y2017_bot3 { |
| 8 | namespace control_loops { |
| 9 | namespace superstructure { |
| 10 | |
| 11 | Superstructure::Superstructure( |
| 12 | control_loops::SuperstructureQueue *superstructure_queue) |
| 13 | : aos::controls::ControlLoop<control_loops::SuperstructureQueue>( |
| 14 | superstructure_queue) {} |
| 15 | |
| 16 | void Superstructure::RunIteration( |
| 17 | const control_loops::SuperstructureQueue::Goal *unsafe_goal, |
| 18 | const control_loops::SuperstructureQueue::Position * /*position*/, |
| 19 | control_loops::SuperstructureQueue::Output *output, |
| 20 | control_loops::SuperstructureQueue::Status * /*status*/) { |
| 21 | // Write out all the voltages. |
| 22 | if (output) { |
| 23 | output->voltage_rollers = 0.0; |
| 24 | output->hanger_voltage = 0.0; |
| 25 | output->fingers_out = false; |
| 26 | if (unsafe_goal) { |
| 27 | // Intake. |
| 28 | output->voltage_rollers = unsafe_goal->voltage_rollers; |
Sabina Davis | 82b1918 | 2017-11-10 09:30:25 -0800 | [diff] [blame^] | 29 | // Fire piston to release gear. |
Sabina Davis | b6b987d | 2017-10-22 20:50:21 -0700 | [diff] [blame] | 30 | output->fingers_out = unsafe_goal->fingers_out; |
Sabina Davis | 82b1918 | 2017-11-10 09:30:25 -0800 | [diff] [blame^] | 31 | // Spin Hanger. |
Sabina Davis | b6b987d | 2017-10-22 20:50:21 -0700 | [diff] [blame] | 32 | output->hanger_voltage = unsafe_goal->hanger_voltage; |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | } // namespace superstructure |
| 38 | } // namespace control_loops |
| 39 | } // namespace y2017_bot3 |