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/y2014/control_loops/shooter/BUILD b/y2014/control_loops/shooter/BUILD
index 9f71e95..d67050d 100644
--- a/y2014/control_loops/shooter/BUILD
+++ b/y2014/control_loops/shooter/BUILD
@@ -78,7 +78,7 @@
":shooter_output_fbs",
":shooter_position_fbs",
":shooter_status_fbs",
- "//aos/controls:control_loop",
+ "//frc971/control_loops:control_loop",
"//frc971/control_loops:control_loops_fbs",
"//frc971/control_loops:state_feedback_loop",
"//y2014:constants",
@@ -98,7 +98,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/y2014/control_loops/shooter/shooter.cc b/y2014/control_loops/shooter/shooter.cc
index fb115c7..52f900a 100644
--- a/y2014/control_loops/shooter/shooter.cc
+++ b/y2014/control_loops/shooter/shooter.cc
@@ -3,8 +3,8 @@
#include <stdio.h>
#include <algorithm>
-#include <limits>
#include <chrono>
+#include <limits>
#include "aos/logging/logging.h"
#include "y2014/constants.h"
@@ -17,9 +17,9 @@
namespace chrono = ::std::chrono;
using ::aos::monotonic_clock;
-using ::y2014::control_loops::shooter::kSpringConstant;
-using ::y2014::control_loops::shooter::kMaxExtension;
using ::y2014::control_loops::shooter::kDt;
+using ::y2014::control_loops::shooter::kMaxExtension;
+using ::y2014::control_loops::shooter::kSpringConstant;
using ::y2014::control_loops::shooter::MakeShooterLoop;
void ZeroedStateFeedbackLoop::CapU() {
@@ -103,8 +103,8 @@
ShooterMotor::ShooterMotor(::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),
shooter_(MakeShooterLoop()),
state_(STATE_INITIALIZE),
cycles_not_moved_(0),
@@ -138,7 +138,7 @@
}
new_pos = ::std::min(::std::max(new_pos, values.shooter.lower_limit),
- values.shooter.upper_limit);
+ values.shooter.upper_limit);
return new_pos;
}
@@ -162,9 +162,8 @@
if (position->pusher_proximal()->current()) {
--proximal_posedge_validation_cycles_left_;
if (proximal_posedge_validation_cycles_left_ == 0) {
- shooter_.SetCalibration(
- position->pusher_proximal()->posedge_value(),
- values.shooter.pusher_proximal.upper_angle);
+ shooter_.SetCalibration(position->pusher_proximal()->posedge_value(),
+ values.shooter.pusher_proximal.upper_angle);
AOS_LOG(DEBUG, "Setting calibration using proximal sensor\n");
zeroed_ = true;
@@ -183,9 +182,8 @@
if (position->pusher_distal()->current()) {
--distal_posedge_validation_cycles_left_;
if (distal_posedge_validation_cycles_left_ == 0) {
- shooter_.SetCalibration(
- position->pusher_distal()->posedge_value(),
- values.shooter.pusher_distal.upper_angle);
+ shooter_.SetCalibration(position->pusher_distal()->posedge_value(),
+ values.shooter.pusher_distal.upper_angle);
AOS_LOG(DEBUG, "Setting calibration using distal sensor\n");
zeroed_ = true;
@@ -197,13 +195,12 @@
}
// Positive is out, and positive power is out.
-void ShooterMotor::RunIteration(
- const Goal *goal,
- const Position *position,
- aos::Sender<Output>::Builder *output,
- aos::Sender<Status>::Builder *status) {
+void ShooterMotor::RunIteration(const Goal *goal, const Position *position,
+ aos::Sender<Output>::Builder *output,
+ aos::Sender<Status>::Builder *status) {
OutputT output_struct;
- const monotonic_clock::time_point monotonic_now = event_loop()->monotonic_now();
+ const monotonic_clock::time_point monotonic_now =
+ event_loop()->monotonic_now();
if (goal && ::std::isnan(goal->shot_power())) {
state_ = STATE_ESTOP;
AOS_LOG(ERROR, "Estopping because got a shot power of NAN.\n");
@@ -362,7 +359,7 @@
latch_piston_ = true;
}
if (output == nullptr) {
- load_timeout_ += ::aos::controls::kLoopFrequency;
+ load_timeout_ += ::frc971::controls::kLoopFrequency;
}
// Go to 0, which should be the latch position, or trigger a hall effect
// on the way. If we don't see edges where we are supposed to, the
@@ -391,8 +388,7 @@
shooter_.goal_position()) < 0.001) {
// We are at the goal, but not latched.
state_ = STATE_LOADING_PROBLEM;
- loading_problem_end_time_ =
- monotonic_now + kLoadProblemEndTimeout;
+ loading_problem_end_time_ = monotonic_now + kLoadProblemEndTimeout;
}
}
if (load_timeout_ < monotonic_now) {
diff --git a/y2014/control_loops/shooter/shooter.h b/y2014/control_loops/shooter/shooter.h
index 1e7d4aa..ec383ad 100644
--- a/y2014/control_loops/shooter/shooter.h
+++ b/y2014/control_loops/shooter/shooter.h
@@ -3,10 +3,9 @@
#include <memory>
-#include "aos/controls/control_loop.h"
-#include "frc971/control_loops/state_feedback_loop.h"
+#include "frc971/control_loops/control_loop.h"
#include "aos/time/time.h"
-
+#include "frc971/control_loops/state_feedback_loop.h"
#include "y2014/constants.h"
#include "y2014/control_loops/shooter/shooter_goal_generated.h"
#include "y2014/control_loops/shooter/shooter_motor_plant.h"
@@ -21,7 +20,7 @@
class ShooterTest_UnloadWindupPositive_Test;
class ShooterTest_UnloadWindupNegative_Test;
class ShooterTest_RezeroWhileUnloading_Test;
-};
+}; // namespace testing
// Note: Everything in this file assumes that there is a 1 cycle delay between
// power being requested and it showing up at the motor. It assumes that
@@ -131,7 +130,7 @@
::std::chrono::milliseconds(40);
class ShooterMotor
- : public aos::controls::ControlLoop<Goal, Position, Status, Output> {
+ : public frc971::controls::ControlLoop<Goal, Position, Status, Output> {
public:
explicit ShooterMotor(::aos::EventLoop *event_loop,
const ::std::string &name = "/shooter");
diff --git a/y2014/control_loops/shooter/shooter_lib_test.cc b/y2014/control_loops/shooter/shooter_lib_test.cc
index 0a7f4f6..d3217a6 100644
--- a/y2014/control_loops/shooter/shooter_lib_test.cc
+++ b/y2014/control_loops/shooter/shooter_lib_test.cc
@@ -3,8 +3,8 @@
#include <chrono>
#include <memory>
-#include "aos/controls/control_loop_test.h"
#include "aos/network/team_number.h"
+#include "frc971/control_loops/control_loop_test.h"
#include "frc971/control_loops/team_number_test_environment.h"
#include "gtest/gtest.h"
#include "y2014/constants.h"
@@ -23,9 +23,9 @@
namespace shooter {
namespace testing {
+using ::frc971::control_loops::testing::kTeamNumber;
using ::y2014::control_loops::shooter::kMaxExtension;
using ::y2014::control_loops::shooter::MakeRawShooterPlant;
-using ::frc971::control_loops::testing::kTeamNumber;
// Class which simulates the shooter and sends out queue messages containing the
// position.
@@ -133,8 +133,7 @@
void UpdateEffectEdge(
::frc971::PosedgeOnlyCountedHallEffectStructT *sensor,
const ::frc971::PosedgeOnlyCountedHallEffectStructT &last_sensor,
- const constants::Values::AnglePair &limits,
- float last_position) {
+ const constants::Values::AnglePair &limits, float last_position) {
sensor->posedge_count = last_sensor.posedge_count;
sensor->negedge_count = last_sensor.negedge_count;
@@ -288,7 +287,7 @@
last_voltage_ = shooter_output_fetcher_->voltage();
}
- private:
+ private:
::aos::EventLoop *event_loop_;
::aos::Sender<Position> shooter_position_sender_;
::aos::Fetcher<Output> shooter_output_fetcher_;
@@ -327,10 +326,10 @@
template <typename TestType>
class ShooterTestTemplated
- : public ::aos::testing::ControlLoopTestTemplated<TestType> {
+ : public ::frc971::testing::ControlLoopTestTemplated<TestType> {
protected:
ShooterTestTemplated()
- : ::aos::testing::ControlLoopTestTemplated<TestType>(
+ : ::frc971::testing::ControlLoopTestTemplated<TestType>(
aos::configuration::ReadConfig("y2014/config.json"),
// TODO(austin): I think this runs at 5 ms in real life.
chrono::microseconds(5000)),
@@ -554,7 +553,6 @@
EXPECT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
}
-
TEST_F(ShooterTest, Unload) {
SetEnabled(true);
{
@@ -727,7 +725,6 @@
EXPECT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
}
-
// Tests that the shooter zeros correctly and goes to a position.
TEST_F(ShooterTest, StartsOnProximal) {
SetEnabled(true);
@@ -760,8 +757,8 @@
bool plunger_back = ::std::get<2>(GetParam());
double start_pos = ::std::get<3>(GetParam());
// flag to initialize test
- //printf("@@@@ l= %d b= %d p= %d s= %.3f\n",
- // latch, brake, plunger_back, start_pos);
+ // printf("@@@@ l= %d b= %d p= %d s= %.3f\n",
+ // latch, brake, plunger_back, start_pos);
bool initialized = false;
Reinitialize(start_pos);
{