Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

FixedLagSmoother

This API walkthrough introduces the wrapped classes FixedLagSmoother, FixedLagSmootherResult declared by FixedLagSmoother.h and demonstrates their principal Python operations.

Open In Colab
import gtsam
import numpy as np
from gtsam.symbol_shorthand import L, X

Overview

The FixedLagSmoother class is the base class for BatchFixedLagSmoother and IncrementalFixedLagSmoother.

It provides an API for fixed-lag smoothing in nonlinear factor graphs. It maintains a sliding window of the most recent variables and marginalizes out older variables. This is particularly useful in real-time applications where memory and computational efficiency are critical.

Mathematical Formulation

In fixed-lag smoothing the objective is to estimate the state xt\mathbf{x}_t given all measurements up to time tt, but only retaining a fixed window of recent states. The optimization problem can be expressed as:

minxtL:ti=1Nhi(xtL:t)zi2\min_{\mathbf{x}_{t-L:t}} \sum_{i=1}^{N} \| \mathbf{h}_i(\mathbf{x}_{t-L:t}) - \mathbf{z}_i \|^2

where LL is the fixed lag, hi\mathbf{h}_i are the measurement functions, and zi\mathbf{z}_i are the measurements. In practice, the functions hi\mathbf{h}_i depend only on a subset of the state variables Xi\mathbf{X}_i, and the optimization is performed over a set of NN factors ϕi\phi_i instead:

minxtL:ti=1Nϕi(Xi;zi)2\min_{\mathbf{x}_{t-L:t}} \sum_{i=1}^{N} \| \phi_i(\mathbf{X}_i; \mathbf{z}_i) \|^2

The API below allows the user to add new factors at every iteration, which will be automatically pruned after they no longer depend on any variables in the lag.

Wrapped class API

The header also exposes the following wrapped classes. This executable listing makes their constructors, properties, and methods visible in the installed build: FixedLagSmootherResult.

def public_api(qualified_name):
    value = gtsam
    for component in qualified_name.split('.'):
        value = getattr(value, component, None)
        if value is None:
            return []
    return [name for name in dir(value) if not name.startswith('_')]

print('\nFixedLagSmootherResult')
print(public_api('FixedLagSmootherResult'))