Clean up and check constants.
Most of the changes are pretty minor. I got rid of some ugly stuff
and added real numbers for some things.
Change-Id: Iafb1a81323141fccc907f87b2da3f8118cb3d6ce
diff --git a/frc971/control_loops/claw/claw_lib_test.cc b/frc971/control_loops/claw/claw_lib_test.cc
index d671cfa..4f86697 100644
--- a/frc971/control_loops/claw/claw_lib_test.cc
+++ b/frc971/control_loops/claw/claw_lib_test.cc
@@ -26,8 +26,7 @@
// Constructs a claw simulation.
ClawSimulation()
: claw_plant_(new StateFeedbackPlant<2, 1, 1>(MakeClawPlant())),
- pot_and_encoder_(
- constants::GetValues().claw_zeroing_constants.index_difference),
+ pot_and_encoder_(constants::GetValues().claw.zeroing.index_difference),
claw_queue_(".frc971.control_loops.claw_queue", 0x9d7452fb,
".frc971.control_loops.claw_queue.goal",
".frc971.control_loops.claw_queue.position",
@@ -35,7 +34,7 @@
".frc971.control_loops.claw_queue.status") {
pot_and_encoder_.Initialize(
constants::GetValues().claw.wrist.lower_limit,
- constants::GetValues().claw_zeroing_constants.index_difference / 3.0);
+ constants::GetValues().claw.zeroing.index_difference / 3.0);
}
// Do specific initialization for the sensors.
@@ -164,7 +163,7 @@
// Lower limit.
ASSERT_TRUE(claw_queue_.goal.MakeWithBuilder()
- .angle(values.claw.wrist.lower_hard_limit + 5.0)
+ .angle(values.claw.wrist.lower_hard_limit - 5.0)
.Send());
RunForTime(Time::InMS(4000));
diff --git a/frc971/control_loops/fridge/fridge.cc b/frc971/control_loops/fridge/fridge.cc
index d2e7bbf..be6bb01 100644
--- a/frc971/control_loops/fridge/fridge.cc
+++ b/frc971/control_loops/fridge/fridge.cc
@@ -61,12 +61,12 @@
StateFeedbackLoop<4, 2, 2>(MakeArmLoop()))),
elevator_loop_(new CappedStateFeedbackLoop(
StateFeedbackLoop<4, 2, 2>(MakeElevatorLoop()))),
- left_arm_estimator_(constants::GetValues().left_arm_zeroing_constants),
- right_arm_estimator_(constants::GetValues().right_arm_zeroing_constants),
+ left_arm_estimator_(constants::GetValues().fridge.left_arm_zeroing),
+ right_arm_estimator_(constants::GetValues().fridge.right_arm_zeroing),
left_elevator_estimator_(
- constants::GetValues().left_elevator_zeroing_constants),
+ constants::GetValues().fridge.left_elev_zeroing),
right_elevator_estimator_(
- constants::GetValues().right_elevator_zeroing_constants) {}
+ constants::GetValues().fridge.right_elev_zeroing) {}
void Fridge::UpdateZeroingState() {
if (left_elevator_estimator_.offset_ratio_ready() < 0.5 ||
@@ -184,8 +184,8 @@
2.0;
const double pulse_width = ::std::max(
- constants::GetValues().left_elevator_zeroing_constants.index_difference,
- constants::GetValues().right_elevator_zeroing_constants.index_difference);
+ constants::GetValues().fridge.left_elev_zeroing.index_difference,
+ constants::GetValues().fridge.right_elev_zeroing.index_difference);
if (elevator_zeroing_velocity_ == 0) {
if (estimated_elevator() > average_elevator) {
@@ -208,8 +208,8 @@
constants::GetValues().fridge.arm.upper_limit) /
2.0;
const double pulse_width = ::std::max(
- constants::GetValues().right_arm_zeroing_constants.index_difference,
- constants::GetValues().left_arm_zeroing_constants.index_difference);
+ constants::GetValues().fridge.right_arm_zeroing.index_difference,
+ constants::GetValues().fridge.left_arm_zeroing.index_difference);
if (arm_zeroing_velocity_ == 0) {
if (estimated_arm() > average_arm) {
diff --git a/frc971/control_loops/fridge/fridge_lib_test.cc b/frc971/control_loops/fridge/fridge_lib_test.cc
index 2bc3d02..5c41e98 100644
--- a/frc971/control_loops/fridge/fridge_lib_test.cc
+++ b/frc971/control_loops/fridge/fridge_lib_test.cc
@@ -28,16 +28,13 @@
: arm_plant_(new StateFeedbackPlant<4, 2, 2>(MakeArmPlant())),
elev_plant_(new StateFeedbackPlant<4, 2, 2>(MakeElevatorPlant())),
left_arm_pot_encoder_(
- constants::GetValues().left_arm_zeroing_constants.index_difference),
+ constants::GetValues().fridge.left_arm_zeroing.index_difference),
right_arm_pot_encoder_(
- constants::GetValues()
- .right_arm_zeroing_constants.index_difference),
+ constants::GetValues().fridge.right_arm_zeroing.index_difference),
left_elev_pot_encoder_(
- constants::GetValues()
- .left_elevator_zeroing_constants.index_difference),
+ constants::GetValues().fridge.left_elev_zeroing.index_difference),
right_elev_pot_encoder_(
- constants::GetValues()
- .right_elevator_zeroing_constants.index_difference),
+ constants::GetValues().fridge.right_elev_zeroing.index_difference),
fridge_queue_(".frc971.control_loops.fridge_queue", 0xe4e05855,
".frc971.control_loops.fridge_queue.goal",
".frc971.control_loops.fridge_queue.position",
@@ -48,13 +45,12 @@
constants::GetValues().fridge.elevator.lower_limit,
constants::GetValues().fridge.elevator.lower_limit,
kNoiseScalar *
- constants::GetValues()
- .right_elevator_zeroing_constants.index_difference);
+ constants::GetValues().fridge.right_elev_zeroing.index_difference);
// Initialize the arm.
SetArmSensors(0.0, 0.0,
kNoiseScalar *
constants::GetValues()
- .right_arm_zeroing_constants.index_difference);
+ .fridge.right_arm_zeroing.index_difference);
}
void SetElevatorSensors(double left_start_pos, double right_start_pos,
@@ -123,8 +119,6 @@
}
void VerifySeparation() {
- // TODO(danielp): Make sure that we are getting the correct values from the
- // plant.
const double left_arm_angle = arm_plant_->Y(0, 0);
const double right_arm_angle = arm_plant_->Y(1, 0);
const double left_elev_height = elev_plant_->Y(0, 0);
@@ -235,7 +229,7 @@
// mechanisms.
TEST_F(FridgeTest, RespectsRange) {
// Put the arm up to get it out of the way.
- // We're going to send the elevator to zero, which should be significantly too
+ // We're going to send the elevator to -5, which should be significantly too
// low.
ASSERT_TRUE(fridge_queue_.goal.MakeWithBuilder()
.angle(M_PI)