Part VI: Motion, Location, and Inertial Intelligence
Chapter 24: Orientation Estimation and Dead Reckoning

Learned inertial odometry (IONet-style)

"I stopped integrating the accelerometer and started predicting where a person like this, moving like this, tends to end up. My error stopped exploding. Nobody told me walking was so predictable."

A Data-Driven AI Agent

Why this section matters

The previous two sections fought inertial drift with physics and hand-built logic: mechanize the strap-down equations, detect the stance phase, inject a zero-velocity pseudo-measurement, hand-calibrate a step-length model. It works, but it is brittle: the stance detector needs a foot mount and per-gait tuning, the step-length model needs per-user calibration, and the whole edifice cracks once the device moves to a swinging hand or a trouser pocket. Learned inertial odometry takes the opposite bet, reading a short window of raw IMU samples and directly regressing how far and in what direction the device moved, learning from data the very regularities dead reckoning hand-codes: that people walk at bounded speeds, that gait is quasi-periodic, that carrying pose constrains motion. The payoff is a phone-in-pocket pedestrian tracker that holds a few meters of error over minutes with no external signal, foot mount, or per-user calibration. This section builds the idea from IONet forward, through the output-parameterization tricks that make it generalize, to the uncertainty-aware fusion that makes it deployable.

This section assumes the drift story of Section 24.4 and the ZUPT and pedestrian-dead-reckoning baselines of Section 24.5, which learned inertial odometry is designed to replace. The models are sequence regressors, so the recurrent and temporal-convolutional architectures of Chapter 14 are the toolbox, built on the raw signal characteristics of Chapter 23 and, for the fusion at the end, the Kalman machinery of Chapter 9.

From double integration to direct regression

The root cause of inertial drift is that position is the double integral of a biased, noisy signal, so a constant accelerometer bias \(b\) becomes a position error growing as \(\tfrac{1}{2} b t^2\); no amount of clever filtering removes an error that the estimator's own structure amplifies. IONet, introduced by Chen and colleagues in 2018, breaks that chain by refusing to integrate at all: instead of estimating instantaneous acceleration and integrating it twice, it treats a fixed window of inertial samples (say two seconds of accelerometer and gyroscope, 200 samples at 100 Hz) as one input and regresses the net displacement over that window as one output. Formally, a network \(f_\theta\) maps a window of six-axis IMU data \(\mathbf{X}_t \in \mathbb{R}^{W \times 6}\) to a planar displacement expressed as a polar vector,

$$ (\Delta l_t,\ \Delta\psi_t) = f_\theta(\mathbf{X}_t), $$

where \(\Delta l_t\) is the distance travelled in the window and \(\Delta\psi_t\) is the change of heading. The full trajectory is then a simple sum of these short segments rather than a fragile chain of accelerations. Because the network sees a whole gait cycle at once, it can exploit the periodic acceleration signature to infer speed, the same information the Weinberg step-length model tries to capture with a single hand-picked exponent, but learned end to end and jointly with heading. IONet's original backbone is a two-layer bidirectional LSTM, chosen because bidirectionality lets the network read the entire window before committing, resolving which phase of the gait cycle a sample belongs to from context on both sides rather than the past alone. Later work shows temporal convolutional and residual networks match that accuracy while training faster, since a dilated receptive field can be sized to the window without an LSTM's sequential unrolling; pick the bidirectional LSTM for buffered, offline processing and a causal TCN when an embedded device must stream displacement window by window under a tight latency budget.

The network learns the motion prior that PDR hand-codes

Pedestrian dead reckoning works only because it injects strong human-motion priors: a step is a discrete event, step length is a smooth function of cadence and acceleration variance, heading changes slowly. Each prior is a hand-written equation with a coefficient someone tuned. Learned inertial odometry absorbs all of them into \(\theta\), fit from data, which is why it degrades gracefully to carrying poses no one wrote a stance detector for: the network learns a different input-to-displacement mapping for the pocket than for the swinging hand, from examples, without a mode switch. The cost is that it inherits the biases of its training distribution, precisely why leakage-safe, subject-independent evaluation is non-negotiable here.

Output parameterization and the heading-agnostic frame

