Switch all robots over to use EventLoop
Stop using the old QueueGroup constructor for ControlLoop
Change-Id: I027febf86e75399a97cdb4dc50dbc475705e0393
diff --git a/y2016/control_loops/shooter/BUILD b/y2016/control_loops/shooter/BUILD
index 4f62c7a..8938a2b 100644
--- a/y2016/control_loops/shooter/BUILD
+++ b/y2016/control_loops/shooter/BUILD
@@ -1,87 +1,88 @@
-package(default_visibility = ['//visibility:public'])
+package(default_visibility = ["//visibility:public"])
-load('//aos/build:queues.bzl', 'queue_library')
+load("//aos/build:queues.bzl", "queue_library")
queue_library(
- name = 'shooter_queue',
- srcs = [
- 'shooter.q',
- ],
- deps = [
- '//aos/controls:control_loop_queues',
- '//frc971/control_loops:queues',
- ],
+ name = "shooter_queue",
+ srcs = [
+ "shooter.q",
+ ],
+ deps = [
+ "//aos/controls:control_loop_queues",
+ "//frc971/control_loops:queues",
+ ],
)
genrule(
- name = 'genrule_shooter',
- visibility = ['//visibility:private'],
- cmd = '$(location //y2016/control_loops/python:shooter) $(OUTS)',
- tools = [
- '//y2016/control_loops/python:shooter',
- ],
- outs = [
- 'shooter_plant.h',
- 'shooter_plant.cc',
- 'shooter_integral_plant.h',
- 'shooter_integral_plant.cc',
- ],
+ name = "genrule_shooter",
+ outs = [
+ "shooter_plant.h",
+ "shooter_plant.cc",
+ "shooter_integral_plant.h",
+ "shooter_integral_plant.cc",
+ ],
+ cmd = "$(location //y2016/control_loops/python:shooter) $(OUTS)",
+ tools = [
+ "//y2016/control_loops/python:shooter",
+ ],
+ visibility = ["//visibility:private"],
)
cc_library(
- name = 'shooter_plants',
- srcs = [
- 'shooter_plant.cc',
- 'shooter_integral_plant.cc',
- ],
- hdrs = [
- 'shooter_plant.h',
- 'shooter_integral_plant.h',
- ],
- deps = [
- '//frc971/control_loops:state_feedback_loop',
- ],
+ name = "shooter_plants",
+ srcs = [
+ "shooter_integral_plant.cc",
+ "shooter_plant.cc",
+ ],
+ hdrs = [
+ "shooter_integral_plant.h",
+ "shooter_plant.h",
+ ],
+ deps = [
+ "//frc971/control_loops:state_feedback_loop",
+ ],
)
cc_library(
- name = 'shooter_lib',
- srcs = [
- 'shooter.cc',
- ],
- hdrs = [
- 'shooter.h',
- ],
- deps = [
- ':shooter_queue',
- ':shooter_plants',
- '//aos/controls:control_loop',
- ],
+ name = "shooter_lib",
+ srcs = [
+ "shooter.cc",
+ ],
+ hdrs = [
+ "shooter.h",
+ ],
+ deps = [
+ ":shooter_plants",
+ ":shooter_queue",
+ "//aos/controls:control_loop",
+ ],
)
cc_test(
- name = 'shooter_lib_test',
- srcs = [
- 'shooter_lib_test.cc',
- ],
- deps = [
- ':shooter_queue',
- ':shooter_lib',
- '//aos/testing:googletest',
- '//aos:queues',
- '//aos/controls:control_loop_test',
- '//frc971/control_loops:state_feedback_loop',
- '//frc971/control_loops:team_number_test_environment',
- ],
+ name = "shooter_lib_test",
+ srcs = [
+ "shooter_lib_test.cc",
+ ],
+ deps = [
+ ":shooter_lib",
+ ":shooter_queue",
+ "//aos:queues",
+ "//aos/controls:control_loop_test",
+ "//aos/testing:googletest",
+ "//frc971/control_loops:state_feedback_loop",
+ "//frc971/control_loops:team_number_test_environment",
+ ],
)
cc_binary(
- name = 'shooter',
- srcs = [
- 'shooter_main.cc',
- ],
- deps = [
- '//aos:init',
- ':shooter_lib',
- ':shooter_queue',
- ],
+ name = "shooter",
+ srcs = [
+ "shooter_main.cc",
+ ],
+ deps = [
+ ":shooter_lib",
+ ":shooter_queue",
+ "//aos:init",
+ "//aos/events:shm-event-loop",
+ ],
)
diff --git a/y2016/control_loops/shooter/shooter.cc b/y2016/control_loops/shooter/shooter.cc
index a047f55..6ae7f0e 100644
--- a/y2016/control_loops/shooter/shooter.cc
+++ b/y2016/control_loops/shooter/shooter.cc
@@ -72,8 +72,8 @@
loop_->next_R(1, 0) > 1.0);
}
-Shooter::Shooter(ShooterQueue *my_shooter)
- : aos::controls::ControlLoop<ShooterQueue>(my_shooter),
+Shooter::Shooter(::aos::EventLoop *event_loop, const ::std::string &name)
+ : aos::controls::ControlLoop<ShooterQueue>(event_loop, name),
shots_(0),
last_pre_shot_timeout_(::aos::monotonic_clock::min_time) {}
diff --git a/y2016/control_loops/shooter/shooter.h b/y2016/control_loops/shooter/shooter.h
index ac5b2d7..9e6968f 100644
--- a/y2016/control_loops/shooter/shooter.h
+++ b/y2016/control_loops/shooter/shooter.h
@@ -4,11 +4,11 @@
#include <memory>
#include "aos/controls/control_loop.h"
+#include "aos/events/event-loop.h"
#include "aos/time/time.h"
#include "frc971/control_loops/state_feedback_loop.h"
-
-#include "y2016/control_loops/shooter/shooter_integral_plant.h"
#include "y2016/control_loops/shooter/shooter.q.h"
+#include "y2016/control_loops/shooter/shooter_integral_plant.h"
namespace y2016 {
namespace control_loops {
@@ -56,7 +56,8 @@
class Shooter : public ::aos::controls::ControlLoop<ShooterQueue> {
public:
explicit Shooter(
- ShooterQueue *shooter_queue = &control_loops::shooter::shooter_queue);
+ ::aos::EventLoop *event_loop,
+ const ::std::string &name = ".y2016.control_loops.shooter.shooter_queue");
enum class ShooterLatchState {
// Any shoot commands will be passed through without modification.
diff --git a/y2016/control_loops/shooter/shooter_lib_test.cc b/y2016/control_loops/shooter/shooter_lib_test.cc
index bba603f..3c8be30 100644
--- a/y2016/control_loops/shooter/shooter_lib_test.cc
+++ b/y2016/control_loops/shooter/shooter_lib_test.cc
@@ -53,11 +53,11 @@
::y2016::control_loops::shooter::MakeShooterPlant())),
shooter_plant_right_(new ShooterPlant(
::y2016::control_loops::shooter::MakeShooterPlant())),
- shooter_queue_(".y2016.control_loops.shooter",
- ".y2016.control_loops.shooter.goal",
- ".y2016.control_loops.shooter.position",
- ".y2016.control_loops.shooter.output",
- ".y2016.control_loops.shooter.status") {}
+ shooter_queue_(".y2016.control_loops.shooter.shooter_queue",
+ ".y2016.control_loops.shooter.shooter_queue.goal",
+ ".y2016.control_loops.shooter.shooter_queue.position",
+ ".y2016.control_loops.shooter.shooter_queue.output",
+ ".y2016.control_loops.shooter.shooter_queue.status") {}
// Sends a queue message with the position of the shooter.
void SendPositionMessage() {
@@ -101,12 +101,12 @@
class ShooterTest : public ::aos::testing::ControlLoopTest {
protected:
ShooterTest()
- : shooter_queue_(".y2016.control_loops.shooter",
- ".y2016.control_loops.shooter.goal",
- ".y2016.control_loops.shooter.position",
- ".y2016.control_loops.shooter.output",
- ".y2016.control_loops.shooter.status"),
- shooter_(&shooter_queue_),
+ : shooter_queue_(".y2016.control_loops.shooter.shooter_queue",
+ ".y2016.control_loops.shooter.shooter_queue.goal",
+ ".y2016.control_loops.shooter.shooter_queue.position",
+ ".y2016.control_loops.shooter.shooter_queue.output",
+ ".y2016.control_loops.shooter.shooter_queue.status"),
+ shooter_(&event_loop_),
shooter_plant_() {
set_team_id(kTeamNumber);
}
@@ -153,6 +153,7 @@
// is no longer valid.
ShooterQueue shooter_queue_;
+ ::aos::ShmEventLoop event_loop_;
// Create a control loop and simulation.
Shooter shooter_;
ShooterSimulation shooter_plant_;
diff --git a/y2016/control_loops/shooter/shooter_main.cc b/y2016/control_loops/shooter/shooter_main.cc
index 2e1d875..8070dde 100644
--- a/y2016/control_loops/shooter/shooter_main.cc
+++ b/y2016/control_loops/shooter/shooter_main.cc
@@ -1,10 +1,12 @@
#include "y2016/control_loops/shooter/shooter.h"
+#include "aos/events/shm-event-loop.h"
#include "aos/init.h"
int main() {
::aos::Init();
- ::y2016::control_loops::shooter::Shooter shooter;
+ ::aos::ShmEventLoop event_loop;
+ ::y2016::control_loops::shooter::Shooter shooter(&event_loop);
shooter.Run();
::aos::Cleanup();
return 0;