S1 — Initialization
A filter has to start somewhere. Visual-Inertial Odometry is a highly non-linear, recursive estimation process. For its linearizations (first-order Taylor-series expansions / Jacobians) to remain valid, the filter must be initialized incredibly close to the true initial state.
S1 bootstraps the initial state — attitude, gyro/accel biases, gravity direction, and (for a moving dynamic start) metric scale — and seeds the initial covariance that represents the filter’s starting uncertainty.
If S1 fails, it introduces two severe failure modes: returning a confidently wrong state when the motion cannot observe it, or seeding too tight on the directions the initialization could not physically observe. the first causes immediate divergence; the second quietly poisons the EKF with structural over-confidence from .
1. Static Initialization (Gravity-Leveling)
Section titled “1. Static Initialization (Gravity-Leveling)”When the vehicle starts stationary on the ground, S1 detects a quiet window by checking that the standard deviation of gyroscope and accelerometer readings is below a strict threshold. It then averages the raw readings over samples:
$\mathbf{a}_{\text{avg}} = \cfrac{1}{M} \sum_{i=1}^M \tilde{\mathbf{a}}_i, \qquad \mathbf{w}_{\text{avg}} = \cfrac{1}{M} \sum_{i=1}^M \tilde{\mathbf{w}}_i$A. Gyroscope Bias Seeding
Section titled “A. Gyroscope Bias Seeding”Since the vehicle is stationary (), any measured angular rate is pure bias. We seed the gyroscope bias directly:
B. Attitude Seeding from Gravity (Leveling)
Section titled “B. Attitude Seeding from Gravity (Leveling)”Since the accelerometer only senses gravity when static, the mean specific force vector points exactly opposite to gravity. We use this to compute the initial roll and pitch of the vehicle relative to gravity, represented by the rotation matrix (IMU-to-World transformation).
We define the vertical z-axis of the IMU frame in the world frame as:
To build a full orthogonal rotation matrix that maps gravity to (or conversely, aligns with gravity), we use Gram-Schmidt orthonormalization:
- Temporary Horizontal Axis: Assume an arbitrary temporary horizontal x-axis: .
- Orthogonal Y Axis: Compute the orthogonal y-axis via the cross product: \mathbf{y}_I = \cfrac{\mathbf{z}_I \times \mathbf{x}_{%%text{tmp}}}{\|\mathbf{z}_I \times \mathbf{x}_{\text{tmp}}\|} (where is the cross-product).
- True Orthogonal X Axis: Compute the true orthogonal x-axis: .
- Assemble Rotation: The initial rotation matrix is then:
- Orthonormalization Singularity & Fallback: If the gravity vector is parallel or near-parallel to the temporary horizontal axis (which happens if the drone is tilted exactly on its side), the cross product collapses to zero, making step 2 undefined. Cortex solves this by checking the norm of . If it falls below a strict threshold (e.g., ), it dynamically falls back to using as the temporary axis, ensuring the basis construction is always well-conditioned.
Because gravity has zero horizontal components, static accelerometer readings can only observe the two tilt axes (roll and pitch). The heading (yaw) is completely unobservable relative to gravity. Yaw is a free gauge direction; we can set it to an arbitrary starting value (), but the filter must be told that this yaw direction is completely unobserved.
2. Dynamic Initialization (Visual-Inertial Alignment)
Section titled “2. Dynamic Initialization (Visual-Inertial Alignment)”If the vehicle starts in motion (e.g., hand-launched or already flying), static gravity-leveling is impossible because world-frame acceleration . S1 must perform a Visual-Inertial Alignment over a short sliding window (usually 1 to 2 seconds) to find metric scale.
This spatial alignment matching process is shown in the following diagram:
- Structure from Motion (SfM): The visual frontend tracks features over multiple frames and runs a bundle-adjustment to recover a set of relative camera translations up to a scale factor .
- IMU Preintegration: The IMU Simple-integrated velocities and positions are double-integrated over the same intervals to compute relative displacement estimates .
- Linear Scale Alignment: We set up a linear system matching the visual translations to the double-integrated IMU displacements, solving for the metric scale , initial velocities , and gravity vector :
The Scale-Observability Cliff
Section titled “The Scale-Observability Cliff”Under gentle motion (such as hover or pure rotation), the acceleration vector does not change. In this regime, the system of equations is ill-conditioned, and the metric scale is physically unobservable.
To prevent the EKF from starting with a confidently wrong metric scale, Cortex runs a Singular Value Decomposition (SVD) condition check on the alignment matrix . If the ratio of the maximum to minimum singular values (condition number) exceeds a strict threshold (usually 100), the dynamic initialization is safely declined, forcing the system to wait for sufficient acceleration excitation.
3. The Covariance Seed Suspect: Isotropic Over-Confidence
Section titled “3. The Covariance Seed Suspect: Isotropic Over-Confidence”The initial covariance is a 15 x 15 matrix that represents the filter’s starting uncertainty.
Historically, many VIO implementations (including those generated by AI Code Assistants) initialize as an isotropic matrix:
Where every block (roll, pitch, yaw, velocity, position, gyroscope bias, accelerometer bias) gets the same small initial uncertainty (e.g., for rotation).
This isotropic seed is mathematically dishonest and a major source of over-confidence:
| State Block | Physical Observation at Static Init | Isotropic Seed () | Physically Honest Seed |
|---|---|---|---|
| Roll / Pitch | Observed via gravity-leveling (). | Small ( to ) | |
| Yaw (Heading) | Unobserved (gravity has no horizontal component). | Huge ( or treated as infinite) | |
| Velocity | Observed (stationary table is ). | Small () | |
| Accel Bias | Weakly Observed over a static window. | Large () |
By claiming that the unobservable yaw heading is known to at , the isotropic seed injects false information into the EKF. Because the filter “thinks” its heading is highly accurate, it will reject visual measurements that deviate slightly due to camera rotation, leading directly to the attitude-localized over-confidence seen on the Consistency Analysis page.
S1 Contract Specs
Section titled “S1 Contract Specs”The mathematical contracts ensuring safe filter bootstrapping:
| Element | Contract Specification |
|---|---|
| Signature | |
| Pre-conditions | Gyro/accel variance is below stationary noise threshold (static init); singular-value conditioning of SfM-IMU matrix is below 100 (dynamic init). |
| Post-conditions & Invariants | 1. Gravity alignment: Gravity vector aligns with measured mean specific force: . 2. Positive Scale: Dynamically recovered scale is strictly positive () and finite. 3. Realistic Yaw Prior: Heading (yaw) standard deviation is seeded with a large variance: to reflect its unobserved status. |
Exploring the Next Stage
Section titled “Exploring the Next Stage”Once the state and covariance are initialized, the filter transitions into high-rate inertial prediction.
- Explore S2 — IMU Propagation to see how the EKF predicts the mean and covariance forward in time.