pub struct MotionBasedViInitializer { /* private fields */ }Expand description
State machine that fires a single VIBA1 inertial-only solve once the
keyframe count + cumulative-translation thresholds are met. See the
module docstring and the design note
docs/motion_based_vi_alignment.md for the full contract.
Implementations§
Source§impl MotionBasedViInitializer
impl MotionBasedViInitializer
Sourcepub const fn new(
config: MotionBasedViInitializerConfig,
) -> MotionBasedViInitializer
pub const fn new( config: MotionBasedViInitializerConfig, ) -> MotionBasedViInitializer
Construct with the given config; carries no keyframes yet.
Sourcepub const fn config(&self) -> &MotionBasedViInitializerConfig
pub const fn config(&self) -> &MotionBasedViInitializerConfig
Borrow the active configuration.
Sourcepub const fn set_gravity_world(
&mut self,
gravity_world: Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>,
)
pub const fn set_gravity_world( &mut self, gravity_world: Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, )
Overwrite the running config’s gravity_world. Used by
crate::OnlineSlamPipeline::promote_motion_vi_init_result to mirror
a freshly-estimate_gravity-recovered gravity vector back into this
initializer so a LATER window (a subsequent
BiasReleaseSchedule Stage B, or a fresh sequence after
reset_sequence_state) starts from the corrected assumption instead
of the original (possibly wrong) config value. Does not touch any
cached result or registered keyframe/translation state.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Drop every accumulated keyframe and the cached VIBA1 result. The
configuration is preserved. Mirrors
crate::VisualInertialInitializer::reset.
Sourcepub fn keyframes_observed(&self) -> usize
pub fn keyframes_observed(&self) -> usize
Number of keyframes registered since construction / last reset.
Sourcepub const fn cumulative_translation_meters(&self) -> f64
pub const fn cumulative_translation_meters(&self) -> f64
Cumulative camera-centre translation (m) along the registered keyframe chain.
Sourcepub fn register_keyframe(
&mut self,
keyframe_id: u64,
camera_center_world: OPoint<f64, Const<3>>,
)
pub fn register_keyframe( &mut self, keyframe_id: u64, camera_center_world: OPoint<f64, Const<3>>, )
Note a freshly-registered keyframe’s camera centre in world frame. The first call after construction / reset only seeds the chain; subsequent calls add the inter-keyframe distance to the running cumulative-translation total.
Idempotent against re-registering the same keyframe_id: a
second call with the same id silently overwrites the prior
centre without double-counting. (This matters when a pipeline
fires a “new keyframe” event and immediately corrects the pose
via local-BA on the same frame.)
Sourcepub fn is_ready(&self) -> bool
pub fn is_ready(&self) -> bool
true once both trigger gates (keyframe count + translation)
are satisfied. try_initialize will still return Err if no IMU
factor connects any pair, but is_ready is the cheap pre-check
the pipeline can poll on every frame.
Sourcepub const fn result(&self) -> Option<&MotionBasedViInitializationResult>
pub const fn result(&self) -> Option<&MotionBasedViInitializationResult>
Returns the cached result if VIBA1 has already fired.
Sourcepub const fn velocity_stage_result(
&self,
) -> Option<&MotionBasedViInitializationResult>
pub const fn velocity_stage_result( &self, ) -> Option<&MotionBasedViInitializationResult>
Returns the cached BiasReleaseSchedule Stage A (“velocity
stage”) result, if one has fired. Always None when
config().bias_release is None, or once the initializer has
reached the terminal Initialised state (Stage A’s cache is not
cleared on Stage B success, but callers should prefer
Self::result at that point).
Sourcepub const fn last_gravity_alignment(&self) -> Option<&GravityVelocityAlignment>
pub const fn last_gravity_alignment(&self) -> Option<&GravityVelocityAlignment>
Returns the most recent estimate_gravity_and_velocities outcome,
if config().estimate_gravity has ever produced one — regardless of
whether that attempt went on to be accepted or rejected by a later
gate. None when estimate_gravity is off, when no in-window
attempt has run yet, or after Self::reset. See the field-level
doc comment on last_gravity_alignment for why this exists
separately from the terminal Self::result.
Sourcepub const fn last_gyro_bias_alignment(&self) -> Option<&GyroBiasAlignment>
pub const fn last_gyro_bias_alignment(&self) -> Option<&GyroBiasAlignment>
Returns the most recent estimate_gyro_bias outcome, if
config().estimate_gyro_bias has ever produced one — regardless of
whether that attempt went on to be accepted or rejected by a later
gate. None when estimate_gyro_bias is off, when no in-window
attempt has run yet, or after Self::reset. See the field-level
doc comment on last_gyro_bias_alignment for why this exists
separately from the terminal Self::result.
Sourcepub fn status(&self) -> MotionBasedViInitializationStatus
pub fn status(&self) -> MotionBasedViInitializationStatus
Render a read-only snapshot of the current state.
Sourcepub fn try_initialize(
&mut self,
map: &mut VisualMap,
preintegration_factors: &[ImuPreintegrationFactor],
static_seed: &VisualInertialInitializationResult,
) -> Result<&MotionBasedViInitializationResult, MotionBasedViRejectionReason>
pub fn try_initialize( &mut self, map: &mut VisualMap, preintegration_factors: &[ImuPreintegrationFactor], static_seed: &VisualInertialInitializationResult, ) -> Result<&MotionBasedViInitializationResult, MotionBasedViRejectionReason>
Attempt to fire VIBA1 over the registered keyframes.
On success, the inertial-only solve refines map.keyframes[*]’s
poses in place and the cached
MotionBasedViInitializationResult is returned. The
initialiser is single-shot: a successful firing parks the
initialiser in the Initialised state and subsequent calls
short-circuit to the cached result. Call Self::reset to
re-arm for a new sequence.
static_seed is consumed only as a sanity seed for downstream
keyframe_states (the inertial-only solver pulls per-keyframe
initial values from map.keyframes[*]’s poses + the static
seed’s biases / velocity).
Sourcepub fn try_initialize_with_bias_seed(
&mut self,
map: &mut VisualMap,
preintegration_factors: &[ImuPreintegrationFactor],
bias_gyro_seed: Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>,
bias_acc_seed: Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>,
) -> Result<&MotionBasedViInitializationResult, MotionBasedViRejectionReason>
pub fn try_initialize_with_bias_seed( &mut self, map: &mut VisualMap, preintegration_factors: &[ImuPreintegrationFactor], bias_gyro_seed: Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, bias_acc_seed: Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, ) -> Result<&MotionBasedViInitializationResult, MotionBasedViRejectionReason>
Motion-based initialization from explicit bias linearisation values. This is the safe fallback entry point for sequences that begin in motion: the caller may retain its calibrated/configured biases after a stationary initializer gives up, without fabricating a false static gravity/bias result. The solver still requires its normal keyframe and translation excitation gates.
When config().bias_release is Some(schedule), this call may
instead run BiasReleaseSchedule Stage A (the bias-fixed
“velocity stage”): see the type-level docs on
BiasReleaseSchedule for the full two-stage contract. Check
result.bias_released — false means this is a non-terminal Stage
A result; true means the legacy path or Stage B fired and the
initializer is now Initialised.
Trait Implementations§
Source§impl Clone for MotionBasedViInitializer
impl Clone for MotionBasedViInitializer
Source§fn clone(&self) -> MotionBasedViInitializer
fn clone(&self) -> MotionBasedViInitializer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MotionBasedViInitializer
impl Debug for MotionBasedViInitializer
Source§impl PartialEq for MotionBasedViInitializer
impl PartialEq for MotionBasedViInitializer
impl StructuralPartialEq for MotionBasedViInitializer
Auto Trait Implementations§
impl Forget for MotionBasedViInitializer
impl Freeze for MotionBasedViInitializer
impl Move for MotionBasedViInitializer
impl RefUnwindSafe for MotionBasedViInitializer
impl Send for MotionBasedViInitializer
impl Sync for MotionBasedViInitializer
impl Unpin for MotionBasedViInitializer
impl UnsafeUnpin for MotionBasedViInitializer
impl UnwindSafe for MotionBasedViInitializer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.