blob: 277ba73765696cec5e981e01a56dd9ba1f4bf937 [file] [log] [blame]
Niko Sohmers3860f8a2024-01-12 21:05:19 -08001#ifndef Y2024_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_
2#define Y2024_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_
3
4#include "aos/events/event_loop.h"
5#include "aos/json_to_flatbuffer.h"
6#include "frc971/constants/constants_sender_lib.h"
7#include "frc971/control_loops/control_loop.h"
8#include "frc971/control_loops/drivetrain/drivetrain_can_position_generated.h"
9#include "frc971/control_loops/drivetrain/drivetrain_status_generated.h"
10#include "frc971/zeroing/absolute_encoder.h"
11#include "frc971/zeroing/pot_and_absolute_encoder.h"
12#include "y2024/constants.h"
13#include "y2024/constants/constants_generated.h"
14#include "y2024/control_loops/superstructure/superstructure_goal_generated.h"
15#include "y2024/control_loops/superstructure/superstructure_output_generated.h"
16#include "y2024/control_loops/superstructure/superstructure_position_generated.h"
17#include "y2024/control_loops/superstructure/superstructure_status_generated.h"
18
Maxwell Henderson09a4b022024-01-19 21:39:51 -080019namespace y2024::control_loops::superstructure {
Niko Sohmers3860f8a2024-01-12 21:05:19 -080020
21class Superstructure
22 : public ::frc971::controls::ControlLoop<Goal, Position, Status, Output> {
23 public:
Niko Sohmersafc51fe2024-01-29 17:48:35 -080024 using PotAndAbsoluteEncoderSubsystem =
25 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem<
26 ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator,
27 ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>;
28
Niko Sohmers3860f8a2024-01-12 21:05:19 -080029 explicit Superstructure(::aos::EventLoop *event_loop,
30 std::shared_ptr<const constants::Values> values,
31 const ::std::string &name = "/superstructure");
32
Niko Sohmersafc51fe2024-01-29 17:48:35 -080033 inline const PotAndAbsoluteEncoderSubsystem &intake_pivot() const {
34 return intake_pivot_;
35 }
36
Niko Sohmers3860f8a2024-01-12 21:05:19 -080037 double robot_velocity() const;
38
39 protected:
40 virtual void RunIteration(const Goal *unsafe_goal, const Position *position,
41 aos::Sender<Output>::Builder *output,
42 aos::Sender<Status>::Builder *status) override;
43
44 private:
45 std::shared_ptr<const constants::Values> values_;
46 frc971::constants::ConstantsFetcher<Constants> constants_fetcher_;
Niko Sohmersafc51fe2024-01-29 17:48:35 -080047 const Constants *robot_constants_;
Niko Sohmers3860f8a2024-01-12 21:05:19 -080048 aos::Fetcher<frc971::control_loops::drivetrain::Status>
49 drivetrain_status_fetcher_;
50 aos::Fetcher<aos::JoystickState> joystick_state_fetcher_;
51
52 aos::Alliance alliance_ = aos::Alliance::kInvalid;
53
Niko Sohmersafc51fe2024-01-29 17:48:35 -080054 PotAndAbsoluteEncoderSubsystem intake_pivot_;
55
Niko Sohmers3860f8a2024-01-12 21:05:19 -080056 DISALLOW_COPY_AND_ASSIGN(Superstructure);
57};
58
Maxwell Henderson09a4b022024-01-19 21:39:51 -080059} // namespace y2024::control_loops::superstructure
Niko Sohmers3860f8a2024-01-12 21:05:19 -080060
61#endif // Y2024_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_