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