The single most important design choice is the coordinate frame the displacement is expressed in, and getting it wrong quietly destroys generalization. Output in the device body frame and the network must implicitly learn device orientation, overfitting to the orientations seen in training; output in the global world frame and the target depends on an absolute heading the IMU cannot observe. RoNIN, from Herath and colleagues in 2020, resolves this with a heading-agnostic coordinate frame: ground-truth velocity is rotated into a frame aligned with gravity but with yaw fixed by the device's own tracked heading, so the network only ever predicts motion relative to where it currently believes it is pointing, while the absolute heading is integrated separately from the gyroscope. This decoupling, learn speed and turn rate in a self-referential frame, integrate global heading with classical attitude tracking, is what lets one model work across phone-in-hand, in-pocket, and in-bag placements. IONet's polar \((\Delta l, \Delta\psi)\) output is a compact special case of the same idea, since a distance and a relative heading change are already invariant to the absolute world orientation.

Frontier: RoNIN, TLIO, and neural inertial navigation in the wild

RoNIN (Herath et al., 2020) released ResNet, LSTM, and TCN regressors with a large multi-subject dataset, reporting roughly 4 to 5 meters of absolute trajectory error over minutes-long indoor walks; TLIO (Liu et al., 2020) fuses a regressed covariance in a stochastic-cloning EKF for sub-1-percent-of-distance drift on head-mounted data. IONet (Chen et al., 2018) and RIDI (Yan et al., 2018, correcting double integration rather than replacing it) sit at the origin of the line. Current SOTA work pushes generalization without per-device tuning: AirIMU (Qiu et al., 2023) learns the IMU's own noise and bias model end to end instead of assuming one, cutting drift on aggressive drone and legged-robot motion, and EqNIO (2024) bakes the rotation symmetry of inertial motion directly into the network so one model transfers across mounting orientations never seen in training. Transformer and state-space-model backbones (Chapter 15, Chapter 16) are now the default choice for the sequence-to-displacement map itself.

Predicting displacement with calibrated uncertainty, then fusing it

A raw displacement regressor is useful, but one that also reports how much to trust each prediction is what turns learned odometry into a full navigation system. TLIO's contribution is to output not just a displacement \(\mathbf{d}_t\) but a diagonal (or full) covariance \(\boldsymbol{\Sigma}_t\), trained by minimizing the Gaussian negative log-likelihood

$$ \mathcal{L} = \tfrac{1}{2}(\mathbf{d}_t - \hat{\mathbf{d}}_t)^\top \boldsymbol{\Sigma}_t^{-1} (\mathbf{d}_t - \hat{\mathbf{d}}_t) + \tfrac{1}{2}\log\det\boldsymbol{\Sigma}_t, $$

so the network learns to widen its uncertainty exactly where it is unreliable, during fast turns or unusual motion. That covariance is not a decoration: it becomes the measurement-noise matrix \(\mathbf{R}\) when the displacement feeds an error-state EKF that also tracks orientation and IMU biases as a pseudo-measurement, the same structural role the zero-velocity update played in Section 24.5, minus the foot mount or stance threshold. Well-calibrated variance, not just a low mean error, is what lets the filter weight the network against other sensors correctly; calibrating it is the subject of Chapter 18.

import torch, torch.nn as nn

class IONetLite(nn.Module):
    """Regress planar displacement (dx, dy) from a window of 6-axis IMU."""
    def __init__(self, in_ch=6, hidden=128, layers=2):
        super().__init__()
        self.lstm = nn.LSTM(in_ch, hidden, layers,
                            batch_first=True, bidirectional=True)
        self.head = nn.Linear(2 * hidden, 2)   # (dx, dy) in the heading-agnostic frame

    def forward(self, x):                       # x: (B, W, 6)
        out, _ = self.lstm(x)                   # (B, W, 2*hidden)
        return self.head(out[:, -1])            # use the last step's summary

def integrate(disps):
    """Sum per-window displacements into a trajectory. disps: (T, 2)."""
    return torch.cumsum(disps, dim=0)

model = IONetLite()
window = torch.randn(4, 200, 6)                 # 4 windows, 2 s at 100 Hz
print(model(window).shape)                      # torch.Size([4, 2])
A minimal IONet-style regressor: a bidirectional LSTM maps a 200-sample IMU window to a planar displacement in the heading-agnostic frame, and integrate sums the per-window displacements into a trajectory. A production model would add a covariance head (predicting \(\log\sigma^2\) per axis) and train with the Gaussian negative-log-likelihood loss above.

