Brian Silverman | a57b701 | 2020-03-11 20:19:23 -0700 | [diff] [blame^] | 1 | #include "frc971/zeroing/zeroing.h" |
| 2 | |
| 3 | #include "frc971/control_loops/control_loops_generated.h" |
| 4 | #include "frc971/control_loops/position_sensor_sim.h" |
| 5 | #include "gtest/gtest.h" |
| 6 | |
| 7 | namespace frc971 { |
| 8 | namespace zeroing { |
| 9 | namespace testing { |
| 10 | |
| 11 | using control_loops::PositionSensorSimulator; |
| 12 | using FBB = flatbuffers::FlatBufferBuilder; |
| 13 | |
| 14 | constexpr size_t kSampleSize = 30; |
| 15 | constexpr double kAcceptableUnzeroedError = 0.2; |
| 16 | constexpr double kIndexErrorFraction = 0.3; |
| 17 | constexpr size_t kMovingBufferSize = 3; |
| 18 | |
| 19 | class ZeroingTest : public ::testing::Test { |
| 20 | protected: |
| 21 | template <typename T> |
| 22 | double GetEstimatorPosition(T *estimator) { |
| 23 | FBB fbb; |
| 24 | fbb.Finish(estimator->GetEstimatorState(&fbb)); |
| 25 | return flatbuffers::GetRoot<typename T::State>(fbb.GetBufferPointer()) |
| 26 | ->position(); |
| 27 | } |
| 28 | }; |
| 29 | |
| 30 | } // namespace testing |
| 31 | } // namespace zeroing |
| 32 | } // namespace frc971 |