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" |
Austin Schuh | ff97355 | 2019-05-19 16:49:28 -0700 | [diff] [blame] | 5 | #include "aos/events/event-loop.h" |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame^] | 6 | #include "frc971/control_loops/drivetrain/drivetrain.q.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" |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 10 | #include "y2019/control_loops/superstructure/superstructure.q.h" |
Theo Bafrali | 3274a18 | 2019-02-17 20:01:38 -0800 | [diff] [blame] | 11 | #include "y2019/control_loops/superstructure/vacuum.h" |
Austin Schuh | ff97355 | 2019-05-19 16:49:28 -0700 | [diff] [blame] | 12 | #include "y2019/status_light.q.h" |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 13 | |
| 14 | namespace y2019 { |
| 15 | namespace control_loops { |
| 16 | namespace superstructure { |
| 17 | |
| 18 | class Superstructure |
| 19 | : public ::aos::controls::ControlLoop<SuperstructureQueue> { |
| 20 | public: |
| 21 | explicit Superstructure( |
Austin Schuh | 55a13dc | 2019-01-27 22:39:03 -0800 | [diff] [blame] | 22 | ::aos::EventLoop *event_loop, |
| 23 | const ::std::string &name = |
| 24 | ".y2019.control_loops.superstructure.superstructure_queue"); |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 25 | |
Theo Bafrali | 00e4227 | 2019-02-12 01:07:46 -0800 | [diff] [blame] | 26 | using PotAndAbsoluteEncoderSubsystem = |
| 27 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 28 | ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator, |
| 29 | ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>; |
| 30 | using AbsoluteEncoderSubsystem = |
| 31 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 32 | ::frc971::zeroing::AbsoluteEncoderZeroingEstimator, |
| 33 | ::frc971::control_loops::AbsoluteEncoderProfiledJointStatus>; |
| 34 | |
Theo Bafrali | 09517b9 | 2019-02-16 15:59:17 -0800 | [diff] [blame] | 35 | const PotAndAbsoluteEncoderSubsystem &elevator() const { return elevator_; } |
| 36 | const PotAndAbsoluteEncoderSubsystem &wrist() const { return wrist_; } |
| 37 | const AbsoluteEncoderSubsystem &intake() const { return intake_; } |
| 38 | const PotAndAbsoluteEncoderSubsystem &stilts() const { return stilts_; } |
Theo Bafrali | 3274a18 | 2019-02-17 20:01:38 -0800 | [diff] [blame] | 39 | const Vacuum &vacuum() const { return vacuum_; } |
Theo Bafrali | 00e4227 | 2019-02-12 01:07:46 -0800 | [diff] [blame] | 40 | |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 41 | protected: |
Theo Bafrali | 00e4227 | 2019-02-12 01:07:46 -0800 | [diff] [blame] | 42 | virtual void RunIteration(const SuperstructureQueue::Goal *unsafe_goal, |
| 43 | const SuperstructureQueue::Position *position, |
| 44 | SuperstructureQueue::Output *output, |
| 45 | SuperstructureQueue::Status *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_; |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame^] | 51 | ::aos::Fetcher<::frc971::control_loops::DrivetrainQueue::Status> |
| 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_ |