The snippet shows the core: no hand-tuned threshold, no explicit integration of acceleration, just a window-to-displacement map plus a cumulative sum. A second output head for \(\log\sigma^2\), with the mean-squared-error loss swapped for the likelihood above, upgrades it to the TLIO-style uncertainty-aware form.

Indoor navigation for a mixed-reality headset

A standalone augmented-reality headset must keep virtual content locked to the room even when the visual-inertial tracker briefly fails: a dark corridor, a blank wall, or cameras duty-cycled to save battery. During that blackout, a learned inertial odometry model runs on the head-mounted IMU alone, regressing three-dimensional displacement with covariance in the TLIO style and feeding it to the pose filter. Trained on head-motion data with visual-inertial ground truth, it captures the characteristic bob and turn of a walking wearer far better than raw integration, and its covariance grows during the fast head turns it handles worst, so the filter leans back on vision the instant the cameras recover: content stops visibly swimming, with no extra sensor beyond the IMU already on the board.

Training data, generalization, and leakage-safe evaluation

Learned inertial odometry is only as good as its ground truth and its splits. Training needs paired IMU-and-trajectory data, with the trajectory supplied by a reference system the IMU never sees at inference (an optical motion-capture rig, a visual-inertial SLAM system, or a survey-grade setup) and the target displacement per window read off that reference. Two failure modes dominate. The network can memorize subject-specific and device-specific quirks, so a model that scores well only because the same person's later walk appears in the test set is measuring memorization, not odometry; subject-independent and device-independent splits are mandatory, exactly the leakage-safe discipline of Chapter 5. And because the model still integrates its own gyroscope-derived heading, a slow yaw drift still curls long trajectories.

Misconception: regression does not mean drift-free

It is tempting to read "IONet escapes double-integration drift" as "IONet has no drift." It does not: the network only replaces the integration of acceleration into position. Heading still comes from integrating the gyroscope, so a slow yaw bias still curls a long trajectory, a failure mode Section 24.5's zero-velocity updates never faced because they left heading alone. Treat the learned displacement as a large reduction in one error source, not a removal of drift altogether.

Evaluation therefore reports both a heading-sensitive metric (absolute trajectory error) and a heading-agnostic one (relative or position drift); those metrics, and why you need more than one, are the subject of Section 24.7. Where an absolute heading or position reference is available, the learned track is fused with it rather than trusted alone, the fusion picked up in Chapter 25.

Right tool: start from RoNIN and TLIO reference code

Reproducing this from scratch (data loader, heading-agnostic frame construction, ResNet or LSTM regressor, covariance head, stochastic-cloning EKF) is well over a thousand lines and weeks of dataset wrangling before a single trajectory looks right. The public RoNIN and TLIO repositories ship the network definitions, pretrained weights, coordinate-frame preprocessing, and fusion filter as tested modules, collapsing the effort to a data-loader adapter plus a fine-tune loop of one to two hundred lines. Build the tiny regressor above to internalize the window-to-displacement idea, then adopt a reference stack for the heading-frame handling and covariance calibration, the hardest parts to get right unaided.

Exercise

Using a public pedestrian IMU dataset with ground-truth trajectories (RoNIN or OxIOD), train the IONetLite regressor above to predict per-window planar displacement in a heading-agnostic frame and integrate its output into a trajectory. Compare its absolute trajectory error against a classical step-and-heading baseline from Section 24.5 on a strictly subject-independent split. Then hold out an entire carrying pose (train on hand and pocket, test on bag) and measure how much the error grows: this generalization gap separates a demo from a deployable model.

Self-check

1. Why does regressing net displacement over a window escape the \(\tfrac{1}{2}bt^2\) error growth that dooms raw double integration?

2. What goes wrong if you train the network to output displacement in the device body frame, and how does the heading-agnostic frame fix it?

3. TLIO outputs a covariance alongside each displacement. Give two distinct reasons that covariance is worth the extra output head, one for training and one for fusion.

What's Next

In Section 24.7, we make the comparisons in this section rigorous: how to score a trajectory estimate faithfully, separating absolute from relative error, aligning estimated and reference paths, and reporting drift as a fraction of distance so a classical filter and a learned odometry model can be judged on the same, leakage-safe footing.