Move aos/controls to frc971/control_loops
Also put what was aos/controls/control_loops.fbs in y2012/control_loops
because that's the only user.
Change-Id: I8f402b0708103077e135a41e55ef5e4f23681d87
Signed-off-by: James Kuszmaul <jabukuszmaul@gmail.com>
diff --git a/y2016/control_loops/shooter/BUILD b/y2016/control_loops/shooter/BUILD
index a6cf134..6cae6fa 100644
--- a/y2016/control_loops/shooter/BUILD
+++ b/y2016/control_loops/shooter/BUILD
@@ -85,7 +85,7 @@
":shooter_plants",
":shooter_position_fbs",
":shooter_status_fbs",
- "//aos/controls:control_loop",
+ "//frc971/control_loops:control_loop",
],
)
@@ -102,7 +102,7 @@
":shooter_output_fbs",
":shooter_position_fbs",
":shooter_status_fbs",
- "//aos/controls:control_loop_test",
+ "//frc971/control_loops:control_loop_test",
"//aos/testing:googletest",
"//frc971/control_loops:state_feedback_loop",
"//frc971/control_loops:team_number_test_environment",
diff --git a/y2016/control_loops/shooter/shooter.cc b/y2016/control_loops/shooter/shooter.cc
index 5156a61..8b719c3 100644
--- a/y2016/control_loops/shooter/shooter.cc
+++ b/y2016/control_loops/shooter/shooter.cc
@@ -56,7 +56,7 @@
// Compute the distance moved over that time period.
const double avg_angular_velocity =
(history_[oldest_history_position] - history_[history_position_]) /
- (::aos::time::DurationInSeconds(::aos::controls::kLoopFrequency) *
+ (::aos::time::DurationInSeconds(::frc971::controls::kLoopFrequency) *
static_cast<double>(kHistoryLength - 1));
shooter_side_status_builder.add_avg_angular_velocity(avg_angular_velocity);
@@ -71,8 +71,8 @@
}
Shooter::Shooter(::aos::EventLoop *event_loop, const ::std::string &name)
- : aos::controls::ControlLoop<Goal, Position, Status, Output>(event_loop,
- name),
+ : frc971::controls::ControlLoop<Goal, Position, Status, Output>(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 07fee84..c29869c 100644
--- a/y2016/control_loops/shooter/shooter.h
+++ b/y2016/control_loops/shooter/shooter.h
@@ -3,7 +3,7 @@
#include <memory>
-#include "aos/controls/control_loop.h"
+#include "frc971/control_loops/control_loop.h"
#include "aos/events/event_loop.h"
#include "aos/time/time.h"
#include "frc971/control_loops/state_feedback_loop.h"
@@ -58,7 +58,7 @@
};
class Shooter
- : public ::aos::controls::ControlLoop<Goal, Position, Status, Output> {
+ : public ::frc971::controls::ControlLoop<Goal, Position, Status, Output> {
public:
explicit Shooter(::aos::EventLoop *event_loop,
const ::std::string &name = "/shooter");
diff --git a/y2016/control_loops/shooter/shooter_lib_test.cc b/y2016/control_loops/shooter/shooter_lib_test.cc
index c20526c..6934a75 100644
--- a/y2016/control_loops/shooter/shooter_lib_test.cc
+++ b/y2016/control_loops/shooter/shooter_lib_test.cc
@@ -1,11 +1,9 @@
-#include "y2016/control_loops/shooter/shooter.h"
-
#include <unistd.h>
#include <chrono>
#include <memory>
-#include "aos/controls/control_loop_test.h"
+#include "frc971/control_loops/control_loop_test.h"
#include "frc971/control_loops/team_number_test_environment.h"
#include "gtest/gtest.h"
#include "y2016/control_loops/shooter/shooter.h"
@@ -44,7 +42,6 @@
double voltage_offset_ = 0.0;
};
-
// Class which simulates the shooter and sends out queue messages with the
// position.
class ShooterSimulation {
@@ -116,10 +113,10 @@
bool first_ = true;
};
-class ShooterTest : public ::aos::testing::ControlLoopTest {
+class ShooterTest : public ::frc971::testing::ControlLoopTest {
protected:
ShooterTest()
- : ::aos::testing::ControlLoopTest(
+ : ::frc971::testing::ControlLoopTest(
aos::configuration::ReadConfig("y2016/config.json"),
chrono::microseconds(5000)),
test_event_loop_(MakeEventLoop("test")),
diff --git a/y2016/control_loops/superstructure/BUILD b/y2016/control_loops/superstructure/BUILD
index cb07ebe..b4c26d9 100644
--- a/y2016/control_loops/superstructure/BUILD
+++ b/y2016/control_loops/superstructure/BUILD
@@ -114,7 +114,7 @@
":superstructure_position_fbs",
":superstructure_status_fbs",
"//aos:math",
- "//aos/controls:control_loop",
+ "//frc971/control_loops:control_loop",
"//aos/util:trapezoid_profile",
"//frc971/control_loops:profiled_subsystem",
"//frc971/control_loops:simple_capped_state_feedback_loop",
@@ -139,7 +139,7 @@
":superstructure_position_fbs",
":superstructure_status_fbs",
"//aos:math",
- "//aos/controls:control_loop_test",
+ "//frc971/control_loops:control_loop_test",
"//aos/testing:googletest",
"//aos/time",
"//frc971/control_loops:position_sensor_sim",
diff --git a/y2016/control_loops/superstructure/superstructure.cc b/y2016/control_loops/superstructure/superstructure.cc
index 8f4d02e..3ee7730 100644
--- a/y2016/control_loops/superstructure/superstructure.cc
+++ b/y2016/control_loops/superstructure/superstructure.cc
@@ -2,14 +2,12 @@
#include "aos/commonmath.h"
#include "aos/logging/logging.h"
-
+#include "y2016/constants.h"
#include "y2016/control_loops/superstructure/integral_arm_plant.h"
#include "y2016/control_loops/superstructure/integral_intake_plant.h"
#include "y2016/control_loops/superstructure/superstructure_controls.h"
#include "y2016/queues/ball_detector_generated.h"
-#include "y2016/constants.h"
-
namespace y2016 {
namespace control_loops {
namespace superstructure {
@@ -207,9 +205,9 @@
// The wrist must go back to zero when the shoulder is moving the arm into
// a stowed/intaking position.
- if (shoulder_angle <
- CollisionAvoidance::kMinShoulderAngleForHorizontalShooter &&
- ::std::abs(wrist_angle) > kMaxWristAngleForSafeArmStowing) {
+ if (shoulder_angle<CollisionAvoidance::kMinShoulderAngleForHorizontalShooter
+ && ::std::abs(wrist_angle)>
+ kMaxWristAngleForSafeArmStowing) {
AOS_LOG(DEBUG, "Collided: Shoulder %f < %f and wrist |%f| > %f.\n",
shoulder_angle,
CollisionAvoidance::kMinShoulderAngleForHorizontalShooter,
@@ -228,8 +226,8 @@
Superstructure::Superstructure(::aos::EventLoop *event_loop,
const ::std::string &name)
- : aos::controls::ControlLoop<Goal, Position, Status, Output>(event_loop,
- name),
+ : frc971::controls::ControlLoop<Goal, Position, Status, Output>(event_loop,
+ name),
ball_detector_fetcher_(
event_loop->MakeFetcher<::y2016::sensors::BallDetector>(
"/superstructure")),
@@ -287,11 +285,10 @@
}
}
-void Superstructure::RunIteration(
- const Goal *unsafe_goal,
- const Position *position,
- aos::Sender<Output>::Builder *output,
- aos::Sender<Status>::Builder *status) {
+void Superstructure::RunIteration(const Goal *unsafe_goal,
+ const Position *position,
+ aos::Sender<Output>::Builder *output,
+ aos::Sender<Status>::Builder *status) {
const State state_before_switch = state_;
if (WasReset()) {
AOS_LOG(ERROR, "WPILib reset, restarting\n");
@@ -727,9 +724,10 @@
// Intake.
if (unsafe_goal->force_intake() || !ball_detected) {
- output_struct.voltage_top_rollers = ::std::max(
- -kMaxIntakeTopVoltage,
- ::std::min(unsafe_goal->voltage_top_rollers(), kMaxIntakeTopVoltage));
+ output_struct.voltage_top_rollers =
+ ::std::max(-kMaxIntakeTopVoltage,
+ ::std::min(unsafe_goal->voltage_top_rollers(),
+ kMaxIntakeTopVoltage));
output_struct.voltage_bottom_rollers =
::std::max(-kMaxIntakeBottomVoltage,
::std::min(unsafe_goal->voltage_bottom_rollers(),
diff --git a/y2016/control_loops/superstructure/superstructure.h b/y2016/control_loops/superstructure/superstructure.h
index 2219c95..48da666 100644
--- a/y2016/control_loops/superstructure/superstructure.h
+++ b/y2016/control_loops/superstructure/superstructure.h
@@ -3,10 +3,9 @@
#include <memory>
-#include "aos/controls/control_loop.h"
+#include "frc971/control_loops/control_loop.h"
#include "aos/util/trapezoid_profile.h"
#include "frc971/control_loops/state_feedback_loop.h"
-
#include "frc971/zeroing/zeroing.h"
#include "y2016/control_loops/superstructure/superstructure_controls.h"
#include "y2016/control_loops/superstructure/superstructure_goal_generated.h"
@@ -108,7 +107,7 @@
};
class Superstructure
- : public ::aos::controls::ControlLoop<Goal, Position, Status, Output> {
+ : public ::frc971::controls::ControlLoop<Goal, Position, Status, Output> {
public:
explicit Superstructure(::aos::EventLoop *event_loop,
const ::std::string &name = "/superstructure");
diff --git a/y2016/control_loops/superstructure/superstructure_controls.cc b/y2016/control_loops/superstructure/superstructure_controls.cc
index 269089b..d16c73c 100644
--- a/y2016/control_loops/superstructure/superstructure_controls.cc
+++ b/y2016/control_loops/superstructure/superstructure_controls.cc
@@ -1,11 +1,9 @@
#include "y2016/control_loops/superstructure/superstructure_controls.h"
#include "aos/logging/logging.h"
-
-#include "y2016/control_loops/superstructure/integral_intake_plant.h"
-#include "y2016/control_loops/superstructure/integral_arm_plant.h"
-
#include "y2016/constants.h"
+#include "y2016/control_loops/superstructure/integral_arm_plant.h"
+#include "y2016/control_loops/superstructure/integral_intake_plant.h"
namespace y2016 {
namespace control_loops {
@@ -45,8 +43,8 @@
constants::GetValues().shoulder.zeroing),
::frc971::zeroing::PotAndIndexPulseZeroingEstimator(
constants::GetValues().wrist.zeroing)}}),
- shoulder_profile_(::aos::controls::kLoopFrequency),
- wrist_profile_(::aos::controls::kLoopFrequency) {
+ shoulder_profile_(::frc971::controls::kLoopFrequency),
+ wrist_profile_(::frc971::controls::kLoopFrequency) {
Y_.setZero();
offset_.setZero();
AdjustProfile(0.0, 0.0, 0.0, 0.0);
diff --git a/y2016/control_loops/superstructure/superstructure_controls.h b/y2016/control_loops/superstructure/superstructure_controls.h
index d301054..a73883b 100644
--- a/y2016/control_loops/superstructure/superstructure_controls.h
+++ b/y2016/control_loops/superstructure/superstructure_controls.h
@@ -3,7 +3,7 @@
#include <memory>
-#include "aos/controls/control_loop.h"
+#include "frc971/control_loops/control_loop.h"
#include "aos/util/trapezoid_profile.h"
#include "frc971/control_loops/profiled_subsystem.h"
#include "frc971/control_loops/simple_capped_state_feedback_loop.h"
diff --git a/y2016/control_loops/superstructure/superstructure_lib_test.cc b/y2016/control_loops/superstructure/superstructure_lib_test.cc
index 24bc187..49ae033 100644
--- a/y2016/control_loops/superstructure/superstructure_lib_test.cc
+++ b/y2016/control_loops/superstructure/superstructure_lib_test.cc
@@ -1,25 +1,23 @@
-#include "y2016/control_loops/superstructure/superstructure.h"
-
#include <unistd.h>
#include <chrono>
#include <memory>
#include "aos/commonmath.h"
-#include "aos/controls/control_loop_test.h"
#include "aos/time/time.h"
+#include "frc971/control_loops/control_loop_test.h"
#include "frc971/control_loops/position_sensor_sim.h"
#include "frc971/control_loops/team_number_test_environment.h"
#include "gtest/gtest.h"
+#include "y2016/constants.h"
#include "y2016/control_loops/superstructure/arm_plant.h"
#include "y2016/control_loops/superstructure/intake_plant.h"
+#include "y2016/control_loops/superstructure/superstructure.h"
#include "y2016/control_loops/superstructure/superstructure_goal_generated.h"
#include "y2016/control_loops/superstructure/superstructure_output_generated.h"
#include "y2016/control_loops/superstructure/superstructure_position_generated.h"
#include "y2016/control_loops/superstructure/superstructure_status_generated.h"
-#include "y2016/constants.h"
-
using ::frc971::control_loops::PositionSensorSimulator;
namespace y2016 {
@@ -350,10 +348,10 @@
double peak_wrist_velocity_ = 1e10;
};
-class SuperstructureTest : public ::aos::testing::ControlLoopTest {
+class SuperstructureTest : public ::frc971::testing::ControlLoopTest {
protected:
SuperstructureTest()
- : ::aos::testing::ControlLoopTest(
+ : ::frc971::testing::ControlLoopTest(
aos::configuration::ReadConfig("y2016/config.json"),
chrono::microseconds(5000)),
test_event_loop_(MakeEventLoop("test")),