Rename control loop queues to the new convention.
Change-Id: I306be7867038e384af19d8b4db77eaf6c20b5c7e
diff --git a/y2014/autonomous/auto.cc b/y2014/autonomous/auto.cc
index f3f3bee..a234890 100644
--- a/y2014/autonomous/auto.cc
+++ b/y2014/autonomous/auto.cc
@@ -166,24 +166,24 @@
// Poll the running bit and auto done bits.
// TODO(sensors): Fix this time.
::aos::time::PhasedLoop10MS(5000);
- control_loops::claw_queue_group.status.FetchLatest();
- control_loops::claw_queue_group.goal.FetchLatest();
+ control_loops::claw_queue.status.FetchLatest();
+ control_loops::claw_queue.goal.FetchLatest();
if (ShouldExitAuto()) {
return;
}
- if (control_loops::claw_queue_group.status.get() == nullptr ||
- control_loops::claw_queue_group.goal.get() == nullptr) {
+ if (control_loops::claw_queue.status.get() == nullptr ||
+ control_loops::claw_queue.goal.get() == nullptr) {
continue;
}
bool ans =
- control_loops::claw_queue_group.status->zeroed &&
- (::std::abs(control_loops::claw_queue_group.status->bottom_velocity) <
+ control_loops::claw_queue.status->zeroed &&
+ (::std::abs(control_loops::claw_queue.status->bottom_velocity) <
1.0) &&
- (::std::abs(control_loops::claw_queue_group.status->bottom -
- control_loops::claw_queue_group.goal->bottom_angle) <
+ (::std::abs(control_loops::claw_queue.status->bottom -
+ control_loops::claw_queue.goal->bottom_angle) <
0.10) &&
- (::std::abs(control_loops::claw_queue_group.status->separation -
- control_loops::claw_queue_group.goal->separation_angle) <
+ (::std::abs(control_loops::claw_queue.status->separation -
+ control_loops::claw_queue.goal->separation_angle) <
0.4);
if (ans) {
return;
diff --git a/y2014/autonomous/autonomous.gyp b/y2014/autonomous/autonomous.gyp
index d37d36b..ccc29c4 100644
--- a/y2014/autonomous/autonomous.gyp
+++ b/y2014/autonomous/autonomous.gyp
@@ -9,9 +9,9 @@
'dependencies': [
'auto_queue',
'<(AOS)/common/controls/controls.gyp:control_loop',
- '<(DEPTH)/y2014/control_loops/drivetrain/drivetrain.gyp:drivetrain_loop',
- '<(DEPTH)/y2014/control_loops/shooter/shooter.gyp:shooter_loop',
- '<(DEPTH)/y2014/control_loops/claw/claw.gyp:claw_loop',
+ '<(DEPTH)/y2014/control_loops/drivetrain/drivetrain.gyp:drivetrain_queue',
+ '<(DEPTH)/y2014/control_loops/shooter/shooter.gyp:shooter_queue',
+ '<(DEPTH)/y2014/control_loops/claw/claw.gyp:claw_queue',
'<(DEPTH)/y2014/y2014.gyp:constants',
'<(AOS)/common/common.gyp:time',
'<(AOS)/common/util/util.gyp:phased_loop',
diff --git a/y2014/control_loops/claw/claw.cc b/y2014/control_loops/claw/claw.cc
index 00c4341..7322b1e 100644
--- a/y2014/control_loops/claw/claw.cc
+++ b/y2014/control_loops/claw/claw.cc
@@ -364,8 +364,8 @@
return false;
}
-ClawMotor::ClawMotor(control_loops::ClawGroup *my_claw)
- : aos::controls::ControlLoop<control_loops::ClawGroup>(my_claw),
+ClawMotor::ClawMotor(control_loops::ClawQueue *my_claw)
+ : aos::controls::ControlLoop<control_loops::ClawQueue>(my_claw),
has_top_claw_goal_(false),
top_claw_goal_(0.0),
top_claw_(this),
@@ -609,10 +609,10 @@
bool ClawMotor::is_zeroing() const { return !is_ready(); }
// Positive angle is up, and positive power is up.
-void ClawMotor::RunIteration(const control_loops::ClawGroup::Goal *goal,
- const control_loops::ClawGroup::Position *position,
- control_loops::ClawGroup::Output *output,
- control_loops::ClawGroup::Status *status) {
+void ClawMotor::RunIteration(const control_loops::ClawQueue::Goal *goal,
+ const control_loops::ClawQueue::Position *position,
+ control_loops::ClawQueue::Output *output,
+ control_loops::ClawQueue::Status *status) {
constexpr double dt = 0.01;
// Disable the motors now so that all early returns will return with the
diff --git a/y2014/control_loops/claw/claw.gyp b/y2014/control_loops/claw/claw.gyp
index 40315ff..8a6a7c5 100644
--- a/y2014/control_loops/claw/claw.gyp
+++ b/y2014/control_loops/claw/claw.gyp
@@ -16,7 +16,7 @@
],
},
{
- 'target_name': 'claw_loop',
+ 'target_name': 'claw_queue',
'type': 'static_library',
'sources': ['claw.q'],
'variables': {
@@ -40,7 +40,7 @@
'claw_motor_plant.cc',
],
'dependencies': [
- 'claw_loop',
+ 'claw_queue',
'<(AOS)/common/controls/controls.gyp:control_loop',
'<(DEPTH)/y2014/y2014.gyp:constants',
'<(DEPTH)/frc971/control_loops/control_loops.gyp:state_feedback_loop',
@@ -50,7 +50,7 @@
'<(AOS)/common/logging/logging.gyp:matrix_logging',
],
'export_dependent_settings': [
- 'claw_loop',
+ 'claw_queue',
'<(AOS)/common/controls/controls.gyp:control_loop',
'<(DEPTH)/frc971/control_loops/control_loops.gyp:state_feedback_loop',
'<(AOS)/common/controls/controls.gyp:polytope',
@@ -65,7 +65,7 @@
],
'dependencies': [
'<(EXTERNALS):gtest',
- 'claw_loop',
+ 'claw_queue',
'claw_lib',
'<(DEPTH)/frc971/control_loops/control_loops.gyp:state_feedback_loop',
'<(AOS)/common/controls/controls.gyp:control_loop_test',
@@ -79,7 +79,7 @@
],
'dependencies': [
'<(AOS)/linux_code/linux_code.gyp:init',
- 'claw_loop',
+ 'claw_queue',
'<(AOS)/common/controls/controls.gyp:control_loop',
'<(DEPTH)/y2014/y2014.gyp:constants',
],
diff --git a/y2014/control_loops/claw/claw.h b/y2014/control_loops/claw/claw.h
index 86b9b6d..cdd3948 100644
--- a/y2014/control_loops/claw/claw.h
+++ b/y2014/control_loops/claw/claw.h
@@ -182,10 +182,10 @@
const constants::Values::Claws::Claw &claw_values);
};
-class ClawMotor : public aos::controls::ControlLoop<control_loops::ClawGroup> {
+class ClawMotor : public aos::controls::ControlLoop<control_loops::ClawQueue> {
public:
- explicit ClawMotor(control_loops::ClawGroup *my_claw =
- &control_loops::claw_queue_group);
+ explicit ClawMotor(control_loops::ClawQueue *my_claw =
+ &control_loops::claw_queue);
// True if the state machine is ready.
bool capped_goal() const { return capped_goal_; }
@@ -215,10 +215,10 @@
CalibrationMode mode() const { return mode_; }
protected:
- virtual void RunIteration(const control_loops::ClawGroup::Goal *goal,
- const control_loops::ClawGroup::Position *position,
- control_loops::ClawGroup::Output *output,
- control_loops::ClawGroup::Status *status);
+ virtual void RunIteration(const control_loops::ClawQueue::Goal *goal,
+ const control_loops::ClawQueue::Position *position,
+ control_loops::ClawQueue::Output *output,
+ control_loops::ClawQueue::Status *status);
double top_absolute_position() const {
return claw_.X_hat(1, 0) + claw_.X_hat(0, 0);
diff --git a/y2014/control_loops/claw/claw.q b/y2014/control_loops/claw/claw.q
index 6c7dada..a116970 100644
--- a/y2014/control_loops/claw/claw.q
+++ b/y2014/control_loops/claw/claw.q
@@ -16,7 +16,7 @@
};
// All angles here are 0 vertical, positive "up" (aka backwards).
-queue_group ClawGroup {
+queue_group ClawQueue {
implements aos.control_loops.ControlLoop;
message Goal {
@@ -67,7 +67,7 @@
queue Status status;
};
-queue_group ClawGroup claw_queue_group;
+queue_group ClawQueue claw_queue;
struct ClawPositionToLog {
double top;
diff --git a/y2014/control_loops/claw/claw_calibration.cc b/y2014/control_loops/claw/claw_calibration.cc
index 8d806d7..772a940 100644
--- a/y2014/control_loops/claw/claw_calibration.cc
+++ b/y2014/control_loops/claw/claw_calibration.cc
@@ -153,17 +153,17 @@
};
int Main() {
- control_loops::claw_queue_group.position.FetchNextBlocking();
+ control_loops::claw_queue.position.FetchNextBlocking();
const double top_start_position =
- control_loops::claw_queue_group.position->top.position;
+ control_loops::claw_queue.position->top.position;
const double bottom_start_position =
- control_loops::claw_queue_group.position->bottom.position;
+ control_loops::claw_queue.position->bottom.position;
ClawSensors top(top_start_position,
- control_loops::claw_queue_group.position->top);
+ control_loops::claw_queue.position->top);
ClawSensors bottom(bottom_start_position,
- control_loops::claw_queue_group.position->bottom);
+ control_loops::claw_queue.position->bottom);
Claws limits;
@@ -217,28 +217,28 @@
limits.start_fine_tune_pos = -0.2;
limits.max_zeroing_voltage = 4.0;
- control_loops::ClawGroup::Position last_position =
- *control_loops::claw_queue_group.position;
+ control_loops::ClawQueue::Position last_position =
+ *control_loops::claw_queue.position;
while (true) {
- control_loops::claw_queue_group.position.FetchNextBlocking();
+ control_loops::claw_queue.position.FetchNextBlocking();
bool print = false;
- if (top.GetPositionOfEdge(control_loops::claw_queue_group.position->top,
+ if (top.GetPositionOfEdge(control_loops::claw_queue.position->top,
&limits.upper_claw)) {
print = true;
printf("Got an edge on the upper claw\n");
}
if (bottom.GetPositionOfEdge(
- control_loops::claw_queue_group.position->bottom,
+ control_loops::claw_queue.position->bottom,
&limits.lower_claw)) {
print = true;
printf("Got an edge on the lower claw\n");
}
const double top_position =
- control_loops::claw_queue_group.position->top.position -
+ control_loops::claw_queue.position->top.position -
top_start_position;
const double bottom_position =
- control_loops::claw_queue_group.position->bottom.position -
+ control_loops::claw_queue.position->bottom.position -
bottom_start_position;
const double separation = top_position - bottom_position;
if (separation > limits.claw_max_separation) {
@@ -300,7 +300,7 @@
printf("}\n");
}
- last_position = *control_loops::claw_queue_group.position;
+ last_position = *control_loops::claw_queue.position;
}
return 0;
}
diff --git a/y2014/control_loops/claw/claw_lib_test.cc b/y2014/control_loops/claw/claw_lib_test.cc
index 2137316..63383c7 100644
--- a/y2014/control_loops/claw/claw_lib_test.cc
+++ b/y2014/control_loops/claw/claw_lib_test.cc
@@ -42,11 +42,11 @@
ClawMotorSimulation(double initial_top_position,
double initial_bottom_position)
: claw_plant_(new StateFeedbackPlant<4, 2, 2>(MakeClawPlant())),
- claw_queue_group(".frc971.control_loops.claw_queue_group", 0x9f1a99dd,
- ".frc971.control_loops.claw_queue_group.goal",
- ".frc971.control_loops.claw_queue_group.position",
- ".frc971.control_loops.claw_queue_group.output",
- ".frc971.control_loops.claw_queue_group.status") {
+ claw_queue(".frc971.control_loops.claw_queue", 0x9f1a99dd,
+ ".frc971.control_loops.claw_queue.goal",
+ ".frc971.control_loops.claw_queue.position",
+ ".frc971.control_loops.claw_queue.output",
+ ".frc971.control_loops.claw_queue.status") {
Reinitialize(initial_top_position, initial_bottom_position);
}
@@ -106,7 +106,7 @@
// Sets the values of the physical sensors that can be directly observed
// (encoder, hall effect).
- void SetPhysicalSensors(control_loops::ClawGroup::Position *position) {
+ void SetPhysicalSensors(control_loops::ClawQueue::Position *position) {
position->top.position = GetPosition(TOP_CLAW);
position->bottom.position = GetPosition(BOTTOM_CLAW);
@@ -181,8 +181,8 @@
// Sends out the position queue messages.
void SendPositionMessage() {
- ::aos::ScopedMessagePtr<control_loops::ClawGroup::Position> position =
- claw_queue_group.position.MakeMessage();
+ ::aos::ScopedMessagePtr<control_loops::ClawQueue::Position> position =
+ claw_queue.position.MakeMessage();
// Initialize all the counters to their previous values.
*position = last_position_;
@@ -207,10 +207,10 @@
// Simulates the claw moving for one timestep.
void Simulate() {
const frc971::constants::Values& v = constants::GetValues();
- EXPECT_TRUE(claw_queue_group.output.FetchLatest());
+ EXPECT_TRUE(claw_queue.output.FetchLatest());
- claw_plant_->mutable_U() << claw_queue_group.output->bottom_claw_voltage,
- claw_queue_group.output->top_claw_voltage;
+ claw_plant_->mutable_U() << claw_queue.output->bottom_claw_voltage,
+ claw_queue.output->top_claw_voltage;
claw_plant_->Update();
// Check that the claw is within the limits.
@@ -234,10 +234,10 @@
initial_position_[type] = initial_position;
}
- ClawGroup claw_queue_group;
+ ClawQueue claw_queue;
double initial_position_[CLAW_COUNT];
- control_loops::ClawGroup::Position last_position_;
+ control_loops::ClawQueue::Position last_position_;
};
@@ -246,7 +246,7 @@
// Create a new instance of the test queue so that it invalidates the queue
// that it points to. Otherwise, we will have a pointer to shared memory that
// is no longer valid.
- ClawGroup claw_queue_group;
+ ClawQueue claw_queue;
// Create a loop and simulation plant.
ClawMotor claw_motor_;
@@ -257,30 +257,29 @@
double min_separation_;
ClawTest()
- : claw_queue_group(".frc971.control_loops.claw_queue_group", 0x9f1a99dd,
- ".frc971.control_loops.claw_queue_group.goal",
- ".frc971.control_loops.claw_queue_group.position",
- ".frc971.control_loops.claw_queue_group.output",
- ".frc971.control_loops.claw_queue_group.status"),
- claw_motor_(&claw_queue_group),
+ : claw_queue(".frc971.control_loops.claw_queue", 0x9f1a99dd,
+ ".frc971.control_loops.claw_queue.goal",
+ ".frc971.control_loops.claw_queue.position",
+ ".frc971.control_loops.claw_queue.output",
+ ".frc971.control_loops.claw_queue.status"),
+ claw_motor_(&claw_queue),
claw_motor_plant_(0.4, 0.2),
- min_separation_(constants::GetValues().claw.claw_min_separation) {
- }
+ min_separation_(constants::GetValues().claw.claw_min_separation) {}
void VerifyNearGoal() {
- claw_queue_group.goal.FetchLatest();
- claw_queue_group.position.FetchLatest();
+ claw_queue.goal.FetchLatest();
+ claw_queue.position.FetchLatest();
double bottom = claw_motor_plant_.GetAbsolutePosition(BOTTOM_CLAW);
double separation =
claw_motor_plant_.GetAbsolutePosition(TOP_CLAW) - bottom;
- EXPECT_NEAR(claw_queue_group.goal->bottom_angle, bottom, 1e-4);
- EXPECT_NEAR(claw_queue_group.goal->separation_angle, separation, 1e-4);
+ EXPECT_NEAR(claw_queue.goal->bottom_angle, bottom, 1e-4);
+ EXPECT_NEAR(claw_queue.goal->separation_angle, separation, 1e-4);
EXPECT_LE(min_separation_, separation);
}
};
TEST_F(ClawTest, HandlesNAN) {
- claw_queue_group.goal.MakeWithBuilder()
+ claw_queue.goal.MakeWithBuilder()
.bottom_angle(::std::nan(""))
.separation_angle(::std::nan(""))
.Send();
@@ -294,7 +293,7 @@
// Tests that the wrist zeros correctly and goes to a position.
TEST_F(ClawTest, ZerosCorrectly) {
- claw_queue_group.goal.MakeWithBuilder()
+ claw_queue.goal.MakeWithBuilder()
.bottom_angle(0.1)
.separation_angle(0.2)
.Send();
@@ -392,7 +391,7 @@
TEST_P(ZeroingClawTest, ParameterizedZero) {
claw_motor_plant_.Reinitialize(GetParam().first, GetParam().second);
- claw_queue_group.goal.MakeWithBuilder()
+ claw_queue.goal.MakeWithBuilder()
.bottom_angle(0.1)
.separation_angle(0.2)
.Send();
@@ -410,7 +409,7 @@
TEST_P(ZeroingClawTest, HandleMissingPosition) {
claw_motor_plant_.Reinitialize(GetParam().first, GetParam().second);
- claw_queue_group.goal.MakeWithBuilder()
+ claw_queue.goal.MakeWithBuilder()
.bottom_angle(0.1)
.separation_angle(0.2)
.Send();
@@ -453,7 +452,7 @@
/*
// Tests that loosing the encoder for a second triggers a re-zero.
TEST_F(ClawTest, RezeroWithMissingPos) {
- claw_queue_group.goal.MakeWithBuilder()
+ claw_queue.goal.MakeWithBuilder()
.bottom_angle(0.1)
.separation_angle(0.2)
.Send();
@@ -468,7 +467,7 @@
// Should be re-zeroing now.
EXPECT_TRUE(claw_motor_.is_uninitialized());
}
- claw_queue_group.goal.MakeWithBuilder()
+ claw_queue.goal.MakeWithBuilder()
.bottom_angle(0.2)
.separation_angle(0.2)
.Send();
@@ -490,7 +489,7 @@
// Tests that disabling while zeroing sends the state machine into the
// uninitialized state.
TEST_F(ClawTest, DisableGoesUninitialized) {
- claw_queue_group.goal.MakeWithBuilder()
+ claw_queue.goal.MakeWithBuilder()
.bottom_angle(0.1)
.separation_angle(0.2)
.Send();
@@ -504,9 +503,9 @@
// it is in the correct state.
EXPECT_TRUE(claw_motor_.is_uninitialized());
// When disabled, we should be applying 0 power.
- EXPECT_TRUE(claw_queue_group.output.FetchLatest());
- EXPECT_EQ(0, claw_queue_group.output->top_claw_voltage);
- EXPECT_EQ(0, claw_queue_group.output->bottom_claw_voltage);
+ EXPECT_TRUE(claw_queue.output.FetchLatest());
+ EXPECT_EQ(0, claw_queue.output->top_claw_voltage);
+ EXPECT_EQ(0, claw_queue.output->bottom_claw_voltage);
}
} else {
SimulateTimestep(true);
@@ -588,7 +587,7 @@
// Tests that the wrist can't get too far away from the zeroing position if the
// zeroing position is saturating the goal.
TEST_F(WindupClawTest, NoWindupPositive) {
- claw_queue_group.goal.MakeWithBuilder()
+ claw_queue.goal.MakeWithBuilder()
.bottom_angle(0.1)
.separation_angle(0.2)
.Send();
@@ -601,7 +600,7 @@
// Tests that the wrist can't get too far away from the zeroing position if the
// zeroing position is saturating the goal.
TEST_F(WindupClawTest, NoWindupNegative) {
- claw_queue_group.goal.MakeWithBuilder()
+ claw_queue.goal.MakeWithBuilder()
.bottom_angle(0.1)
.separation_angle(0.2)
.Send();
@@ -614,7 +613,7 @@
// Tests that the wrist can't get too far away from the zeroing position if the
// zeroing position is saturating the goal.
TEST_F(WindupClawTest, NoWindupNegativeFineTune) {
- claw_queue_group.goal.MakeWithBuilder()
+ claw_queue.goal.MakeWithBuilder()
.bottom_angle(0.1)
.separation_angle(0.2)
.Send();
diff --git a/y2014/control_loops/shooter/shooter.cc b/y2014/control_loops/shooter/shooter.cc
index 2a9f6e8..5211967 100644
--- a/y2014/control_loops/shooter/shooter.cc
+++ b/y2014/control_loops/shooter/shooter.cc
@@ -102,8 +102,8 @@
absolute_position(), previous_offset, offset_));
}
-ShooterMotor::ShooterMotor(control_loops::ShooterGroup *my_shooter)
- : aos::controls::ControlLoop<control_loops::ShooterGroup>(my_shooter),
+ShooterMotor::ShooterMotor(control_loops::ShooterQueue *my_shooter)
+ : aos::controls::ControlLoop<control_loops::ShooterQueue>(my_shooter),
shooter_(MakeShooterLoop()),
state_(STATE_INITIALIZE),
loading_problem_end_time_(0, 0),
@@ -153,7 +153,7 @@
}
void ShooterMotor::CheckCalibrations(
- const control_loops::ShooterGroup::Position *position) {
+ const control_loops::ShooterQueue::Position *position) {
CHECK_NOTNULL(position);
const frc971::constants::Values &values = constants::GetValues();
@@ -202,10 +202,10 @@
// Positive is out, and positive power is out.
void ShooterMotor::RunIteration(
- const control_loops::ShooterGroup::Goal *goal,
- const control_loops::ShooterGroup::Position *position,
- control_loops::ShooterGroup::Output *output,
- control_loops::ShooterGroup::Status *status) {
+ const control_loops::ShooterQueue::Goal *goal,
+ const control_loops::ShooterQueue::Position *position,
+ control_loops::ShooterQueue::Output *output,
+ control_loops::ShooterQueue::Status *status) {
constexpr double dt = 0.01;
if (goal && ::std::isnan(goal->shot_power)) {
diff --git a/y2014/control_loops/shooter/shooter.gyp b/y2014/control_loops/shooter/shooter.gyp
index 260fb11..e96b592 100644
--- a/y2014/control_loops/shooter/shooter.gyp
+++ b/y2014/control_loops/shooter/shooter.gyp
@@ -16,7 +16,7 @@
],
},
{
- 'target_name': 'shooter_loop',
+ 'target_name': 'shooter_queue',
'type': 'static_library',
'sources': ['shooter.q'],
'variables': {
@@ -41,14 +41,14 @@
'unaugmented_shooter_motor_plant.cc',
],
'dependencies': [
- 'shooter_loop',
+ 'shooter_queue',
'<(AOS)/common/controls/controls.gyp:control_loop',
'<(DEPTH)/y2014/y2014.gyp:constants',
'<(DEPTH)/frc971/control_loops/control_loops.gyp:state_feedback_loop',
'<(AOS)/common/logging/logging.gyp:queue_logging',
],
'export_dependent_settings': [
- 'shooter_loop',
+ 'shooter_queue',
'<(AOS)/common/controls/controls.gyp:control_loop',
'<(DEPTH)/frc971/control_loops/control_loops.gyp:state_feedback_loop',
],
@@ -61,7 +61,7 @@
],
'dependencies': [
'<(EXTERNALS):gtest',
- 'shooter_loop',
+ 'shooter_queue',
'shooter_lib',
'<(AOS)/common/controls/controls.gyp:control_loop_test',
'<(DEPTH)/frc971/control_loops/control_loops.gyp:state_feedback_loop',
diff --git a/y2014/control_loops/shooter/shooter.h b/y2014/control_loops/shooter/shooter.h
index 1339f6b..71347cb 100644
--- a/y2014/control_loops/shooter/shooter.h
+++ b/y2014/control_loops/shooter/shooter.h
@@ -121,17 +121,17 @@
const Time kPrepareFireEndTime = Time::InMS(40);
class ShooterMotor
- : public aos::controls::ControlLoop<control_loops::ShooterGroup> {
+ : public aos::controls::ControlLoop<control_loops::ShooterQueue> {
public:
- explicit ShooterMotor(control_loops::ShooterGroup *my_shooter =
- &control_loops::shooter_queue_group);
+ explicit ShooterMotor(control_loops::ShooterQueue *my_shooter =
+ &control_loops::shooter_queue);
// True if the goal was moved to avoid goal windup.
bool capped_goal() const { return shooter_.capped_goal(); }
double PowerToPosition(double power);
double PositionToPower(double position);
- void CheckCalibrations(const control_loops::ShooterGroup::Position *position);
+ void CheckCalibrations(const control_loops::ShooterQueue::Position *position);
typedef enum {
STATE_INITIALIZE = 0,
@@ -152,9 +152,9 @@
protected:
virtual void RunIteration(
- const ShooterGroup::Goal *goal,
- const control_loops::ShooterGroup::Position *position,
- ShooterGroup::Output *output, ShooterGroup::Status *status);
+ const ShooterQueue::Goal *goal,
+ const control_loops::ShooterQueue::Position *position,
+ ShooterQueue::Output *output, ShooterQueue::Status *status);
private:
// We have to override this to keep the pistons in the correct positions.
@@ -176,7 +176,7 @@
load_timeout_ = Time::Now() + kLoadTimeout;
}
- control_loops::ShooterGroup::Position last_position_;
+ control_loops::ShooterQueue::Position last_position_;
ZeroedStateFeedbackLoop shooter_;
diff --git a/y2014/control_loops/shooter/shooter.q b/y2014/control_loops/shooter/shooter.q
index bc83ff7..009e20e 100644
--- a/y2014/control_loops/shooter/shooter.q
+++ b/y2014/control_loops/shooter/shooter.q
@@ -3,7 +3,7 @@
import "aos/common/controls/control_loops.q";
import "frc971/control_loops/control_loops.q";
-queue_group ShooterGroup {
+queue_group ShooterQueue {
implements aos.control_loops.ControlLoop;
message Output {
@@ -57,7 +57,7 @@
queue Status status;
};
-queue_group ShooterGroup shooter_queue_group;
+queue_group ShooterQueue shooter_queue;
struct ShooterStateToLog {
double absolute_position;
diff --git a/y2014/control_loops/shooter/shooter_lib_test.cc b/y2014/control_loops/shooter/shooter_lib_test.cc
index a65e56f..2beb705 100644
--- a/y2014/control_loops/shooter/shooter_lib_test.cc
+++ b/y2014/control_loops/shooter/shooter_lib_test.cc
@@ -40,12 +40,12 @@
plunger_latched_(false),
brake_piston_state_(true),
brake_delay_count_(0),
- shooter_queue_group_(
- ".frc971.control_loops.shooter_queue_group", 0xcbf22ba9,
- ".frc971.control_loops.shooter_queue_group.goal",
- ".frc971.control_loops.shooter_queue_group.position",
- ".frc971.control_loops.shooter_queue_group.output",
- ".frc971.control_loops.shooter_queue_group.status") {
+ shooter_queue_(
+ ".frc971.control_loops.shooter_queue", 0xcbf22ba9,
+ ".frc971.control_loops.shooter_queue.goal",
+ ".frc971.control_loops.shooter_queue.position",
+ ".frc971.control_loops.shooter_queue.output",
+ ".frc971.control_loops.shooter_queue.status") {
Reinitialize(initial_position);
}
@@ -82,7 +82,7 @@
// Sets the values of the physical sensors that can be directly observed
// (encoder, hall effect).
- void SetPhysicalSensors(control_loops::ShooterGroup::Position *position) {
+ void SetPhysicalSensors(control_loops::ShooterQueue::Position *position) {
const frc971::constants::Values &values = constants::GetValues();
position->position = GetPosition();
@@ -115,7 +115,7 @@
PosedgeOnlyCountedHallEffectStruct *sensor,
const PosedgeOnlyCountedHallEffectStruct &last_sensor,
const constants::Values::AnglePair &limits,
- const control_loops::ShooterGroup::Position &last_position) {
+ const control_loops::ShooterQueue::Position &last_position) {
sensor->posedge_count = last_sensor.posedge_count;
sensor->negedge_count = last_sensor.negedge_count;
@@ -150,8 +150,8 @@
void SendPositionMessage(bool use_passed, bool plunger_in,
bool latch_in, bool brake_in) {
const frc971::constants::Values &values = constants::GetValues();
- ::aos::ScopedMessagePtr<control_loops::ShooterGroup::Position> position =
- shooter_queue_group_.position.MakeMessage();
+ ::aos::ScopedMessagePtr<control_loops::ShooterQueue::Position> position =
+ shooter_queue_.position.MakeMessage();
if (use_passed) {
plunger_latched_ = latch_in && plunger_in;
@@ -180,22 +180,22 @@
// Simulates the claw moving for one timestep.
void Simulate() {
last_plant_position_ = GetAbsolutePosition();
- EXPECT_TRUE(shooter_queue_group_.output.FetchLatest());
- if (shooter_queue_group_.output->latch_piston && !latch_piston_state_ &&
+ EXPECT_TRUE(shooter_queue_.output.FetchLatest());
+ if (shooter_queue_.output->latch_piston && !latch_piston_state_ &&
latch_delay_count_ <= 0) {
ASSERT_EQ(0, latch_delay_count_) << "The test doesn't support that.";
latch_delay_count_ = 6;
- } else if (!shooter_queue_group_.output->latch_piston &&
+ } else if (!shooter_queue_.output->latch_piston &&
latch_piston_state_ && latch_delay_count_ >= 0) {
ASSERT_EQ(0, latch_delay_count_) << "The test doesn't support that.";
latch_delay_count_ = -6;
}
- if (shooter_queue_group_.output->brake_piston && !brake_piston_state_ &&
+ if (shooter_queue_.output->brake_piston && !brake_piston_state_ &&
brake_delay_count_ <= 0) {
ASSERT_EQ(0, brake_delay_count_) << "The test doesn't support that.";
brake_delay_count_ = 5;
- } else if (!shooter_queue_group_.output->brake_piston &&
+ } else if (!shooter_queue_.output->brake_piston &&
brake_piston_state_ && brake_delay_count_ >= 0) {
ASSERT_EQ(0, brake_delay_count_) << "The test doesn't support that.";
brake_delay_count_ = -5;
@@ -221,7 +221,7 @@
shooter_plant_->D() * shooter_plant_->U();
} else {
shooter_plant_->mutable_U() << last_voltage_;
- //shooter_plant_->U << shooter_queue_group_.output->voltage;
+ //shooter_plant_->U << shooter_queue_.output->voltage;
shooter_plant_->Update();
}
LOG(DEBUG, "Plant index is %d\n", shooter_plant_->plant_index());
@@ -258,7 +258,7 @@
EXPECT_LE(constants::GetValues().shooter.lower_hard_limit,
GetAbsolutePosition());
- last_voltage_ = shooter_queue_group_.output->voltage;
+ last_voltage_ = shooter_queue_.output->voltage;
::aos::time::Time::IncrementMockTime(::aos::time::Time::InMS(10.0));
}
@@ -279,11 +279,11 @@
int brake_delay_count_;
private:
- ShooterGroup shooter_queue_group_;
+ ShooterQueue shooter_queue_;
double initial_position_;
double last_voltage_;
- control_loops::ShooterGroup::Position last_position_message_;
+ control_loops::ShooterQueue::Position last_position_message_;
double last_plant_position_;
};
@@ -293,7 +293,7 @@
// Create a new instance of the test queue so that it invalidates the queue
// that it points to. Otherwise, we will have a pointer to shared memory that
// is no longer valid.
- ShooterGroup shooter_queue_group_;
+ ShooterQueue shooter_queue_;
// Create a loop and simulation plant.
ShooterMotor shooter_motor_;
@@ -304,21 +304,21 @@
}
ShooterTest()
- : shooter_queue_group_(
- ".frc971.control_loops.shooter_queue_group", 0xcbf22ba9,
- ".frc971.control_loops.shooter_queue_group.goal",
- ".frc971.control_loops.shooter_queue_group.position",
- ".frc971.control_loops.shooter_queue_group.output",
- ".frc971.control_loops.shooter_queue_group.status"),
- shooter_motor_(&shooter_queue_group_),
+ : shooter_queue_(
+ ".frc971.control_loops.shooter_queue", 0xcbf22ba9,
+ ".frc971.control_loops.shooter_queue.goal",
+ ".frc971.control_loops.shooter_queue.position",
+ ".frc971.control_loops.shooter_queue.output",
+ ".frc971.control_loops.shooter_queue.status"),
+ shooter_motor_(&shooter_queue_),
shooter_motor_plant_(0.2) {
}
void VerifyNearGoal() {
- shooter_queue_group_.goal.FetchLatest();
- shooter_queue_group_.position.FetchLatest();
+ shooter_queue_.goal.FetchLatest();
+ shooter_queue_.position.FetchLatest();
double pos = shooter_motor_plant_.GetAbsolutePosition();
- EXPECT_NEAR(shooter_queue_group_.goal->shot_power, pos, 1e-4);
+ EXPECT_NEAR(shooter_queue_.goal->shot_power, pos, 1e-4);
}
};
@@ -355,7 +355,7 @@
// Tests that the shooter zeros correctly and goes to a position.
TEST_F(ShooterTest, GoesToValue) {
- shooter_queue_group_.goal.MakeWithBuilder().shot_power(70.0).Send();
+ shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
for (int i = 0; i < 200; ++i) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
@@ -365,14 +365,14 @@
// EXPECT_NEAR(0.0, shooter_motor_.GetPosition(), 0.01);
double pos = shooter_motor_plant_.GetAbsolutePosition();
EXPECT_NEAR(
- shooter_motor_.PowerToPosition(shooter_queue_group_.goal->shot_power),
+ shooter_motor_.PowerToPosition(shooter_queue_.goal->shot_power),
pos, 0.05);
EXPECT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
}
// Tests that the shooter zeros correctly and goes to a position.
TEST_F(ShooterTest, Fire) {
- shooter_queue_group_.goal.MakeWithBuilder().shot_power(70.0).Send();
+ shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
for (int i = 0; i < 120; ++i) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
@@ -380,7 +380,7 @@
SimulateTimestep(true);
}
EXPECT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
- shooter_queue_group_.goal.MakeWithBuilder()
+ shooter_queue_.goal.MakeWithBuilder()
.shot_power(35.0)
.shot_requested(true)
.Send();
@@ -393,7 +393,7 @@
SimulateTimestep(true);
if (shooter_motor_.state() == ShooterMotor::STATE_FIRE) {
if (!hit_fire) {
- shooter_queue_group_.goal.MakeWithBuilder()
+ shooter_queue_.goal.MakeWithBuilder()
.shot_power(17.0)
.shot_requested(false)
.Send();
@@ -404,7 +404,7 @@
double pos = shooter_motor_plant_.GetAbsolutePosition();
EXPECT_NEAR(
- shooter_motor_.PowerToPosition(shooter_queue_group_.goal->shot_power),
+ shooter_motor_.PowerToPosition(shooter_queue_.goal->shot_power),
pos, 0.05);
EXPECT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
EXPECT_TRUE(hit_fire);
@@ -412,7 +412,7 @@
// Tests that the shooter zeros correctly and goes to a position.
TEST_F(ShooterTest, FireLong) {
- shooter_queue_group_.goal.MakeWithBuilder().shot_power(70.0).Send();
+ shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
for (int i = 0; i < 150; ++i) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
@@ -420,7 +420,7 @@
SimulateTimestep(true);
}
EXPECT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
- shooter_queue_group_.goal.MakeWithBuilder().shot_requested(true).Send();
+ shooter_queue_.goal.MakeWithBuilder().shot_requested(true).Send();
bool hit_fire = false;
for (int i = 0; i < 400; ++i) {
@@ -430,7 +430,7 @@
SimulateTimestep(true);
if (shooter_motor_.state() == ShooterMotor::STATE_FIRE) {
if (!hit_fire) {
- shooter_queue_group_.goal.MakeWithBuilder()
+ shooter_queue_.goal.MakeWithBuilder()
.shot_requested(false)
.Send();
}
@@ -439,7 +439,7 @@
}
double pos = shooter_motor_plant_.GetAbsolutePosition();
- EXPECT_NEAR(shooter_motor_.PowerToPosition(shooter_queue_group_.goal->shot_power), pos, 0.05);
+ EXPECT_NEAR(shooter_motor_.PowerToPosition(shooter_queue_.goal->shot_power), pos, 0.05);
EXPECT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
EXPECT_TRUE(hit_fire);
}
@@ -447,7 +447,7 @@
// Verifies that it doesn't try to go out too far if you give it a ridicilous
// power.
TEST_F(ShooterTest, LoadTooFar) {
- shooter_queue_group_.goal.MakeWithBuilder().shot_power(500.0).Send();
+ shooter_queue_.goal.MakeWithBuilder().shot_power(500.0).Send();
for (int i = 0; i < 160; ++i) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
@@ -462,7 +462,7 @@
// Tests that the shooter zeros correctly and goes to a position.
TEST_F(ShooterTest, MoveGoal) {
- shooter_queue_group_.goal.MakeWithBuilder().shot_power(70.0).Send();
+ shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
for (int i = 0; i < 150; ++i) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
@@ -470,7 +470,7 @@
SimulateTimestep(true);
}
EXPECT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
- shooter_queue_group_.goal.MakeWithBuilder().shot_power(14.0).Send();
+ shooter_queue_.goal.MakeWithBuilder().shot_power(14.0).Send();
for (int i = 0; i < 100; ++i) {
shooter_motor_plant_.SendPositionMessage();
@@ -481,14 +481,14 @@
double pos = shooter_motor_plant_.GetAbsolutePosition();
EXPECT_NEAR(
- shooter_motor_.PowerToPosition(shooter_queue_group_.goal->shot_power),
+ shooter_motor_.PowerToPosition(shooter_queue_.goal->shot_power),
pos, 0.05);
EXPECT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
}
TEST_F(ShooterTest, Unload) {
- shooter_queue_group_.goal.MakeWithBuilder().shot_power(70.0).Send();
+ shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
for (int i = 0; i < 150; ++i) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
@@ -496,7 +496,7 @@
SimulateTimestep(true);
}
EXPECT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
- shooter_queue_group_.goal.MakeWithBuilder().unload_requested(true).Send();
+ shooter_queue_.goal.MakeWithBuilder().unload_requested(true).Send();
for (int i = 0;
i < 800 && shooter_motor_.state() != ShooterMotor::STATE_READY_UNLOAD;
@@ -514,7 +514,7 @@
// Tests that it rezeros while unloading.
TEST_F(ShooterTest, RezeroWhileUnloading) {
- shooter_queue_group_.goal.MakeWithBuilder().shot_power(70.0).Send();
+ shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
for (int i = 0; i < 150; ++i) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
@@ -531,7 +531,7 @@
SimulateTimestep(true);
}
- shooter_queue_group_.goal.MakeWithBuilder().unload_requested(true).Send();
+ shooter_queue_.goal.MakeWithBuilder().unload_requested(true).Send();
for (int i = 0;
i < 800 && shooter_motor_.state() != ShooterMotor::STATE_READY_UNLOAD;
@@ -549,7 +549,7 @@
// Tests that the shooter zeros correctly and goes to a position.
TEST_F(ShooterTest, UnloadWindupNegative) {
- shooter_queue_group_.goal.MakeWithBuilder().shot_power(70.0).Send();
+ shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
for (int i = 0; i < 150; ++i) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
@@ -557,7 +557,7 @@
SimulateTimestep(true);
}
EXPECT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
- shooter_queue_group_.goal.MakeWithBuilder().unload_requested(true).Send();
+ shooter_queue_.goal.MakeWithBuilder().unload_requested(true).Send();
int kicked_delay = 20;
int capped_goal_count = 0;
@@ -589,7 +589,7 @@
// Tests that the shooter zeros correctly and goes to a position.
TEST_F(ShooterTest, UnloadWindupPositive) {
- shooter_queue_group_.goal.MakeWithBuilder().shot_power(70.0).Send();
+ shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
for (int i = 0; i < 150; ++i) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
@@ -597,7 +597,7 @@
SimulateTimestep(true);
}
EXPECT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
- shooter_queue_group_.goal.MakeWithBuilder().unload_requested(true).Send();
+ shooter_queue_.goal.MakeWithBuilder().unload_requested(true).Send();
int kicked_delay = 20;
int capped_goal_count = 0;
@@ -634,7 +634,7 @@
// Tests that the shooter zeros correctly and goes to a position.
TEST_F(ShooterTest, StartsOnDistal) {
Reinitialize(HallEffectMiddle(constants::GetValues().shooter.pusher_distal));
- shooter_queue_group_.goal.MakeWithBuilder().shot_power(70.0).Send();
+ shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
for (int i = 0; i < 200; ++i) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
@@ -644,7 +644,7 @@
// EXPECT_NEAR(0.0, shooter_motor_.GetPosition(), 0.01);
double pos = shooter_motor_plant_.GetAbsolutePosition();
EXPECT_NEAR(
- shooter_motor_.PowerToPosition(shooter_queue_group_.goal->shot_power),
+ shooter_motor_.PowerToPosition(shooter_queue_.goal->shot_power),
pos, 0.05);
EXPECT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
}
@@ -654,7 +654,7 @@
TEST_F(ShooterTest, StartsOnProximal) {
Reinitialize(
HallEffectMiddle(constants::GetValues().shooter.pusher_proximal));
- shooter_queue_group_.goal.MakeWithBuilder().shot_power(70.0).Send();
+ shooter_queue_.goal.MakeWithBuilder().shot_power(70.0).Send();
for (int i = 0; i < 300; ++i) {
shooter_motor_plant_.SendPositionMessage();
shooter_motor_.Iterate();
@@ -664,7 +664,7 @@
// EXPECT_NEAR(0.0, shooter_motor_.GetPosition(), 0.01);
double pos = shooter_motor_plant_.GetAbsolutePosition();
EXPECT_NEAR(
- shooter_motor_.PowerToPosition(shooter_queue_group_.goal->shot_power),
+ shooter_motor_.PowerToPosition(shooter_queue_.goal->shot_power),
pos, 0.05);
EXPECT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
}
@@ -683,7 +683,7 @@
// latch, brake, plunger_back, start_pos);
bool initialized = false;
Reinitialize(start_pos);
- shooter_queue_group_.goal.MakeWithBuilder().shot_power(120.0).Send();
+ shooter_queue_.goal.MakeWithBuilder().shot_power(120.0).Send();
for (int i = 0; i < 200; ++i) {
shooter_motor_plant_.SendPositionMessage(!initialized, plunger_back, latch, brake);
initialized = true;
@@ -694,7 +694,7 @@
// EXPECT_NEAR(0.0, shooter_motor_.GetPosition(), 0.01);
double pos = shooter_motor_plant_.GetAbsolutePosition();
EXPECT_NEAR(
- shooter_motor_.PowerToPosition(shooter_queue_group_.goal->shot_power),
+ shooter_motor_.PowerToPosition(shooter_queue_.goal->shot_power),
pos, 0.05);
ASSERT_EQ(ShooterMotor::STATE_READY, shooter_motor_.state());
}
diff --git a/y2014/wpilib/wpilib_interface.cc b/y2014/wpilib/wpilib_interface.cc
index f47bad3..776b681 100644
--- a/y2014/wpilib/wpilib_interface.cc
+++ b/y2014/wpilib/wpilib_interface.cc
@@ -573,11 +573,11 @@
private:
virtual void Read() override {
- ::frc971::control_loops::shooter_queue_group.output.FetchAnother();
+ ::frc971::control_loops::shooter_queue.output.FetchAnother();
}
virtual void Write() override {
- auto &queue = ::frc971::control_loops::shooter_queue_group.output;
+ auto &queue = ::frc971::control_loops::shooter_queue.output;
LOG_STRUCT(DEBUG, "will output", *queue);
shooter_talon_->Set(queue->voltage / 12.0);
}
@@ -618,11 +618,11 @@
private:
virtual void Read() override {
- ::frc971::control_loops::claw_queue_group.output.FetchAnother();
+ ::frc971::control_loops::claw_queue.output.FetchAnother();
}
virtual void Write() override {
- auto &queue = ::frc971::control_loops::claw_queue_group.output;
+ auto &queue = ::frc971::control_loops::claw_queue.output;
LOG_STRUCT(DEBUG, "will output", *queue);
intake1_talon_->Set(queue->intake_voltage / 12.0);
intake2_talon_->Set(queue->intake_voltage / 12.0);