Skip to main content

Module state

Module state 

Source
Expand description

Navigation state: the estimator’s belief as one aggregate.

An estimator fuses fixes, headings and speeds into one belief — position, heading, speed through the water, current — with its uncertainty. NavigationState is a DDD aggregate: private fields, constructed only through invariant-checking constructors, exposed through the projection NavigationState::project.

Internally a six-element state vector and its covariance (StateComponent). The dimension is not public: consumers see an ErrorEllipse and sigmas for heading and speed. The estimator uses hidden accessors for the vector and covariance and rebuilds the state through a hidden, re-validating constructor. Six components because each is directly observed by a standard bridge sensor — GNSS position, gyro heading, log speed — with current reconciling them.

use kinavis_kernel::gnss::{Dop, GnssFix};
use kinavis_kernel::state::NavigationState;
use kinavis_kernel::time::{Civil, Instant, Utc};
use kinavis_kernel::{Position, Speed, TrueCourse};

let fix = GnssFix::builder(
    Instant::<Utc>::from_civil(Civil::date(2026, 9, 11))?,
    "50°45.3'N 001°20.0'W".parse::<Position>()?,
)
.course_over_ground(TrueCourse::new(272.5)?)
.speed_over_ground(Speed::from_knots(11.3)?)
.hdop(Dop::new(1.0)?)
.build();

let state = NavigationState::initialised_from(&fix, None)?;
assert_eq!(state.heading().degrees(), 272.5);
assert!((state.speed_through_water().knots() - 11.3).abs() < 1e-9);
// Four metres one-sigma from the HDOP, in every direction.
assert!((state.horizontal_error().semi_major().metres() - 4.0).abs() < 1e-9);

Structs§

NavigationState
Estimator belief about the vessel at one instant.
StatePriors
Initial 1σ priors where the fix provides none.

Enums§

StateComponent
State vector component, by name.