milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame^] | 1 | #include "y2022/control_loops/superstructure/superstructure.h" |
| 2 | |
| 3 | #include "aos/events/event_loop.h" |
| 4 | |
| 5 | namespace y2022 { |
| 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 | : frc971::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 && unsafe_goal != nullptr) { |
| 28 | OutputT output_struct; |
| 29 | |
| 30 | output->CheckOk(output->Send(Output::Pack(*output->fbb(), &output_struct))); |
| 31 | } |
| 32 | |
| 33 | Status::Builder status_builder = status->MakeBuilder<Status>(); |
| 34 | |
| 35 | status_builder.add_zeroed(true); |
| 36 | status_builder.add_estopped(false); |
| 37 | |
| 38 | if (unsafe_goal != nullptr) { |
| 39 | } |
| 40 | |
| 41 | (void)status->Send(status_builder.Finish()); |
| 42 | } |
| 43 | |
| 44 | } // namespace superstructure |
| 45 | } // namespace control_loops |
| 46 | } // namespace y2022 |