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" |
Niko Sohmers | c4d2c50 | 2024-02-19 19:35:35 -0800 | [diff] [blame] | 14 | #include "y2024/control_loops/superstructure/shooter.h" |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 15 | #include "y2024/control_loops/superstructure/superstructure_goal_generated.h" |
| 16 | #include "y2024/control_loops/superstructure/superstructure_output_generated.h" |
| 17 | #include "y2024/control_loops/superstructure/superstructure_position_generated.h" |
| 18 | #include "y2024/control_loops/superstructure/superstructure_status_generated.h" |
| 19 | |
Maxwell Henderson | 09a4b02 | 2024-01-19 21:39:51 -0800 | [diff] [blame] | 20 | namespace y2024::control_loops::superstructure { |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 21 | |
| 22 | class Superstructure |
| 23 | : public ::frc971::controls::ControlLoop<Goal, Position, Status, Output> { |
| 24 | public: |
Niko Sohmers | 74b0ad5 | 2024-02-03 18:00:31 -0800 | [diff] [blame] | 25 | using AbsoluteEncoderSubsystem = |
| 26 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 27 | ::frc971::zeroing::AbsoluteEncoderZeroingEstimator, |
| 28 | ::frc971::control_loops::AbsoluteEncoderProfiledJointStatus>; |
| 29 | |
Niko Sohmers | afc51fe | 2024-01-29 17:48:35 -0800 | [diff] [blame] | 30 | using PotAndAbsoluteEncoderSubsystem = |
| 31 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 32 | ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator, |
| 33 | ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>; |
| 34 | |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 35 | explicit Superstructure(::aos::EventLoop *event_loop, |
| 36 | std::shared_ptr<const constants::Values> values, |
| 37 | const ::std::string &name = "/superstructure"); |
| 38 | |
Niko Sohmers | 74b0ad5 | 2024-02-03 18:00:31 -0800 | [diff] [blame] | 39 | inline const AbsoluteEncoderSubsystem &intake_pivot() const { |
Niko Sohmers | afc51fe | 2024-01-29 17:48:35 -0800 | [diff] [blame] | 40 | return intake_pivot_; |
| 41 | } |
| 42 | |
Filip Kujawa | 6d71763 | 2024-02-01 11:40:55 -0800 | [diff] [blame] | 43 | inline const PotAndAbsoluteEncoderSubsystem &climber() const { |
| 44 | return climber_; |
| 45 | } |
| 46 | |
Niko Sohmers | c4d2c50 | 2024-02-19 19:35:35 -0800 | [diff] [blame] | 47 | inline const Shooter &shooter() const { return shooter_; } |
| 48 | |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 49 | double robot_velocity() const; |
| 50 | |
| 51 | protected: |
| 52 | virtual void RunIteration(const Goal *unsafe_goal, const Position *position, |
| 53 | aos::Sender<Output>::Builder *output, |
| 54 | aos::Sender<Status>::Builder *status) override; |
| 55 | |
| 56 | private: |
| 57 | std::shared_ptr<const constants::Values> values_; |
| 58 | frc971::constants::ConstantsFetcher<Constants> constants_fetcher_; |
Niko Sohmers | afc51fe | 2024-01-29 17:48:35 -0800 | [diff] [blame] | 59 | const Constants *robot_constants_; |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 60 | aos::Fetcher<frc971::control_loops::drivetrain::Status> |
| 61 | drivetrain_status_fetcher_; |
| 62 | aos::Fetcher<aos::JoystickState> joystick_state_fetcher_; |
| 63 | |
Niko Sohmers | ac4d887 | 2024-02-23 13:55:47 -0800 | [diff] [blame^] | 64 | CollisionAvoidance collision_avoidance_; |
| 65 | |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 66 | aos::Alliance alliance_ = aos::Alliance::kInvalid; |
| 67 | |
Niko Sohmers | e735fa8 | 2024-02-02 16:49:02 -0800 | [diff] [blame] | 68 | TransferRollerGoal transfer_goal_; |
Niko Sohmers | 74b0ad5 | 2024-02-03 18:00:31 -0800 | [diff] [blame] | 69 | AbsoluteEncoderSubsystem intake_pivot_; |
Filip Kujawa | 6d71763 | 2024-02-01 11:40:55 -0800 | [diff] [blame] | 70 | PotAndAbsoluteEncoderSubsystem climber_; |
Niko Sohmers | 74b0ad5 | 2024-02-03 18:00:31 -0800 | [diff] [blame] | 71 | |
Niko Sohmers | c4d2c50 | 2024-02-19 19:35:35 -0800 | [diff] [blame] | 72 | Shooter shooter_; |
| 73 | |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 74 | DISALLOW_COPY_AND_ASSIGN(Superstructure); |
| 75 | }; |
| 76 | |
Maxwell Henderson | 09a4b02 | 2024-01-19 21:39:51 -0800 | [diff] [blame] | 77 | } // namespace y2024::control_loops::superstructure |
Niko Sohmers | 3860f8a | 2024-01-12 21:05:19 -0800 | [diff] [blame] | 78 | |
| 79 | #endif // Y2024_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |