Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 1 | #ifndef Y2023_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |
| 2 | #define Y2023_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 "y2023_bot3/constants.h" |
| 11 | #include "y2023_bot3/constants/constants_generated.h" |
Ariv Diggi | c892e92 | 2023-10-21 15:52:06 -0700 | [diff] [blame] | 12 | #include "y2023_bot3/control_loops/superstructure/end_effector.h" |
Maxwell Henderson | 0d22077 | 2023-11-06 11:09:58 -0800 | [diff] [blame] | 13 | #include "y2023_bot3/control_loops/superstructure/pivot_joint.h" |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 14 | #include "y2023_bot3/control_loops/superstructure/superstructure_goal_generated.h" |
| 15 | #include "y2023_bot3/control_loops/superstructure/superstructure_output_generated.h" |
| 16 | #include "y2023_bot3/control_loops/superstructure/superstructure_position_generated.h" |
| 17 | #include "y2023_bot3/control_loops/superstructure/superstructure_status_generated.h" |
| 18 | |
| 19 | namespace y2023_bot3 { |
| 20 | namespace control_loops { |
| 21 | namespace superstructure { |
| 22 | |
| 23 | class Superstructure |
| 24 | : public ::frc971::controls::ControlLoop<Goal, Position, Status, Output> { |
| 25 | public: |
Maxwell Henderson | 43684fa | 2023-11-06 11:08:06 -0800 | [diff] [blame] | 26 | using PotAndAbsoluteEncoderSubsystem = |
| 27 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 28 | ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator, |
| 29 | ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>; |
| 30 | |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 31 | explicit Superstructure(::aos::EventLoop *event_loop, |
| 32 | std::shared_ptr<const constants::Values> values, |
| 33 | const ::std::string &name = "/superstructure"); |
| 34 | |
| 35 | double robot_velocity() const; |
| 36 | |
Ariv Diggi | c892e92 | 2023-10-21 15:52:06 -0700 | [diff] [blame] | 37 | inline const EndEffector &end_effector() const { return end_effector_; } |
| 38 | |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 39 | protected: |
| 40 | virtual void RunIteration(const Goal *unsafe_goal, const Position *position, |
| 41 | aos::Sender<Output>::Builder *output, |
| 42 | aos::Sender<Status>::Builder *status) override; |
| 43 | |
| 44 | private: |
| 45 | // Returns the Y coordinate of a game piece given the time-of-flight reading. |
| 46 | std::optional<double> LateralOffsetForTimeOfFlight(double reading); |
| 47 | |
| 48 | std::shared_ptr<const constants::Values> values_; |
Ariv Diggi | c892e92 | 2023-10-21 15:52:06 -0700 | [diff] [blame] | 49 | EndEffector end_effector_; |
| 50 | |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 51 | aos::Alliance alliance_ = aos::Alliance::kInvalid; |
| 52 | |
Maxwell Henderson | 0d22077 | 2023-11-06 11:09:58 -0800 | [diff] [blame] | 53 | PivotJoint pivot_joint_; |
| 54 | |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 55 | DISALLOW_COPY_AND_ASSIGN(Superstructure); |
| 56 | }; |
| 57 | |
| 58 | } // namespace superstructure |
| 59 | } // namespace control_loops |
| 60 | } // namespace y2023_bot3 |
| 61 | |
| 62 | #endif // Y2023_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |