blob: 33a284ce6958d04a5dc01f50e643fb412334d6d4 [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"
Brian Silverman17f503e2015-08-02 18:17:18 -070010
Brian Silvermanb601d892015-12-20 18:24:38 -050011namespace y2014 {
Brian Silverman17f503e2015-08-02 18:17:18 -070012namespace actors {
13
14class ShootActor
15 : public ::aos::common::actions::ActorBase<actors::ShootActionQueueGroup> {
16 public:
Austin Schuh1bf8a212019-05-26 22:13:14 -070017 typedef ::aos::common::actions::TypedActionFactory<
18 actors::ShootActionQueueGroup>
19 Factory;
20
21 explicit ShootActor(::aos::EventLoop *event_loop);
22
23 static Factory MakeFactory(::aos::EventLoop *event_loop) {
24 return Factory(event_loop, ".y2014.actors.shoot_action");
25 }
Brian Silverman17f503e2015-08-02 18:17:18 -070026
27 // Actually execute the action of moving the claw and shooter into position
28 // and actually firing them.
29 bool RunAction(const double &params) override;
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();
46
Austin Schuhb2461f42019-06-29 18:17:06 -070047 bool IntakeOff();
48 bool ClawIsReady();
49
50 private:
51 ::aos::Fetcher<::y2014::control_loops::ClawQueue::Goal> claw_goal_fetcher_;
52 ::aos::Fetcher<::y2014::control_loops::ClawQueue::Status>
53 claw_status_fetcher_;
54 ::aos::Sender<::y2014::control_loops::ClawQueue::Goal> claw_goal_sender_;
55
Brian Silverman17f503e2015-08-02 18:17:18 -070056 // to track when shot is complete
57 int previous_shots_;
58};
59
Brian Silverman17f503e2015-08-02 18:17:18 -070060} // namespace actors
Brian Silvermanb601d892015-12-20 18:24:38 -050061} // namespace y2014
Brian Silverman17f503e2015-08-02 18:17:18 -070062
63#endif // Y2014_ACTORS_SHOOT_ACTOR_H_