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" |
Theo Bafrali | 00e4227 | 2019-02-12 01:07:46 -0800 | [diff] [blame] | 5 | #include "frc971/control_loops/static_zeroing_single_dof_profiled_subsystem.h" |
| 6 | #include "y2019/constants.h" |
| 7 | #include "y2019/control_loops/superstructure/collision_avoidance.h" |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 8 | #include "y2019/control_loops/superstructure/superstructure.q.h" |
| 9 | |
| 10 | namespace y2019 { |
| 11 | namespace control_loops { |
| 12 | namespace superstructure { |
| 13 | |
| 14 | class Superstructure |
| 15 | : public ::aos::controls::ControlLoop<SuperstructureQueue> { |
| 16 | public: |
| 17 | explicit Superstructure( |
Austin Schuh | 55a13dc | 2019-01-27 22:39:03 -0800 | [diff] [blame] | 18 | ::aos::EventLoop *event_loop, |
| 19 | const ::std::string &name = |
| 20 | ".y2019.control_loops.superstructure.superstructure_queue"); |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 21 | |
Theo Bafrali | 00e4227 | 2019-02-12 01:07:46 -0800 | [diff] [blame] | 22 | using PotAndAbsoluteEncoderSubsystem = |
| 23 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 24 | ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator, |
| 25 | ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>; |
| 26 | using AbsoluteEncoderSubsystem = |
| 27 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 28 | ::frc971::zeroing::AbsoluteEncoderZeroingEstimator, |
| 29 | ::frc971::control_loops::AbsoluteEncoderProfiledJointStatus>; |
| 30 | |
Theo Bafrali | 09517b9 | 2019-02-16 15:59:17 -0800 | [diff] [blame] | 31 | const PotAndAbsoluteEncoderSubsystem &elevator() const { return elevator_; } |
| 32 | const PotAndAbsoluteEncoderSubsystem &wrist() const { return wrist_; } |
| 33 | const AbsoluteEncoderSubsystem &intake() const { return intake_; } |
| 34 | const PotAndAbsoluteEncoderSubsystem &stilts() const { return stilts_; } |
Theo Bafrali | 00e4227 | 2019-02-12 01:07:46 -0800 | [diff] [blame] | 35 | |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 36 | protected: |
Theo Bafrali | 00e4227 | 2019-02-12 01:07:46 -0800 | [diff] [blame] | 37 | virtual void RunIteration(const SuperstructureQueue::Goal *unsafe_goal, |
| 38 | const SuperstructureQueue::Position *position, |
| 39 | SuperstructureQueue::Output *output, |
| 40 | SuperstructureQueue::Status *status) override; |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 41 | |
| 42 | private: |
Austin Schuh | e835475 | 2019-02-17 14:59:05 -0800 | [diff] [blame] | 43 | void HandleSuction(const SuctionGoal *unsafe_goal, float suction_pressure, |
| 44 | SuperstructureQueue::Output *output, bool *has_piece); |
| 45 | |
Theo Bafrali | 00e4227 | 2019-02-12 01:07:46 -0800 | [diff] [blame] | 46 | PotAndAbsoluteEncoderSubsystem elevator_; |
| 47 | PotAndAbsoluteEncoderSubsystem wrist_; |
| 48 | AbsoluteEncoderSubsystem intake_; |
| 49 | PotAndAbsoluteEncoderSubsystem stilts_; |
| 50 | |
| 51 | CollisionAvoidance collision_avoidance_; |
Austin Schuh | e835475 | 2019-02-17 14:59:05 -0800 | [diff] [blame] | 52 | int vacuum_count_ = 0; |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 53 | |
Theo Bafrali | 09517b9 | 2019-02-16 15:59:17 -0800 | [diff] [blame] | 54 | static constexpr double kMinIntakeAngleForRollers = -0.7; |
| 55 | |
Tyler Chatow | e51334a | 2019-01-20 16:58:16 -0800 | [diff] [blame] | 56 | DISALLOW_COPY_AND_ASSIGN(Superstructure); |
| 57 | }; |
| 58 | |
| 59 | } // namespace superstructure |
| 60 | } // namespace control_loops |
| 61 | } // namespace y2019 |
| 62 | |
Austin Schuh | 55a13dc | 2019-01-27 22:39:03 -0800 | [diff] [blame] | 63 | #endif // Y2019_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |