blob: 497f8331cc57681f64f7e1151a78dbd191d70099 [file] [log] [blame]
Philipp Schrader790cb542023-07-05 21:06:52 -07001#include "gtest/gtest.h"
Brian Silvermana57b7012020-03-11 20:19:23 -07002
3#include "frc971/control_loops/control_loops_generated.h"
4#include "frc971/control_loops/position_sensor_sim.h"
Philipp Schrader790cb542023-07-05 21:06:52 -07005#include "frc971/zeroing/zeroing.h"
Brian Silvermana57b7012020-03-11 20:19:23 -07006
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -08007namespace frc971::zeroing::testing {
Brian Silvermana57b7012020-03-11 20:19:23 -07008
9using control_loops::PositionSensorSimulator;
10using FBB = flatbuffers::FlatBufferBuilder;
11
12constexpr size_t kSampleSize = 30;
13constexpr double kAcceptableUnzeroedError = 0.2;
14constexpr double kIndexErrorFraction = 0.3;
15constexpr size_t kMovingBufferSize = 3;
16
17class 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 Pleinesd99b1ee2024-02-02 20:56:44 -080028} // namespace frc971::zeroing::testing