Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 1 | #ifndef Y2014_ACTORS_SHOOT_ACTOR_H_ |
| 2 | #define Y2014_ACTORS_SHOOT_ACTOR_H_ |
| 3 | |
| 4 | #include <memory> |
| 5 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 6 | #include "aos/actions/actions.h" |
Austin Schuh | b2461f4 | 2019-06-29 18:17:06 -0700 | [diff] [blame] | 7 | #include "aos/actions/actor.h" |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 8 | #include "y2014/control_loops/claw/claw_goal_generated.h" |
| 9 | #include "y2014/control_loops/claw/claw_status_generated.h" |
| 10 | #include "y2014/control_loops/shooter/shooter_goal_generated.h" |
| 11 | #include "y2014/control_loops/shooter/shooter_status_generated.h" |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 12 | |
Brian Silverman | b601d89 | 2015-12-20 18:24:38 -0500 | [diff] [blame] | 13 | namespace y2014 { |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 14 | namespace actors { |
| 15 | |
| 16 | class ShootActor |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 17 | : public ::aos::common::actions::ActorBase<aos::common::actions::Goal> { |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 18 | public: |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 19 | typedef ::aos::common::actions::TypedActionFactory< |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 20 | aos::common::actions::Goal> |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 21 | Factory; |
| 22 | |
| 23 | explicit ShootActor(::aos::EventLoop *event_loop); |
| 24 | |
| 25 | static Factory MakeFactory(::aos::EventLoop *event_loop) { |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 26 | return Factory(event_loop, "/shoot_action"); |
Austin Schuh | 1bf8a21 | 2019-05-26 22:13:14 -0700 | [diff] [blame] | 27 | } |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 28 | |
| 29 | // Actually execute the action of moving the claw and shooter into position |
| 30 | // and actually firing them. |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 31 | bool RunAction(const aos::common::actions::DoubleParam *params) override; |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 32 | void InnerRunAction(); |
| 33 | |
| 34 | // calc an offset to our requested shot based on robot speed |
| 35 | double SpeedToAngleOffset(double speed); |
| 36 | |
| 37 | static constexpr double kOffsetRadians = 0.4; |
| 38 | static constexpr double kClawShootingSeparation = 0.10; |
| 39 | static constexpr double kClawShootingSeparationGoal = 0.10; |
| 40 | |
| 41 | protected: |
| 42 | // completed shot |
| 43 | bool DoneShot(); |
| 44 | // ready for shot |
| 45 | bool DonePreShotOpen(); |
| 46 | // in the right place |
| 47 | bool DoneSetupShot(); |
Austin Schuh | 493f7af | 2019-06-29 18:42:12 -0700 | [diff] [blame] | 48 | bool ShooterIsReady(); |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 49 | |
Austin Schuh | b2461f4 | 2019-06-29 18:17:06 -0700 | [diff] [blame] | 50 | bool IntakeOff(); |
| 51 | bool ClawIsReady(); |
| 52 | |
| 53 | private: |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 54 | ::aos::Fetcher<::y2014::control_loops::claw::Goal> claw_goal_fetcher_; |
| 55 | ::aos::Fetcher<::y2014::control_loops::claw::Status> claw_status_fetcher_; |
| 56 | ::aos::Sender<::y2014::control_loops::claw::Goal> claw_goal_sender_; |
| 57 | ::aos::Fetcher<::y2014::control_loops::shooter::Status> |
Austin Schuh | 493f7af | 2019-06-29 18:42:12 -0700 | [diff] [blame] | 58 | shooter_status_fetcher_; |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame^] | 59 | ::aos::Fetcher<::y2014::control_loops::shooter::Goal> shooter_goal_fetcher_; |
| 60 | ::aos::Sender<::y2014::control_loops::shooter::Goal> shooter_goal_sender_; |
Austin Schuh | b2461f4 | 2019-06-29 18:17:06 -0700 | [diff] [blame] | 61 | |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 62 | // to track when shot is complete |
| 63 | int previous_shots_; |
| 64 | }; |
| 65 | |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 66 | } // namespace actors |
Brian Silverman | b601d89 | 2015-12-20 18:24:38 -0500 | [diff] [blame] | 67 | } // namespace y2014 |
Brian Silverman | 17f503e | 2015-08-02 18:17:18 -0700 | [diff] [blame] | 68 | |
| 69 | #endif // Y2014_ACTORS_SHOOT_ACTOR_H_ |