Kill target_selector_hint queue
Use EventLoop instead.
Change-Id: I84f839e6ec247648470c70be234611517dff8f51
diff --git a/y2019/control_loops/drivetrain/BUILD b/y2019/control_loops/drivetrain/BUILD
index 8cfa45e..845575f 100644
--- a/y2019/control_loops/drivetrain/BUILD
+++ b/y2019/control_loops/drivetrain/BUILD
@@ -147,6 +147,7 @@
srcs = ["target_selector_test.cc"],
deps = [
":target_selector",
+ "//aos/events:shm-event-loop",
"//aos/testing:googletest",
"//aos/testing:test_shm",
],
diff --git a/y2019/control_loops/drivetrain/target_selector.q b/y2019/control_loops/drivetrain/target_selector.q
index 7ad2013..021bd3a 100644
--- a/y2019/control_loops/drivetrain/target_selector.q
+++ b/y2019/control_loops/drivetrain/target_selector.q
@@ -1,6 +1,7 @@
package y2019.control_loops.drivetrain;
// A message to provide information to the target selector about what it should
+// The drivetrain listens on ".y2019.control_loops.drivetrain.target_selector_hint"
message TargetSelectorHint {
// Which target we should go for:
// 0 implies no selection, we should just default to whatever.
@@ -9,5 +10,3 @@
// These should match the SelectionHint enum in target_selector.h.
uint8_t suggested_target;
};
-
-queue TargetSelectorHint target_selector_hint;
diff --git a/y2019/control_loops/drivetrain/target_selector_test.cc b/y2019/control_loops/drivetrain/target_selector_test.cc
index aa655e6..966f766 100644
--- a/y2019/control_loops/drivetrain/target_selector_test.cc
+++ b/y2019/control_loops/drivetrain/target_selector_test.cc
@@ -1,5 +1,6 @@
#include "y2019/control_loops/drivetrain/target_selector.h"
+#include "aos/events/shm-event-loop.h"
#include "aos/testing/test_shm.h"
#include "gtest/gtest.h"
#include "y2019/control_loops/superstructure/superstructure.q.h"
@@ -36,15 +37,27 @@
double expected_radius;
};
class TargetSelectorParamTest : public ::testing::TestWithParam<TestParams> {
- protected:
- virtual void TearDown() override {
- ::y2019::control_loops::superstructure::superstructure_queue.goal.Clear();
- ::y2019::control_loops::drivetrain::target_selector_hint.Clear();
- }
- ::aos::ShmEventLoop event_loop_;
+ public:
+ TargetSelectorParamTest()
+ : target_selector_hint_sender_(
+ test_event_loop_.MakeSender<
+ ::y2019::control_loops::drivetrain::TargetSelectorHint>(
+ ".y2019.control_loops.drivetrain.target_selector_hint")) {}
private:
::aos::testing::TestSharedMemory my_shm_;
+
+ protected:
+ virtual void TearDown() override {
+ ::y2019::control_loops::superstructure::superstructure_queue.goal.Clear();
+ }
+
+ ::aos::ShmEventLoop event_loop_;
+ ::aos::ShmEventLoop test_event_loop_;
+
+ ::aos::Sender<::y2019::control_loops::drivetrain::TargetSelectorHint>
+ target_selector_hint_sender_;
+
};
TEST_P(TargetSelectorParamTest, ExpectReturn) {
@@ -57,8 +70,7 @@
ASSERT_TRUE(super_goal.Send());
}
{
- auto hint =
- ::y2019::control_loops::drivetrain::target_selector_hint.MakeMessage();
+ auto hint = target_selector_hint_sender_.MakeMessage();
hint->suggested_target = static_cast<int>(GetParam().selection_hint);
ASSERT_TRUE(hint.Send());
}