blob: 1b91c695b6b8edf5c17759f0a338d0fec0a2f964 [file] [log] [blame]
Sabina Davisb6b987d2017-10-22 20:50:21 -07001#include "y2017_bot3/control_loops/superstructure/superstructure.h"
2
John Park33858a32018-09-28 23:05:48 -07003#include "aos/commonmath.h"
4#include "aos/controls/control_loops.q.h"
5#include "aos/logging/logging.h"
Sabina Davisb6b987d2017-10-22 20:50:21 -07006
7namespace y2017_bot3 {
8namespace control_loops {
9namespace superstructure {
10
11Superstructure::Superstructure(
12 control_loops::SuperstructureQueue *superstructure_queue)
13 : aos::controls::ControlLoop<control_loops::SuperstructureQueue>(
14 superstructure_queue) {}
15
16void 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 Davis82b19182017-11-10 09:30:25 -080029 // Fire piston to release gear.
Sabina Davisb6b987d2017-10-22 20:50:21 -070030 output->fingers_out = unsafe_goal->fingers_out;
Sabina Davis82b19182017-11-10 09:30:25 -080031 // Spin Hanger.
Sabina Davisb6b987d2017-10-22 20:50:21 -070032 output->hanger_voltage = unsafe_goal->hanger_voltage;
33 }
34 }
35}
36
37} // namespace superstructure
38} // namespace control_loops
39} // namespace y2017_bot3