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