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