Skip to main content

Module conformance

Module conformance 

Source
Expand description

Frame-conformance kit for state sources: simulator backends and estimators.

Every simulator or sensor stack reports state in its own frames and units; a StateSource converts to the VehicleState frame contract at its boundary. This module is a table of physical Scenarios with the state each must produce. A backend’s tests build the simulator’s native report for each scenario (a mock-client fixture), run it through the backend, and Scenario::check the result. That catches a swapped axis, a flipped sign, a wrong rotation order, or a unit slip before the backend flies.

conformance_tests! generates one test per scenario and a test that fails when a scenario has none, so new scenarios reach every backend.

§Examples

use stable_flight::testing::conformance::{LEVEL, ROLL_RIGHT_30, SCENARIOS};

// A backend that got the frames right produces the scenario's expected state.
for scenario in SCENARIOS {
    assert!(scenario.check(&scenario.expected_state()).is_ok());
}

// Level flight is not a 30° right bank.
let error = ROLL_RIGHT_30.check(&LEVEL.expected_state()).unwrap_err();
assert_eq!(error.mismatches()[0].field, "roll_rad");

Structs§

ConformanceError
A backend’s state for a Scenario broke the frame contract.
Mismatch
One field of a ConformanceError.
Scenario
One physical situation and the VehicleState it must map to.

Constants§

ANGLE_TOLERANCE
Largest difference accepted for an angle (rad) or body rate (rad/s).
BANKED_CLIMB_EAST
Nose east, 10° up, banked 30° right. Distinct angles on every axis catch a wrong rotation order or swapped Euler angles.
CLIMBING
Level, climbing at 2 m/s and accelerating upward at 1 m/s².
COMBINED_RATES
Rolling right, pitching up, and yawing right at distinct rates, which catches swapped rate axes.
HEADING_EAST
Level, nose pointing east.
LEVEL
At rest, wings level, nose north.
LINEAR_TOLERANCE
Largest difference accepted for a position (m), velocity (m/s), or acceleration (m/s²).
MOVING_NORTHEAST
Northeast of the origin, flying northeast and speeding up. Distinct north and east values catch a swapped horizontal axis (e.g. ENU vs NED).
PITCH_UP_15
Nose 15° up.
ROLL_RIGHT_30
Banked 30° right (right wing down).
SCENARIOS
Every scenario; a backend covers each one (see conformance_tests!).
YAW_RIGHT_RATE
Level, yawing right (clockwise from above) at 30°/s.