Ravago Jones | 486de80 | 2021-05-19 20:47:55 -0700 | [diff] [blame^] | 1 | #include "y2021_bot3/control_loops/superstructure/superstructure.h" |
| 2 | |
| 3 | #include "aos/events/event_loop.h" |
| 4 | |
| 5 | namespace y2021_bot3 { |
| 6 | namespace control_loops { |
| 7 | namespace superstructure { |
| 8 | |
| 9 | using frc971::control_loops::AbsoluteEncoderProfiledJointStatus; |
| 10 | using frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus; |
| 11 | |
| 12 | Superstructure::Superstructure(::aos::EventLoop *event_loop, |
| 13 | const ::std::string &name) |
| 14 | : aos::controls::ControlLoop<Goal, Position, Status, Output>(event_loop, |
| 15 | name) { |
| 16 | event_loop->SetRuntimeRealtimePriority(30); |
| 17 | } |
| 18 | |
| 19 | void Superstructure::RunIteration(const Goal * /*unsafe_goal*/, |
| 20 | const Position * /*position*/, |
| 21 | aos::Sender<Output>::Builder *output, |
| 22 | aos::Sender<Status>::Builder *status) { |
| 23 | if (WasReset()) { |
| 24 | AOS_LOG(ERROR, "WPILib reset, restarting\n"); |
| 25 | } |
| 26 | |
| 27 | if (output != nullptr) { |
| 28 | OutputT output_struct; |
| 29 | output->Send(Output::Pack(*output->fbb(), &output_struct)); |
| 30 | } |
| 31 | |
| 32 | Status::Builder status_builder = status->MakeBuilder<Status>(); |
| 33 | |
| 34 | status_builder.add_zeroed(true); |
| 35 | status_builder.add_estopped(false); |
| 36 | |
| 37 | status->Send(status_builder.Finish()); |
| 38 | } |
| 39 | |
| 40 | } // namespace superstructure |
| 41 | } // namespace control_loops |
| 42 | } // namespace y2021_bot3 |