blob: 9b3bcf1680dd47265d664553b89c3b9760c4c323 [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/actor.h"
7#include "aos/actions/actions.h"
Brian Silverman17f503e2015-08-02 18:17:18 -07008
9#include "y2014/actors/shoot_action.q.h"
10
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
47 // to track when shot is complete
48 int previous_shots_;
49};
50
Brian Silverman17f503e2015-08-02 18:17:18 -070051} // namespace actors
Brian Silvermanb601d892015-12-20 18:24:38 -050052} // namespace y2014
Brian Silverman17f503e2015-08-02 18:17:18 -070053
54#endif // Y2014_ACTORS_SHOOT_ACTOR_H_