blob: e985779e403317ffc38b5b3ff06713bb935e288e [file] [log] [blame]
milind-u086d7262022-01-19 20:44:18 -08001#include "y2022/control_loops/superstructure/superstructure.h"
2
3#include "aos/events/event_loop.h"
4
5namespace y2022 {
6namespace control_loops {
7namespace superstructure {
8
9using frc971::control_loops::AbsoluteEncoderProfiledJointStatus;
10using frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus;
11
12Superstructure::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
19void 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