mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-22 14:19:57 +08:00
test(rover): add unit tests for the rover control helpers (#29836)
* test(rover): add unit tests for the rover control helpers throttleControl, attitudeControl, speedControl, rateControl and globalToLocalSetpointTriplet drive all three rover modules but had no tests. rateControl was also the only helper without an input check, so a NaN yaw rate reached the PID; it now returns NaN like the others. Assisted-by: Claude:claude-opus-5-5 * test(rover): split rover control tests into single given/when/then cases Review feedback: tests that set up a scenario should read as given/when/then, and tests covering several cases should be split so each failure points at one case. Assisted-by: Claude:claude-opus-5-5 * test(rover): check that NaN inputs leave the controller state untouched Most NaN cases propagate to a NaN output even without the input check, so asserting only on the output didn't test the check. Starting from a known adjusted setpoint and asserting it is unchanged does. Also name the rateControl clamp tests by sign, since in NED a positive yaw rate turns right, and use speed_diff_normalized like the callers do. Assisted-by: Claude:claude-opus-5-5 * style(rover): re-indent rateControl test continuation lines for astyle Assisted-by: Claude:claude-opus-5-5 * test(rover): apply given/when/then to the existing rover control tests Review feedback: use the same scheme for the tests that were already in the file, so every test checks one case. Assisted-by: Claude:claude-opus-5-5 --------- Co-authored-by: Vishal Kotak <22182951+vishalkotak@users.noreply.github.com>
This commit is contained in:
1 parent
e01c2dd44e
commit
16b1d820c8
2 files changed
+1073
-144
No files matched your search
@@ -203,6 +203,11 @@ float rateControl(SlewRate<float> &adjusted_yaw_rate_setpoint, PID &pid_yaw_rate
|
||||
const float max_yaw_decel,
|
||||
const float wheel_track, const float dt)
|
||||
{
|
||||
// Sanitize inputs
|
||||
if (!PX4_ISFINITE(yaw_rate_setpoint) || !PX4_ISFINITE(vehicle_yaw_rate) || !PX4_ISFINITE(dt)) {
|
||||
return NAN;
|
||||
}
|
||||
|
||||
// Apply acceleration and deceleration limit
|
||||
if (fabsf(yaw_rate_setpoint) >= fabsf(vehicle_yaw_rate) && max_yaw_accel > FLT_EPSILON) {
|
||||
adjusted_yaw_rate_setpoint.setSlewRate(max_yaw_accel);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user