Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 1 | #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 Henderson | 09a4b02 | 2024-01-19 21:39:51 -0800 | [diff] [blame] | 19 | namespace y2024::control_loops::superstructure { |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 20 | |
| 21 | class Superstructure |
| 22 | : public ::frc971::controls::ControlLoop<Goal, Position, Status, Output> { |
| 23 | public: |
Niko Sohmers | afc51fe | 2024-01-29 17:48:35 -0800 | [diff] [blame^] | 24 | using PotAndAbsoluteEncoderSubsystem = |
| 25 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 26 | ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator, |
| 27 | ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>; |
| 28 | |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 29 | explicit Superstructure(::aos::EventLoop *event_loop, |
| 30 | std::shared_ptr<const constants::Values> values, |
| 31 | const ::std::string &name = "/superstructure"); |
| 32 | |
Niko Sohmers | afc51fe | 2024-01-29 17:48:35 -0800 | [diff] [blame^] | 33 | inline const PotAndAbsoluteEncoderSubsystem &intake_pivot() const { |
| 34 | return intake_pivot_; |
| 35 | } |
| 36 | |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 37 | 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 Sohmers | afc51fe | 2024-01-29 17:48:35 -0800 | [diff] [blame^] | 47 | const Constants *robot_constants_; |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 48 | 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 Sohmers | afc51fe | 2024-01-29 17:48:35 -0800 | [diff] [blame^] | 54 | PotAndAbsoluteEncoderSubsystem intake_pivot_; |
| 55 | |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 56 | DISALLOW_COPY_AND_ASSIGN(Superstructure); |
| 57 | }; |
| 58 | |
Maxwell Henderson | 09a4b02 | 2024-01-19 21:39:51 -0800 | [diff] [blame] | 59 | } // namespace y2024::control_loops::superstructure |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 60 | |
| 61 | #endif // Y2024_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |