Skip to main content

StateSource

Trait StateSource 

Source
pub trait StateSource {
    // Required method
    fn state(&mut self, dt: Duration) -> VehicleState;
}
Expand description

Where the flight loop’s vehicle state comes from.

The name describes the role, not how the state is obtained. Implementors include:

  • Simulator backends that report the simulator’s true state (e.g. RealFlightVehicle);
  • Test doubles that report a fixed state (testing::NullVehicle);
  • Estimators that fuse sensor readings into an estimate (IMU, baro, mag, GNSS).

Every implementor reports in the VehicleState frame contract.

Required Methods§

Source

fn state(&mut self, dt: Duration) -> VehicleState

Returns the current vehicle state.

Takes &mut self because sources typically advance internal state on each call (a filter’s predict/update, a simulator exchange’s bookkeeping).

§Parameters
  • dt: Time elapsed since the previous call. The first call, made once before the control loop starts, passes Duration::ZERO; implementations may use it to initialize (see RealFlightVehicle).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§