Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 1 | #ifndef Y2017_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |
| 2 | #define Y2017_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |
| 3 | |
| 4 | #include <memory> |
| 5 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 6 | #include "aos/controls/control_loop.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 7 | #include "aos/events/event_loop.h" |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 8 | #include "frc971/control_loops/state_feedback_loop.h" |
Parker Schuh | 208a58d | 2017-04-12 20:51:38 -0700 | [diff] [blame] | 9 | #include "y2017/control_loops/superstructure/column/column.h" |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 10 | #include "y2017/control_loops/superstructure/hood/hood.h" |
Adam Snaider | 79900c2 | 2017-02-08 20:23:15 -0800 | [diff] [blame] | 11 | #include "y2017/control_loops/superstructure/intake/intake.h" |
Tyler Chatow | 2737d2a | 2017-02-08 21:20:51 -0800 | [diff] [blame] | 12 | #include "y2017/control_loops/superstructure/shooter/shooter.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 13 | #include "y2017/control_loops/superstructure/superstructure_goal_generated.h" |
| 14 | #include "y2017/control_loops/superstructure/superstructure_output_generated.h" |
| 15 | #include "y2017/control_loops/superstructure/superstructure_position_generated.h" |
| 16 | #include "y2017/control_loops/superstructure/superstructure_status_generated.h" |
Parker Schuh | 208a58d | 2017-04-12 20:51:38 -0700 | [diff] [blame] | 17 | #include "y2017/control_loops/superstructure/vision_distance_average.h" |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 18 | |
| 19 | namespace y2017 { |
| 20 | namespace control_loops { |
| 21 | namespace superstructure { |
| 22 | |
| 23 | class Superstructure |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 24 | : public ::aos::controls::ControlLoop<Goal, Position, Status, Output> { |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 25 | public: |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 26 | explicit Superstructure(::aos::EventLoop *event_loop, |
| 27 | const ::std::string &name = "/superstructure"); |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 28 | |
Adam Snaider | cfe1306 | 2017-02-05 18:23:09 -0800 | [diff] [blame] | 29 | const hood::Hood &hood() const { return hood_; } |
Adam Snaider | 79900c2 | 2017-02-08 20:23:15 -0800 | [diff] [blame] | 30 | const intake::Intake &intake() const { return intake_; } |
Austin Schuh | cd3237a | 2017-02-18 14:19:26 -0800 | [diff] [blame] | 31 | const shooter::Shooter &shooter() const { return shooter_; } |
Austin Schuh | d5ccb86 | 2017-03-11 22:06:36 -0800 | [diff] [blame] | 32 | const column::Column &column() const { return column_; } |
| 33 | |
| 34 | // Sets the ignore collisions bit. This should *not* be used on the robot. |
| 35 | void set_ignore_collisions(bool ignore_collisions) { |
| 36 | ignore_collisions_ = ignore_collisions; |
| 37 | } |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 38 | |
| 39 | protected: |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 40 | virtual void RunIteration(const Goal *unsafe_goal, const Position *position, |
| 41 | aos::Sender<Output>::Builder *output, |
| 42 | aos::Sender<Status>::Builder *status) override; |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 43 | |
| 44 | private: |
Austin Schuh | b6c5c85 | 2019-05-19 20:13:31 -0700 | [diff] [blame] | 45 | ::aos::Fetcher<::y2017::vision::VisionStatus> vision_status_fetcher_; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 46 | ::aos::Fetcher<::frc971::control_loops::drivetrain::Status> |
Austin Schuh | bd0a40f | 2019-06-30 14:56:31 -0700 | [diff] [blame] | 47 | drivetrain_status_fetcher_; |
Austin Schuh | b6c5c85 | 2019-05-19 20:13:31 -0700 | [diff] [blame] | 48 | |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 49 | hood::Hood hood_; |
Adam Snaider | 79900c2 | 2017-02-08 20:23:15 -0800 | [diff] [blame] | 50 | intake::Intake intake_; |
Tyler Chatow | 2737d2a | 2017-02-08 21:20:51 -0800 | [diff] [blame] | 51 | shooter::Shooter shooter_; |
Austin Schuh | d5ccb86 | 2017-03-11 22:06:36 -0800 | [diff] [blame] | 52 | column::Column column_; |
| 53 | |
| 54 | // If true, we ignore collisions. |
| 55 | bool ignore_collisions_ = false; |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 56 | |
Parker Schuh | 208a58d | 2017-04-12 20:51:38 -0700 | [diff] [blame] | 57 | VisionDistanceAverage distance_average_; |
| 58 | |
Austin Schuh | e8b0075 | 2017-04-16 19:14:31 -0700 | [diff] [blame] | 59 | ::frc971::shooter_interpolation::InterpolationTable< |
| 60 | ::y2017::constants::Values::ShotParams> |
| 61 | shot_interpolation_table_; |
| 62 | |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 63 | DISALLOW_COPY_AND_ASSIGN(Superstructure); |
| 64 | }; |
| 65 | |
| 66 | } // namespace superstructure |
| 67 | } // namespace control_loops |
| 68 | } // namespace y2017 |
| 69 | |
| 70 | #endif // Y2017_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |