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