Convert actions to event loops
The logic gets significantly simpler due to Watchers. But we also get
to port all the users over as well.
Change-Id: Ib4e75951e65f7431acc6c1548b7f1d20da3da295
diff --git a/y2014/joystick_reader.cc b/y2014/joystick_reader.cc
index 99c11b4..2b32d2d 100644
--- a/y2014/joystick_reader.cc
+++ b/y2014/joystick_reader.cc
@@ -164,7 +164,8 @@
goal_angle_(0.0),
separation_angle_(kGrabSeparation),
velocity_compensation_(0.0),
- intake_power_(0.0) {}
+ intake_power_(0.0),
+ shoot_action_factory_(actors::ShootActor::MakeFactory(event_loop)) {}
void SetGoal(ClawGoal goal) {
goal_angle_ = goal.angle;
@@ -315,7 +316,7 @@
}
if (data.PosEdge(kFire)) {
- EnqueueAction(actors::MakeShootAction());
+ EnqueueAction(shoot_action_factory_.Make(0.0));
} else if (data.NegEdge(kFire)) {
CancelCurrentAction();
}
@@ -417,6 +418,8 @@
double intake_power_;
bool moving_for_shot_ = false;
+ actors::ShootActor::Factory shoot_action_factory_;
+
::aos::util::SimpleLogInterval no_drivetrain_status_ =
::aos::util::SimpleLogInterval(::std::chrono::milliseconds(200), WARNING,
"no drivetrain status");