Henry Speiser | 354d278 | 2022-07-22 13:56:48 -0700 | [diff] [blame] | 1 | #ifndef Y2022_BOT3_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |
| 2 | #define Y2022_BOT3_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |
| 3 | |
| 4 | #include "aos/events/event_loop.h" |
| 5 | #include "frc971/control_loops/control_loop.h" |
| 6 | #include "frc971/control_loops/drivetrain/drivetrain_status_generated.h" |
James Kuszmaul | ec635d2 | 2023-08-12 18:39:24 -0700 | [diff] [blame] | 7 | #include "frc971/zeroing/pot_and_absolute_encoder.h" |
Henry Speiser | 354d278 | 2022-07-22 13:56:48 -0700 | [diff] [blame] | 8 | #include "y2022_bot3/constants.h" |
| 9 | #include "y2022_bot3/control_loops/superstructure/superstructure_goal_generated.h" |
| 10 | #include "y2022_bot3/control_loops/superstructure/superstructure_output_generated.h" |
| 11 | #include "y2022_bot3/control_loops/superstructure/superstructure_position_generated.h" |
| 12 | #include "y2022_bot3/control_loops/superstructure/superstructure_status_generated.h" |
| 13 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame^] | 14 | namespace y2022_bot3::control_loops::superstructure { |
Henry Speiser | 354d278 | 2022-07-22 13:56:48 -0700 | [diff] [blame] | 15 | |
| 16 | class Superstructure |
| 17 | : public ::frc971::controls::ControlLoop<Goal, Position, Status, Output> { |
| 18 | public: |
| 19 | using RelativeEncoderSubsystem = |
| 20 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 21 | ::frc971::zeroing::RelativeEncoderZeroingEstimator, |
| 22 | ::frc971::control_loops::RelativeEncoderProfiledJointStatus>; |
| 23 | |
| 24 | using PotAndAbsoluteEncoderSubsystem = |
| 25 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 26 | ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator, |
| 27 | ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>; |
| 28 | |
| 29 | explicit Superstructure(::aos::EventLoop *event_loop, |
| 30 | std::shared_ptr<const constants::Values> values, |
| 31 | const ::std::string &name = "/superstructure"); |
| 32 | |
Niko Sohmers | 74c5b59 | 2022-09-10 13:41:46 -0700 | [diff] [blame] | 33 | inline const PotAndAbsoluteEncoderSubsystem &intake() const { |
| 34 | return intake_; |
| 35 | } |
| 36 | inline const PotAndAbsoluteEncoderSubsystem &climber_left() const { |
| 37 | return climber_left_; |
| 38 | } |
| 39 | inline const PotAndAbsoluteEncoderSubsystem &climber_right() const { |
| 40 | return climber_right_; |
| 41 | } |
| 42 | |
Henry Speiser | 354d278 | 2022-07-22 13:56:48 -0700 | [diff] [blame] | 43 | protected: |
| 44 | virtual void RunIteration(const Goal *unsafe_goal, const Position *position, |
| 45 | aos::Sender<Output>::Builder *output, |
| 46 | aos::Sender<Status>::Builder *status) override; |
| 47 | |
| 48 | private: |
| 49 | std::shared_ptr<const constants::Values> values_; |
| 50 | |
Niko Sohmers | 74c5b59 | 2022-09-10 13:41:46 -0700 | [diff] [blame] | 51 | PotAndAbsoluteEncoderSubsystem climber_left_; |
| 52 | PotAndAbsoluteEncoderSubsystem climber_right_; |
| 53 | PotAndAbsoluteEncoderSubsystem intake_; |
| 54 | |
Henry Speiser | 354d278 | 2022-07-22 13:56:48 -0700 | [diff] [blame] | 55 | aos::Fetcher<frc971::control_loops::drivetrain::Status> |
| 56 | drivetrain_status_fetcher_; |
| 57 | aos::Fetcher<aos::JoystickState> joystick_state_fetcher_; |
| 58 | |
| 59 | aos::Alliance alliance_ = aos::Alliance::kInvalid; |
| 60 | |
| 61 | DISALLOW_COPY_AND_ASSIGN(Superstructure); |
| 62 | }; |
| 63 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame^] | 64 | } // namespace y2022_bot3::control_loops::superstructure |
Henry Speiser | 354d278 | 2022-07-22 13:56:48 -0700 | [diff] [blame] | 65 | |
| 66 | #endif // Y2022_BOT3_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |