Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 1 | #ifndef Y2019_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |
| 2 | #define Y2019_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |
| 3 | |
| 4 | #include "aos/controls/control_loop.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 5 | #include "aos/events/event_loop.h" |
| 6 | #include "frc971/control_loops/drivetrain/drivetrain_status_generated.h" |
Theo Bafrali | 00e4227 | 2019-02-12 01:07:46 -0800 | [diff] [blame] | 7 | #include "frc971/control_loops/static_zeroing_single_dof_profiled_subsystem.h" |
| 8 | #include "y2019/constants.h" |
| 9 | #include "y2019/control_loops/superstructure/collision_avoidance.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 10 | #include "y2019/control_loops/superstructure/superstructure_goal_generated.h" |
| 11 | #include "y2019/control_loops/superstructure/superstructure_output_generated.h" |
| 12 | #include "y2019/control_loops/superstructure/superstructure_position_generated.h" |
| 13 | #include "y2019/control_loops/superstructure/superstructure_status_generated.h" |
Theo Bafrali | 3274a18 | 2019-02-17 20:01:38 -0800 | [diff] [blame] | 14 | #include "y2019/control_loops/superstructure/vacuum.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 15 | #include "y2019/status_light_generated.h" |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 16 | |
| 17 | namespace y2019 { |
| 18 | namespace control_loops { |
| 19 | namespace superstructure { |
| 20 | |
| 21 | class Superstructure |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 22 | : public ::aos::controls::ControlLoop<Goal, Position, Status, Output> { |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 23 | public: |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 24 | explicit Superstructure(::aos::EventLoop *event_loop, |
| 25 | const ::std::string &name = "/superstructure"); |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 26 | |
Theo Bafrali | 00e4227 | 2019-02-12 01:07:46 -0800 | [diff] [blame] | 27 | using PotAndAbsoluteEncoderSubsystem = |
| 28 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 29 | ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator, |
| 30 | ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>; |
| 31 | using AbsoluteEncoderSubsystem = |
| 32 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 33 | ::frc971::zeroing::AbsoluteEncoderZeroingEstimator, |
| 34 | ::frc971::control_loops::AbsoluteEncoderProfiledJointStatus>; |
| 35 | |
Theo Bafrali | 09517b9 | 2019-02-16 15:59:17 -0800 | [diff] [blame] | 36 | const PotAndAbsoluteEncoderSubsystem &elevator() const { return elevator_; } |
| 37 | const PotAndAbsoluteEncoderSubsystem &wrist() const { return wrist_; } |
| 38 | const AbsoluteEncoderSubsystem &intake() const { return intake_; } |
| 39 | const PotAndAbsoluteEncoderSubsystem &stilts() const { return stilts_; } |
Theo Bafrali | 3274a18 | 2019-02-17 20:01:38 -0800 | [diff] [blame] | 40 | const Vacuum &vacuum() const { return vacuum_; } |
Theo Bafrali | 00e4227 | 2019-02-12 01:07:46 -0800 | [diff] [blame] | 41 | |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 42 | protected: |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 43 | virtual void RunIteration(const Goal *unsafe_goal, const Position *position, |
| 44 | aos::Sender<Output>::Builder *output, |
| 45 | aos::Sender<Status>::Builder *status) override; |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 46 | |
| 47 | private: |
Austin Schuh | ff97355 | 2019-05-19 16:49:28 -0700 | [diff] [blame] | 48 | void SendColors(float red, float green, float blue); |
| 49 | |
| 50 | ::aos::Sender<::y2019::StatusLight> status_light_sender_; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 51 | ::aos::Fetcher<::frc971::control_loops::drivetrain::Status> |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 52 | drivetrain_status_fetcher_; |
Austin Schuh | ff97355 | 2019-05-19 16:49:28 -0700 | [diff] [blame] | 53 | |
Theo Bafrali | 00e4227 | 2019-02-12 01:07:46 -0800 | [diff] [blame] | 54 | PotAndAbsoluteEncoderSubsystem elevator_; |
| 55 | PotAndAbsoluteEncoderSubsystem wrist_; |
| 56 | AbsoluteEncoderSubsystem intake_; |
| 57 | PotAndAbsoluteEncoderSubsystem stilts_; |
Theo Bafrali | 3274a18 | 2019-02-17 20:01:38 -0800 | [diff] [blame] | 58 | Vacuum vacuum_; |
Theo Bafrali | 00e4227 | 2019-02-12 01:07:46 -0800 | [diff] [blame] | 59 | |
| 60 | CollisionAvoidance collision_avoidance_; |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 61 | |
Austin Schuh | 194c43c | 2019-03-22 20:40:53 -0700 | [diff] [blame] | 62 | int line_blink_count_ = 0; |
| 63 | |
Theo Bafrali | 09517b9 | 2019-02-16 15:59:17 -0800 | [diff] [blame] | 64 | static constexpr double kMinIntakeAngleForRollers = -0.7; |
| 65 | |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 66 | DISALLOW_COPY_AND_ASSIGN(Superstructure); |
| 67 | }; |
| 68 | |
| 69 | } // namespace superstructure |
| 70 | } // namespace control_loops |
| 71 | } // namespace y2019 |
| 72 | |
Austin Schuh | 55a13dc | 2019-01-27 22:39:03 -0800 | [diff] [blame] | 73 | #endif // Y2019_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |