Switch all robots over to use EventLoop
Stop using the old QueueGroup constructor for ControlLoop
Change-Id: I027febf86e75399a97cdb4dc50dbc475705e0393
diff --git a/y2016/control_loops/drivetrain/drivetrain_main.cc b/y2016/control_loops/drivetrain/drivetrain_main.cc
index f461581..e74ddea 100644
--- a/y2016/control_loops/drivetrain/drivetrain_main.cc
+++ b/y2016/control_loops/drivetrain/drivetrain_main.cc
@@ -1,5 +1,6 @@
#include "aos/init.h"
+#include "aos/events/shm-event-loop.h"
#include "frc971/control_loops/drivetrain/drivetrain.h"
#include "y2016/control_loops/drivetrain/drivetrain_base.h"
@@ -7,8 +8,9 @@
int main() {
::aos::Init();
+ ::aos::ShmEventLoop event_loop;
DrivetrainLoop drivetrain(
- ::y2016::control_loops::drivetrain::GetDrivetrainConfig());
+ ::y2016::control_loops::drivetrain::GetDrivetrainConfig(), &event_loop);
drivetrain.Run();
::aos::Cleanup();
return 0;
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;
diff --git a/y2016/control_loops/superstructure/BUILD b/y2016/control_loops/superstructure/BUILD
index 7f08651..6a14a5f 100644
--- a/y2016/control_loops/superstructure/BUILD
+++ b/y2016/control_loops/superstructure/BUILD
@@ -1,118 +1,119 @@
-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 = 'superstructure_queue',
- srcs = [
- 'superstructure.q',
- ],
- deps = [
- '//aos/controls:control_loop_queues',
- '//frc971/control_loops:queues',
- ],
+ name = "superstructure_queue",
+ srcs = [
+ "superstructure.q",
+ ],
+ deps = [
+ "//aos/controls:control_loop_queues",
+ "//frc971/control_loops:queues",
+ ],
)
genrule(
- name = 'genrule_intake',
- visibility = ['//visibility:private'],
- cmd = '$(location //y2016/control_loops/python:intake) $(OUTS)',
- tools = [
- '//y2016/control_loops/python:intake',
- ],
- outs = [
- 'intake_plant.h',
- 'intake_plant.cc',
- 'integral_intake_plant.h',
- 'integral_intake_plant.cc',
- ],
+ name = "genrule_intake",
+ outs = [
+ "intake_plant.h",
+ "intake_plant.cc",
+ "integral_intake_plant.h",
+ "integral_intake_plant.cc",
+ ],
+ cmd = "$(location //y2016/control_loops/python:intake) $(OUTS)",
+ tools = [
+ "//y2016/control_loops/python:intake",
+ ],
+ visibility = ["//visibility:private"],
)
genrule(
- name = 'genrule_arm',
- visibility = ['//visibility:private'],
- cmd = '$(location //y2016/control_loops/python:arm) $(OUTS)',
- tools = [
- '//y2016/control_loops/python:arm',
- ],
- outs = [
- 'arm_plant.h',
- 'arm_plant.cc',
- 'integral_arm_plant.h',
- 'integral_arm_plant.cc',
- ],
+ name = "genrule_arm",
+ outs = [
+ "arm_plant.h",
+ "arm_plant.cc",
+ "integral_arm_plant.h",
+ "integral_arm_plant.cc",
+ ],
+ cmd = "$(location //y2016/control_loops/python:arm) $(OUTS)",
+ tools = [
+ "//y2016/control_loops/python:arm",
+ ],
+ visibility = ["//visibility:private"],
)
cc_library(
- name = 'superstructure_plants',
- srcs = [
- 'intake_plant.cc',
- 'arm_plant.cc',
- 'integral_intake_plant.cc',
- 'integral_arm_plant.cc',
- ],
- hdrs = [
- 'intake_plant.h',
- 'arm_plant.h',
- 'integral_intake_plant.h',
- 'integral_arm_plant.h',
- ],
- deps = [
- '//frc971/control_loops:state_feedback_loop',
- ],
+ name = "superstructure_plants",
+ srcs = [
+ "arm_plant.cc",
+ "intake_plant.cc",
+ "integral_arm_plant.cc",
+ "integral_intake_plant.cc",
+ ],
+ hdrs = [
+ "arm_plant.h",
+ "intake_plant.h",
+ "integral_arm_plant.h",
+ "integral_intake_plant.h",
+ ],
+ deps = [
+ "//frc971/control_loops:state_feedback_loop",
+ ],
)
cc_library(
- name = 'superstructure_lib',
- srcs = [
- 'superstructure.cc',
- 'superstructure_controls.cc',
- ],
- hdrs = [
- 'superstructure.h',
- 'superstructure_controls.h',
- ],
- deps = [
- ':superstructure_queue',
- ':superstructure_plants',
- '//aos/controls:control_loop',
- '//aos/util:trapezoid_profile',
- '//aos:math',
- '//frc971/control_loops:profiled_subsystem',
- '//frc971/control_loops:simple_capped_state_feedback_loop',
- '//frc971/control_loops:state_feedback_loop',
- '//frc971/zeroing',
- '//y2016/queues:ball_detector',
- '//y2016:constants',
- ],
+ name = "superstructure_lib",
+ srcs = [
+ "superstructure.cc",
+ "superstructure_controls.cc",
+ ],
+ hdrs = [
+ "superstructure.h",
+ "superstructure_controls.h",
+ ],
+ deps = [
+ ":superstructure_plants",
+ ":superstructure_queue",
+ "//aos:math",
+ "//aos/controls:control_loop",
+ "//aos/util:trapezoid_profile",
+ "//frc971/control_loops:profiled_subsystem",
+ "//frc971/control_loops:simple_capped_state_feedback_loop",
+ "//frc971/control_loops:state_feedback_loop",
+ "//frc971/zeroing",
+ "//y2016:constants",
+ "//y2016/queues:ball_detector",
+ ],
)
cc_test(
- name = 'superstructure_lib_test',
- srcs = [
- 'superstructure_lib_test.cc',
- ],
- deps = [
- ':superstructure_queue',
- ':superstructure_lib',
- '//aos/testing:googletest',
- '//aos:queues',
- '//aos/controls:control_loop_test',
- '//aos:math',
- '//aos/time:time',
- '//frc971/control_loops:position_sensor_sim',
- '//frc971/control_loops:team_number_test_environment',
- ],
+ name = "superstructure_lib_test",
+ srcs = [
+ "superstructure_lib_test.cc",
+ ],
+ deps = [
+ ":superstructure_lib",
+ ":superstructure_queue",
+ "//aos:math",
+ "//aos:queues",
+ "//aos/controls:control_loop_test",
+ "//aos/testing:googletest",
+ "//aos/time",
+ "//frc971/control_loops:position_sensor_sim",
+ "//frc971/control_loops:team_number_test_environment",
+ ],
)
cc_binary(
- name = 'superstructure',
- srcs = [
- 'superstructure_main.cc',
- ],
- deps = [
- '//aos:init',
- ':superstructure_lib',
- ':superstructure_queue',
- ],
+ name = "superstructure",
+ srcs = [
+ "superstructure_main.cc",
+ ],
+ deps = [
+ ":superstructure_lib",
+ ":superstructure_queue",
+ "//aos:init",
+ "//aos/events:shm-event-loop",
+ ],
)
diff --git a/y2016/control_loops/superstructure/superstructure.cc b/y2016/control_loops/superstructure/superstructure.cc
index 1bcac52..984bcc3 100644
--- a/y2016/control_loops/superstructure/superstructure.cc
+++ b/y2016/control_loops/superstructure/superstructure.cc
@@ -225,10 +225,10 @@
constexpr double CollisionAvoidance::kMaxWristAngleForSafeArmStowing;
constexpr double CollisionAvoidance::kMaxShoulderAngleUntilSafeIntakeStowing;
-Superstructure::Superstructure(
- control_loops::SuperstructureQueue *superstructure_queue)
- : aos::controls::ControlLoop<control_loops::SuperstructureQueue>(
- superstructure_queue),
+Superstructure::Superstructure(::aos::EventLoop *event_loop,
+ const ::std::string &name)
+ : aos::controls::ControlLoop<control_loops::SuperstructureQueue>(event_loop,
+ name),
collision_avoidance_(&intake_, &arm_) {}
bool Superstructure::IsArmNear(double shoulder_tolerance,
diff --git a/y2016/control_loops/superstructure/superstructure.h b/y2016/control_loops/superstructure/superstructure.h
index 17a1547..7215067 100644
--- a/y2016/control_loops/superstructure/superstructure.h
+++ b/y2016/control_loops/superstructure/superstructure.h
@@ -107,8 +107,8 @@
: public ::aos::controls::ControlLoop<control_loops::SuperstructureQueue> {
public:
explicit Superstructure(
- control_loops::SuperstructureQueue *my_superstructure =
- &control_loops::superstructure_queue);
+ ::aos::EventLoop *event_loop,
+ const ::std::string &name = ".y2016.control_loops.superstructure_queue");
static constexpr double kZeroingVoltage = 6.0;
static constexpr double kShooterHangingVoltage = 6.0;
diff --git a/y2016/control_loops/superstructure/superstructure_lib_test.cc b/y2016/control_loops/superstructure/superstructure_lib_test.cc
index 57ca9fa..d0c4362 100644
--- a/y2016/control_loops/superstructure/superstructure_lib_test.cc
+++ b/y2016/control_loops/superstructure/superstructure_lib_test.cc
@@ -88,11 +88,11 @@
pot_encoder_shoulder_(
constants::Values::kShoulderEncoderIndexDifference),
pot_encoder_wrist_(constants::Values::kWristEncoderIndexDifference),
- superstructure_queue_(".y2016.control_loops.superstructure",
- ".y2016.control_loops.superstructure.goal",
- ".y2016.control_loops.superstructure.position",
- ".y2016.control_loops.superstructure.output",
- ".y2016.control_loops.superstructure.status") {
+ superstructure_queue_(".y2016.control_loops.superstructure_queue",
+ ".y2016.control_loops.superstructure_queue.goal",
+ ".y2016.control_loops.superstructure_queue.position",
+ ".y2016.control_loops.superstructure_queue.output",
+ ".y2016.control_loops.superstructure_queue.status") {
InitializeIntakePosition(0.0);
InitializeShoulderPosition(0.0);
InitializeRelativeWristPosition(0.0);
@@ -246,12 +246,12 @@
class SuperstructureTest : public ::aos::testing::ControlLoopTest {
protected:
SuperstructureTest()
- : superstructure_queue_(".y2016.control_loops.superstructure",
- ".y2016.control_loops.superstructure.goal",
- ".y2016.control_loops.superstructure.position",
- ".y2016.control_loops.superstructure.output",
- ".y2016.control_loops.superstructure.status"),
- superstructure_(&superstructure_queue_),
+ : superstructure_queue_(".y2016.control_loops.superstructure_queue",
+ ".y2016.control_loops.superstructure_queue.goal",
+ ".y2016.control_loops.superstructure_queue.position",
+ ".y2016.control_loops.superstructure_queue.output",
+ ".y2016.control_loops.superstructure_queue.status"),
+ superstructure_(&event_loop_),
superstructure_plant_() {}
void VerifyNearGoal() {
@@ -375,6 +375,7 @@
// shared memory that is no longer valid.
SuperstructureQueue superstructure_queue_;
+ ::aos::ShmEventLoop event_loop_;
// Create a control loop and simulation.
Superstructure superstructure_;
SuperstructureSimulation superstructure_plant_;
diff --git a/y2016/control_loops/superstructure/superstructure_main.cc b/y2016/control_loops/superstructure/superstructure_main.cc
index a08074d..435724b 100644
--- a/y2016/control_loops/superstructure/superstructure_main.cc
+++ b/y2016/control_loops/superstructure/superstructure_main.cc
@@ -1,10 +1,13 @@
#include "y2016/control_loops/superstructure/superstructure.h"
+#include "aos/events/shm-event-loop.h"
#include "aos/init.h"
int main() {
::aos::Init();
- ::y2016::control_loops::superstructure::Superstructure superstructure;
+ ::aos::ShmEventLoop event_loop;
+ ::y2016::control_loops::superstructure::Superstructure superstructure(
+ &event_loop);
superstructure.Run();
::aos::Cleanup();
return 0;