blob: 128040948bf1e7b670b4adf009a77cb51786842b [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"
Alex Perrycb7da4b2019-08-28 19:35:56 -07008#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 Silverman17f503e2015-08-02 18:17:18 -070012
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080013namespace y2014::actors {
Brian Silverman17f503e2015-08-02 18:17:18 -070014
15class ShootActor
Alex Perrycb7da4b2019-08-28 19:35:56 -070016 : public ::aos::common::actions::ActorBase<aos::common::actions::Goal> {
Brian Silverman17f503e2015-08-02 18:17:18 -070017 public:
Philipp Schrader790cb542023-07-05 21:06:52 -070018 typedef ::aos::common::actions::TypedActionFactory<aos::common::actions::Goal>
Austin Schuh1bf8a212019-05-26 22:13:14 -070019 Factory;
20
21 explicit ShootActor(::aos::EventLoop *event_loop);
22
23 static Factory MakeFactory(::aos::EventLoop *event_loop) {
Alex Perrycb7da4b2019-08-28 19:35:56 -070024 return Factory(event_loop, "/shoot_action");
Austin Schuh1bf8a212019-05-26 22:13:14 -070025 }
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.
Alex Perrycb7da4b2019-08-28 19:35:56 -070029 bool RunAction(const aos::common::actions::DoubleParam *params) override;
Brian Silverman17f503e2015-08-02 18:17:18 -070030 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 Schuh493f7af2019-06-29 18:42:12 -070046 bool ShooterIsReady();
Brian Silverman17f503e2015-08-02 18:17:18 -070047
Austin Schuhb2461f42019-06-29 18:17:06 -070048 bool IntakeOff();
49 bool ClawIsReady();
50
51 private:
Alex Perrycb7da4b2019-08-28 19:35:56 -070052 ::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 Schuh493f7af2019-06-29 18:42:12 -070056 shooter_status_fetcher_;
Alex Perrycb7da4b2019-08-28 19:35:56 -070057 ::aos::Fetcher<::y2014::control_loops::shooter::Goal> shooter_goal_fetcher_;
58 ::aos::Sender<::y2014::control_loops::shooter::Goal> shooter_goal_sender_;
Austin Schuhb2461f42019-06-29 18:17:06 -070059
Brian Silverman17f503e2015-08-02 18:17:18 -070060 // to track when shot is complete
61 int previous_shots_;
62};
63
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080064} // namespace y2014::actors
Brian Silverman17f503e2015-08-02 18:17:18 -070065
66#endif // Y2014_ACTORS_SHOOT_ACTOR_H_