milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 1 | #ifndef Y2022_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |
| 2 | #define Y2022_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |
| 3 | |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 4 | #include "aos/events/event_loop.h" |
Siddhant Kanwar | 0e37f59 | 2022-02-21 19:26:50 -0800 | [diff] [blame] | 5 | #include "frc971/control_loops/control_loop.h" |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 6 | #include "frc971/control_loops/drivetrain/drivetrain_status_generated.h" |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 7 | #include "y2022/constants.h" |
Austin Schuh | 39f26f6 | 2022-02-24 21:34:46 -0800 | [diff] [blame] | 8 | #include "y2022/control_loops/superstructure/catapult/catapult.h" |
Milind Upadhyay | 225156b | 2022-02-25 22:42:12 -0800 | [diff] [blame^] | 9 | #include "y2022/control_loops/superstructure/collision_avoidance.h" |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 10 | #include "y2022/control_loops/superstructure/superstructure_goal_generated.h" |
| 11 | #include "y2022/control_loops/superstructure/superstructure_output_generated.h" |
| 12 | #include "y2022/control_loops/superstructure/superstructure_position_generated.h" |
| 13 | #include "y2022/control_loops/superstructure/superstructure_status_generated.h" |
| 14 | |
| 15 | namespace y2022 { |
| 16 | namespace control_loops { |
| 17 | namespace superstructure { |
| 18 | |
| 19 | class Superstructure |
| 20 | : public ::frc971::controls::ControlLoop<Goal, Position, Status, Output> { |
| 21 | public: |
Siddhant Kanwar | 0e37f59 | 2022-02-21 19:26:50 -0800 | [diff] [blame] | 22 | using RelativeEncoderSubsystem = |
| 23 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 24 | ::frc971::zeroing::RelativeEncoderZeroingEstimator, |
| 25 | ::frc971::control_loops::RelativeEncoderProfiledJointStatus>; |
| 26 | |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 27 | using PotAndAbsoluteEncoderSubsystem = |
| 28 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 29 | ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator, |
| 30 | ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>; |
| 31 | |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 32 | explicit Superstructure(::aos::EventLoop *event_loop, |
Milind Upadhyay | 225156b | 2022-02-25 22:42:12 -0800 | [diff] [blame^] | 33 | std::shared_ptr<const constants::Values> values, |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 34 | const ::std::string &name = "/superstructure"); |
| 35 | |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 36 | inline const PotAndAbsoluteEncoderSubsystem &intake_front() const { |
| 37 | return intake_front_; |
| 38 | } |
| 39 | inline const PotAndAbsoluteEncoderSubsystem &intake_back() const { |
| 40 | return intake_back_; |
| 41 | } |
| 42 | inline const PotAndAbsoluteEncoderSubsystem &turret() const { |
| 43 | return turret_; |
| 44 | } |
| 45 | inline const RelativeEncoderSubsystem &climber() const { return climber_; } |
| 46 | |
| 47 | double robot_velocity() const; |
| 48 | |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 49 | protected: |
| 50 | virtual void RunIteration(const Goal *unsafe_goal, const Position *position, |
| 51 | aos::Sender<Output>::Builder *output, |
| 52 | aos::Sender<Status>::Builder *status) override; |
| 53 | |
| 54 | private: |
Austin Schuh | 39f26f6 | 2022-02-24 21:34:46 -0800 | [diff] [blame] | 55 | std::shared_ptr<const constants::Values> values_; |
| 56 | |
Siddhant Kanwar | 0e37f59 | 2022-02-21 19:26:50 -0800 | [diff] [blame] | 57 | RelativeEncoderSubsystem climber_; |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 58 | PotAndAbsoluteEncoderSubsystem intake_front_; |
| 59 | PotAndAbsoluteEncoderSubsystem intake_back_; |
| 60 | PotAndAbsoluteEncoderSubsystem turret_; |
| 61 | |
Milind Upadhyay | 225156b | 2022-02-25 22:42:12 -0800 | [diff] [blame^] | 62 | CollisionAvoidance collision_avoidance_; |
| 63 | |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 64 | aos::Fetcher<frc971::control_loops::drivetrain::Status> |
| 65 | drivetrain_status_fetcher_; |
Siddhant Kanwar | 0e37f59 | 2022-02-21 19:26:50 -0800 | [diff] [blame] | 66 | |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 67 | DISALLOW_COPY_AND_ASSIGN(Superstructure); |
Austin Schuh | 39f26f6 | 2022-02-24 21:34:46 -0800 | [diff] [blame] | 68 | |
| 69 | catapult::Catapult catapult_; |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | } // namespace superstructure |
| 73 | } // namespace control_loops |
| 74 | } // namespace y2022 |
| 75 | |
| 76 | #endif // Y2022_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |