blob: a4412fff7a6824b7179678b8d5851adcda68dacf [file] [log] [blame]
Brian Silverman17f503e2015-08-02 18:17:18 -07001#ifndef Y2014_ACTORS_SHOOT_ACTOR_H_
2#define Y2014_ACTORS_SHOOT_ACTOR_H_
3
4#include <memory>
5
John Park33858a32018-09-28 23:05:48 -07006#include "aos/actions/actions.h"
Austin Schuhb2461f42019-06-29 18:17:06 -07007#include "aos/actions/actor.h"
Brian Silverman17f503e2015-08-02 18:17:18 -07008#include "y2014/actors/shoot_action.q.h"
Austin Schuhb2461f42019-06-29 18:17:06 -07009#include "y2014/control_loops/claw/claw.q.h"
Austin Schuh493f7af2019-06-29 18:42:12 -070010#include "y2014/control_loops/shooter/shooter.q.h"
Brian Silverman17f503e2015-08-02 18:17:18 -070011
Brian Silvermanb601d892015-12-20 18:24:38 -050012namespace y2014 {
Brian Silverman17f503e2015-08-02 18:17:18 -070013namespace actors {
14
15class ShootActor
16 : public ::aos::common::actions::ActorBase<actors::ShootActionQueueGroup> {
17 public:
Austin Schuh1bf8a212019-05-26 22:13:14 -070018 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 Silverman17f503e2015-08-02 18:17:18 -070027
28 // Actually execute the action of moving the claw and shooter into position
29 // and actually firing them.
30 bool RunAction(const double &params) 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 Schuh493f7af2019-06-29 18:42:12 -070047 bool ShooterIsReady();
Brian Silverman17f503e2015-08-02 18:17:18 -070048
Austin Schuhb2461f42019-06-29 18:17:06 -070049 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 Schuh493f7af2019-06-29 18:42:12 -070057 ::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 Schuhb2461f42019-06-29 18:17:06 -070063
Brian Silverman17f503e2015-08-02 18:17:18 -070064 // to track when shot is complete
65 int previous_shots_;
66};
67
Brian Silverman17f503e2015-08-02 18:17:18 -070068} // namespace actors
Brian Silvermanb601d892015-12-20 18:24:38 -050069} // namespace y2014
Brian Silverman17f503e2015-08-02 18:17:18 -070070
71#endif // Y2014_ACTORS_SHOOT_ACTOR_H_