Use references to store constants::GetValues().
Most of the code already uses auto references so this should make it
consistent.
My very authoritative source of information regarding how auto works:
http://stackoverflow.com/questions/8542873/c11-auto-semantics
Change-Id: I0ca437c564a5f878e1c716fd858770bbdf821687
diff --git a/frc971/control_loops/claw/claw_lib_test.cc b/frc971/control_loops/claw/claw_lib_test.cc
index 49205d9..9c0553c 100644
--- a/frc971/control_loops/claw/claw_lib_test.cc
+++ b/frc971/control_loops/claw/claw_lib_test.cc
@@ -124,7 +124,7 @@
// Tests that the loop does nothing when the goal is our lower limit.
TEST_F(ClawTest, DoesNothing) {
- const auto values = constants::GetValues();
+ const auto &values = constants::GetValues();
ASSERT_TRUE(claw_queue_.goal.MakeWithBuilder()
.angle(values.claw.wrist.lower_limit)
.Send());
@@ -148,7 +148,7 @@
// Tests that it doesn't try to move past the physical range of the mechanism.
TEST_F(ClawTest, RespectsRange) {
- const auto values = constants::GetValues();
+ const auto &values = constants::GetValues();
// Upper limit
ASSERT_TRUE(claw_queue_.goal.MakeWithBuilder()
.angle(values.claw.wrist.upper_hard_limit + 5.0)
diff --git a/frc971/control_loops/fridge/fridge.cc b/frc971/control_loops/fridge/fridge.cc
index 65ee72e..8807baf 100644
--- a/frc971/control_loops/fridge/fridge.cc
+++ b/frc971/control_loops/fridge/fridge.cc
@@ -245,7 +245,7 @@
// Get a reference to the constants struct since we use it so often in this
// code.
- auto &values = constants::GetValues();
+ const auto &values = constants::GetValues();
// Bool to track if we should turn the motors on or not.
bool disable = output == nullptr;
diff --git a/frc971/control_loops/fridge/fridge_lib_test.cc b/frc971/control_loops/fridge/fridge_lib_test.cc
index 2af5e2c..657c07e 100644
--- a/frc971/control_loops/fridge/fridge_lib_test.cc
+++ b/frc971/control_loops/fridge/fridge_lib_test.cc
@@ -248,7 +248,7 @@
TEST_F(FridgeTest, DoesNothing) {
// Set the goals to the starting values. This should theoretically guarantee
// that the controller does nothing.
- const constants::Values values = constants::GetValues();
+ const auto &values = constants::GetValues();
ASSERT_TRUE(fridge_queue_.goal.MakeWithBuilder()
.angle(0.0)
.height(values.fridge.elevator.lower_limit)
@@ -263,7 +263,7 @@
// Tests that the loop can reach a goal.
TEST_F(FridgeTest, ReachesGoal) {
// Set a reasonable goal.
- const auto values = constants::GetValues();
+ const auto &values = constants::GetValues();
const double soft_limit = values.fridge.elevator.lower_limit;
ASSERT_TRUE(fridge_queue_.goal.MakeWithBuilder()
.angle(M_PI / 4.0)
@@ -291,7 +291,7 @@
// Check that we are near our soft limit.
fridge_queue_.status.FetchLatest();
- const auto values = constants::GetValues();
+ const auto &values = constants::GetValues();
EXPECT_NEAR(values.fridge.elevator.lower_limit, fridge_queue_.status->height,
0.001);
EXPECT_NEAR(values.fridge.arm.upper_limit, fridge_queue_.status->angle,
diff --git a/frc971/wpilib/wpilib_interface.cc b/frc971/wpilib/wpilib_interface.cc
index 1941144..c60feec 100644
--- a/frc971/wpilib/wpilib_interface.cc
+++ b/frc971/wpilib/wpilib_interface.cc
@@ -254,7 +254,7 @@
dma_synchronizer_->RunIteration();
- const auto values = constants::GetValues();
+ const auto &values = constants::GetValues();
{
auto fridge_message = fridge_queue.position.MakeMessage();