mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-08 14:30:35 +08:00
PositionControlTest: add integrator windup with invalid setpoint combination unit test
This bug was by chance found during simulation testing and debugging. The unit test is to easily reproduce and cover this case.
This commit is contained in:
@@ -399,3 +399,23 @@ TEST_F(PositionControlBasicTest, UpdateHoverThrust)
|
||||
// the output is still the same
|
||||
EXPECT_EQ(_output_setpoint.thrust[2], -hover_thrust);
|
||||
}
|
||||
|
||||
TEST_F(PositionControlBasicTest, IntegratorWindupWithInvalidSetpoint)
|
||||
{
|
||||
// GIVEN: the controller was ran with an invalid setpoint containing some valid values
|
||||
_input_setpoint.x = .1f;
|
||||
_input_setpoint.y = .2f;
|
||||
// all z-axis setpoints stay NAN
|
||||
EXPECT_FALSE(runController());
|
||||
|
||||
// WHEN: we run the controller with a valid setpoint
|
||||
resetInputSetpoint();
|
||||
_input_setpoint.vx = 0.f;
|
||||
_input_setpoint.vy = 0.f;
|
||||
_input_setpoint.vz = 0.f;
|
||||
EXPECT_TRUE(runController());
|
||||
|
||||
// THEN: the integral did not wind up and produce unexpected deviation
|
||||
EXPECT_FLOAT_EQ(_attitude.roll_body, 0.f);
|
||||
EXPECT_FLOAT_EQ(_attitude.pitch_body, 0.f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user