Remove position() member from zeroing estimators
It didn't return anything particularly useful, so it should not have
been used anywhere. Turns out it was only used in the test, so it was
pretty easy.
Change-Id: I3f81bd16a1a8e429c9748abd4e9dc9c7e0259dc5
diff --git a/frc971/zeroing/zeroing_test.cc b/frc971/zeroing/zeroing_test.cc
index 6373056..e5c6813 100644
--- a/frc971/zeroing/zeroing_test.cc
+++ b/frc971/zeroing/zeroing_test.cc
@@ -71,13 +71,13 @@
for (int i = 0; i < 300; i++) {
MoveTo(&sim, &estimator, 3.3 * index_diff);
}
- ASSERT_NEAR(3.3 * index_diff, estimator.position(),
+ ASSERT_NEAR(3.3 * index_diff, estimator.GetEstimatorState().position,
kAcceptableUnzeroedError * index_diff);
for (int i = 0; i < 300; i++) {
MoveTo(&sim, &estimator, 3.9 * index_diff);
}
- ASSERT_NEAR(3.9 * index_diff, estimator.position(),
+ ASSERT_NEAR(3.9 * index_diff, estimator.GetEstimatorState().position,
kAcceptableUnzeroedError * index_diff);
}
@@ -114,24 +114,25 @@
for (int i = 0; i < 300; i++) {
MoveTo(&sim, &estimator, 3.6);
}
- ASSERT_NEAR(3.6, estimator.position(), kAcceptableUnzeroedError * index_diff);
+ ASSERT_NEAR(3.6, estimator.GetEstimatorState().position,
+ kAcceptableUnzeroedError * index_diff);
// With a single index pulse the zeroing estimator should be able to lock
// onto the true value of the position.
MoveTo(&sim, &estimator, 4.01);
- ASSERT_NEAR(4.01, estimator.position(), 0.001);
+ ASSERT_NEAR(4.01, estimator.GetEstimatorState().position, 0.001);
MoveTo(&sim, &estimator, 4.99);
- ASSERT_NEAR(4.99, estimator.position(), 0.001);
+ ASSERT_NEAR(4.99, estimator.GetEstimatorState().position, 0.001);
MoveTo(&sim, &estimator, 3.99);
- ASSERT_NEAR(3.99, estimator.position(), 0.001);
+ ASSERT_NEAR(3.99, estimator.GetEstimatorState().position, 0.001);
MoveTo(&sim, &estimator, 3.01);
- ASSERT_NEAR(3.01, estimator.position(), 0.001);
+ ASSERT_NEAR(3.01, estimator.GetEstimatorState().position, 0.001);
MoveTo(&sim, &estimator, 13.55);
- ASSERT_NEAR(13.55, estimator.position(), 0.001);
+ ASSERT_NEAR(13.55, estimator.GetEstimatorState().position, 0.001);
}
TEST_F(ZeroingTest, TestDifferentIndexDiffs) {
@@ -147,25 +148,25 @@
for (int i = 0; i < 300; i++) {
MoveTo(&sim, &estimator, 3.5 * index_diff);
}
- ASSERT_NEAR(3.5 * index_diff, estimator.position(),
+ ASSERT_NEAR(3.5 * index_diff, estimator.GetEstimatorState().position,
kAcceptableUnzeroedError * index_diff);
// With a single index pulse the zeroing estimator should be able to lock
// onto the true value of the position.
MoveTo(&sim, &estimator, 4.01);
- ASSERT_NEAR(4.01, estimator.position(), 0.001);
+ ASSERT_NEAR(4.01, estimator.GetEstimatorState().position, 0.001);
MoveTo(&sim, &estimator, 4.99);
- ASSERT_NEAR(4.99, estimator.position(), 0.001);
+ ASSERT_NEAR(4.99, estimator.GetEstimatorState().position, 0.001);
MoveTo(&sim, &estimator, 3.99);
- ASSERT_NEAR(3.99, estimator.position(), 0.001);
+ ASSERT_NEAR(3.99, estimator.GetEstimatorState().position, 0.001);
MoveTo(&sim, &estimator, 3.01);
- ASSERT_NEAR(3.01, estimator.position(), 0.001);
+ ASSERT_NEAR(3.01, estimator.GetEstimatorState().position, 0.001);
MoveTo(&sim, &estimator, 13.55);
- ASSERT_NEAR(13.55, estimator.position(), 0.001);
+ ASSERT_NEAR(13.55, estimator.GetEstimatorState().position, 0.001);
}
TEST_F(ZeroingTest, TestPercentage) {
@@ -258,12 +259,12 @@
MoveTo(&sim, &estimator, 3.7 * index_diff);
ASSERT_TRUE(estimator.zeroed());
ASSERT_DOUBLE_EQ(3.3 * index_diff, estimator.offset());
- ASSERT_DOUBLE_EQ(3.7 * index_diff, estimator.position());
+ ASSERT_DOUBLE_EQ(3.7 * index_diff, estimator.GetEstimatorState().position);
// Trigger one more index pulse and check the offset.
MoveTo(&sim, &estimator, 4.7 * index_diff);
ASSERT_DOUBLE_EQ(3.3 * index_diff, estimator.offset());
- ASSERT_DOUBLE_EQ(4.7 * index_diff, estimator.position());
+ ASSERT_DOUBLE_EQ(4.7 * index_diff, estimator.GetEstimatorState().position);
}
TEST_F(ZeroingTest, BasicErrorAPITest) {
@@ -439,10 +440,12 @@
ASSERT_TRUE(estimator.zeroed());
ASSERT_DOUBLE_EQ(start_pos, estimator.offset());
- ASSERT_DOUBLE_EQ(3.5 * constants.index_difference, estimator.position());
+ ASSERT_DOUBLE_EQ(3.5 * constants.index_difference,
+ estimator.GetEstimatorState().position);
MoveTo(&sim, &estimator, 0.5 * constants.index_difference);
- ASSERT_DOUBLE_EQ(0.5 * constants.index_difference, estimator.position());
+ ASSERT_DOUBLE_EQ(0.5 * constants.index_difference,
+ estimator.GetEstimatorState().position);
}
} // namespace zeroing