James (Peilun) Li | a70e575 | 2024-09-18 20:43:00 -0700 | [diff] [blame^] | 1 | #ifndef Y2024_BOT3_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |
| 2 | #define Y2024_BOT3_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |
| 3 | |
| 4 | #include "aos/events/event_loop.h" |
| 5 | #include "aos/json_to_flatbuffer.h" |
| 6 | #include "aos/time/time.h" |
| 7 | #include "frc971/constants/constants_sender_lib.h" |
| 8 | #include "frc971/control_loops/control_loop.h" |
| 9 | #include "frc971/zeroing/absolute_encoder.h" |
| 10 | #include "frc971/zeroing/pot_and_absolute_encoder.h" |
| 11 | #include "y2024_bot3/constants.h" |
| 12 | #include "y2024_bot3/constants/constants_generated.h" |
| 13 | #include "y2024_bot3/control_loops/superstructure/superstructure_goal_generated.h" |
| 14 | #include "y2024_bot3/control_loops/superstructure/superstructure_output_generated.h" |
| 15 | #include "y2024_bot3/control_loops/superstructure/superstructure_position_generated.h" |
| 16 | #include "y2024_bot3/control_loops/superstructure/superstructure_status_generated.h" |
| 17 | |
| 18 | namespace y2024_bot3::control_loops::superstructure { |
| 19 | |
| 20 | class Superstructure |
| 21 | : public ::frc971::controls::ControlLoop<Goal, Position, Status, Output> { |
| 22 | public: |
| 23 | using AbsoluteEncoderSubsystem = |
| 24 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 25 | ::frc971::zeroing::AbsoluteEncoderZeroingEstimator, |
| 26 | ::frc971::control_loops::AbsoluteEncoderProfiledJointStatus>; |
| 27 | |
| 28 | using PotAndAbsoluteEncoderSubsystem = |
| 29 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 30 | ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator, |
| 31 | ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>; |
| 32 | |
| 33 | explicit Superstructure(::aos::EventLoop *event_loop, |
| 34 | const ::std::string &name = "/superstructure"); |
| 35 | |
| 36 | double robot_velocity() const; |
| 37 | |
| 38 | protected: |
| 39 | virtual void RunIteration(const Goal *unsafe_goal, const Position *position, |
| 40 | aos::Sender<Output>::Builder *output, |
| 41 | aos::Sender<Status>::Builder *status) override; |
| 42 | |
| 43 | private: |
| 44 | frc971::constants::ConstantsFetcher<Constants> constants_fetcher_; |
| 45 | const Constants *robot_constants_; |
| 46 | aos::Fetcher<aos::JoystickState> joystick_state_fetcher_; |
| 47 | |
| 48 | aos::Alliance alliance_ = aos::Alliance::kInvalid; |
| 49 | |
| 50 | DISALLOW_COPY_AND_ASSIGN(Superstructure); |
| 51 | }; |
| 52 | |
| 53 | } // namespace y2024_bot3::control_loops::superstructure |
| 54 | |
| 55 | #endif // Y2024_BOT3_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |