[wpilib] Shorten differential drive simulation stability test (#2745)

If the model is unstable, it will almost always diverge within 10
seconds, and the results are rather dramatic. We're also reducing the
threshold to 100 meters because the drivetrain is moving in a small
circle. The translation norm is also used for this reason; the X
component alone regularly crosses zero since the drivetrain moves in a
circle.
This commit is contained in:
Tyler Veness
2020-09-27 09:31:29 -07:00
committed by GitHub
parent 451f67c63d
commit 1320691eb4
2 changed files with 8 additions and 4 deletions

View File

@@ -6,6 +6,7 @@
/*----------------------------------------------------------------------------*/
#include <units/current.h>
#include <units/math.h>
#include <units/moment_of_inertia.h>
#include "frc/controller/LinearPlantInversionFeedforward.h"
@@ -105,9 +106,11 @@ TEST(DifferentialDriveSim, ModelStability) {
sim.SetInputs(2_V, 4_V);
for (int i = 0; i < 10000; ++i) {
// 10 seconds should be enough time to verify stability
for (int i = 0; i < 500; ++i) {
sim.Update(20_ms);
}
EXPECT_TRUE(std::abs(sim.GetEstimatedPosition().X().to<double>()) < 10000);
EXPECT_LT(units::math::abs(sim.GetEstimatedPosition().Translation().Norm()),
100_m);
}