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.
diff --git a/y2016/control_loops/superstructure/superstructure.h b/y2016/control_loops/superstructure/superstructure.h
index 7215067..610db8e 100644
--- a/y2016/control_loops/superstructure/superstructure.h
+++ b/y2016/control_loops/superstructure/superstructure.h
@@ -10,6 +10,7 @@
#include "frc971/zeroing/zeroing.h"
#include "y2016/control_loops/superstructure/superstructure.q.h"
#include "y2016/control_loops/superstructure/superstructure_controls.h"
+#include "y2016/queues/ball_detector.q.h"
namespace y2016 {
namespace control_loops {
@@ -222,6 +223,9 @@
friend class testing::SuperstructureTest_UpperHardstopStartup_Test;
friend class testing::SuperstructureTest_DisabledWhileZeroingHigh_Test;
friend class testing::SuperstructureTest_DisabledWhileZeroingLow_Test;
+
+ ::aos::Fetcher<::y2016::sensors::BallDetector> ball_detector_fetcher_;
+
Intake intake_;
Arm arm_;