blob: f1ae1fefb09b23c49750ae303013eccc52e3e56d [file] [log] [blame]
Comran Morshed2f7b4672016-01-23 14:27:34 +00001#ifndef Y2016_ACTORS_SUPERSTRUCTURE_ACTOR_H_
2#define Y2016_ACTORS_SUPERSTRUCTURE_ACTOR_H_
3
4#include <memory>
5
John Park33858a32018-09-28 23:05:48 -07006#include "aos/actions/actions.h"
Austin Schuh9481d0d2019-06-29 21:56:17 -07007#include "aos/actions/actor.h"
Alex Perrycb7da4b2019-08-28 19:35:56 -07008#include "y2016/actors/superstructure_action_generated.h"
9#include "y2016/control_loops/superstructure/superstructure_goal_generated.h"
10#include "y2016/control_loops/superstructure/superstructure_status_generated.h"
Comran Morshed2f7b4672016-01-23 14:27:34 +000011
12namespace y2016 {
13namespace actors {
14
15class SuperstructureActor
Alex Perrycb7da4b2019-08-28 19:35:56 -070016 : public ::aos::common::actions::ActorBase<superstructure_action::Goal> {
Comran Morshed2f7b4672016-01-23 14:27:34 +000017 public:
Austin Schuh1bf8a212019-05-26 22:13:14 -070018 typedef ::aos::common::actions::TypedActionFactory<
Alex Perrycb7da4b2019-08-28 19:35:56 -070019 superstructure_action::Goal>
Austin Schuh1bf8a212019-05-26 22:13:14 -070020 Factory;
21
22 explicit SuperstructureActor(::aos::EventLoop *event_loop);
23
24 static Factory MakeFactory(::aos::EventLoop *event_loop) {
Alex Perrycb7da4b2019-08-28 19:35:56 -070025 return Factory(event_loop, "/superstructure_action");
Austin Schuh1bf8a212019-05-26 22:13:14 -070026 }
Comran Morshed2f7b4672016-01-23 14:27:34 +000027
Austin Schuh9481d0d2019-06-29 21:56:17 -070028 private:
Alex Perrycb7da4b2019-08-28 19:35:56 -070029 ::aos::Sender<::y2016::control_loops::superstructure::Goal>
Austin Schuh9481d0d2019-06-29 21:56:17 -070030 superstructure_goal_sender_;
Alex Perrycb7da4b2019-08-28 19:35:56 -070031 ::aos::Fetcher<::y2016::control_loops::superstructure::Status>
Austin Schuh9481d0d2019-06-29 21:56:17 -070032 superstructure_status_fetcher_;
Diana Vandenberg9cc9ab62016-04-20 21:27:47 -070033 // Internal struct holding superstructure goals sent by autonomous to the
34 // loop.
35 struct SuperstructureGoal {
36 double intake;
37 double shoulder;
38 double wrist;
39 };
40 SuperstructureGoal superstructure_goal_;
Alex Perrycb7da4b2019-08-28 19:35:56 -070041 bool RunAction(
42 const superstructure_action::SuperstructureActionParams *params) override;
Austin Schuhfef64ac2016-04-24 19:08:01 -070043 void MoveSuperstructure(double shoulder, double shooter, bool unfold_climber);
Diana Vandenberg9cc9ab62016-04-20 21:27:47 -070044 void WaitForSuperstructure();
45 bool SuperstructureProfileDone();
46 bool SuperstructureDone();
Comran Morshed2f7b4672016-01-23 14:27:34 +000047};
48
Comran Morshed2f7b4672016-01-23 14:27:34 +000049} // namespace actors
50} // namespace y2016
51
52#endif // Y2016_ACTORS_SUPERSTRUCTURE_ACTOR_H_