Convert BallDetector to event loops.
Change-Id: Ic2716e5cc6d2573835aa039ce50d1ed96c882eed
diff --git a/y2016/control_loops/superstructure/superstructure.cc b/y2016/control_loops/superstructure/superstructure.cc
index 984bcc3..c3155bf 100644
--- a/y2016/control_loops/superstructure/superstructure.cc
+++ b/y2016/control_loops/superstructure/superstructure.cc
@@ -229,6 +229,9 @@
const ::std::string &name)
: aos::controls::ControlLoop<control_loops::SuperstructureQueue>(event_loop,
name),
+ ball_detector_fetcher_(
+ event_loop->MakeFetcher<::y2016::sensors::BallDetector>(
+ ".y2016.sensors.ball_detector")),
collision_avoidance_(&intake_, &arm_) {}
bool Superstructure::IsArmNear(double shoulder_tolerance,
@@ -704,10 +707,10 @@
output->unfold_climber = false;
if (unsafe_goal) {
// Ball detector lights.
- ::y2016::sensors::ball_detector.FetchLatest();
+ ball_detector_fetcher_.Fetch();
bool ball_detected = false;
- if (::y2016::sensors::ball_detector.get()) {
- ball_detected = ::y2016::sensors::ball_detector->voltage > 2.5;
+ if (ball_detector_fetcher_.get()) {
+ ball_detected = ball_detector_fetcher_->voltage > 2.5;
}
// Climber.