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