blob: a3978a42c734663c034539459032068695b278bf [file] [log] [blame]
Stephan Massaltd021f972020-01-05 20:41:23 -08001#include "y2020/control_loops/superstructure/superstructure.h"
2
3#include "aos/events/event_loop.h"
4
5namespace y2020 {
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 : aos::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
28 if (output != nullptr) {
29 OutputT output_struct;
30 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 status->Send(status_builder.Finish());
39}
40
41} // namespace control_loops
42} // namespace y2020
43} // namespace y2020