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.

HybridSmoother

Open In Colab

HybridSmoother implements an incremental fixed-lag smoother for hybrid systems. Unlike a full ISAM approach which keeps the entire history, a fixed-lag smoother marginalizes out older variables to maintain a bounded-size active window.

It includes features for:

  • Storing all factors (HybridNonlinearFactorGraph).

  • Maintaining a linearization point (Values).

  • Holding the current posterior (HybridBayesNet).

  • Optionally removing “dead modes” based on a marginal probability threshold (marginalThreshold_).

  • An update method to incorporate new factors.

  • A relinearize method.

Initialization

Constructed optionally with a marginalThreshold for dead mode removal. It starts with an empty internal state.

Initialized Smoother 1 (no threshold)
Initialized Smoother 2 (threshold=0.99)
 Smoother 2 initial fixed values: DiscreteValues{}

Update Steps

The update method incorporates new nonlinear factors and initial estimates. It performs linearization, updates the internal HybridBayesNet posterior (by eliminating variables related to the new factors against the current posterior), and updates the linearization point. Pruning based on maxNrLeaves and marginalThreshold occurs during this step.

--- Update 0 ---
Smoother state after update 0:
 Lin Point Size: 1
 Factors Size: 2
 Posterior HybridBayesNet:
HybridBayesNet
 
size: 1
conditional 0: p(x0)
  R = [ 10  0  0 ]
      [  0 10  0 ]
      [  0  0 20 ]
  d = [ 0 0 0 ]
  mean: 1 elements
  x0: 0 0 0
  logNormalizationConstant: 4.84409
  No noise model
 Fixed Values: DiscreteValues{7205759403792793600: 0}

--- Update 1 ---
Smoother state after update 1:
 Lin Point Size: 2
 Posterior HybridBayesNet:
HybridBayesNet
 
size: 2
conditional 0: p(x0 | x1)
  R = [ 14.1421       0       0 ]
      [       0 14.1421 7.07107 ]
      [       0       0 61.0967 ]
  S[x1] = [  -7.07107         0         0 ]
          [         0  -7.07107         0 ]
          [         0 -0.818375  -53.7313 ]
  d = [ 0 0 0 ]
  logNormalizationConstant: 6.65396
  No noise model
conditional 1: p(x1)
  R = [ 7.07107       0       0 ]
      [       0 7.02355 -6.2607 ]
      [       0       0 18.8827 ]
  d = [ 0 0 0 ]
  mean: 1 elements
  x1: 0 0 0
  logNormalizationConstant: 4.08671
  No noise model
 Fixed Values: DiscreteValues{7205759403792793600: 0}

Accessing State and Optimization

Allows accessing the current linearization point, the posterior HybridBayesNet, and optimizing the posterior.


Current Linearization Point:
Values with 2 values:
Value x0: (gtsam::Pose2)
(0, 0, 0)

Value x1: (gtsam::Pose2)
(1, 0, 0)


Current Posterior HybridBayesNet:
HybridBayesNet
 
size: 2
conditional 0: p(x0 | x1)
  R = [ 14.1421       0       0 ]
      [       0 14.1421 7.07107 ]
      [       0       0 61.0967 ]
  S[x1] = [  -7.07107         0         0 ]
          [         0  -7.07107         0 ]
          [         0 -0.818375  -53.7313 ]
  d = [ 0 0 0 ]
  logNormalizationConstant: 6.65396
  No noise model
conditional 1: p(x1)
  R = [ 7.07107       0       0 ]
      [       0 7.02355 -6.2607 ]
      [       0       0 18.8827 ]
  d = [ 0 0 0 ]
  mean: 1 elements
  x1: 0 0 0
  logNormalizationConstant: 4.08671
  No noise model

Current Fixed Values: DiscreteValues{7205759403792793600: 0}

MAP Solution from Smoother:
HybridValues: 
  Continuous: 2 elements
  x0: 0 0 0
  x1: 0 0 0
  Discrete: (d0, 0)
  Nonlinear
Values with 0 values:
 Solution D(0): 0, Fixed D(0): 0

Relinearization

The relinearize method rebuilds the posterior HybridBayesNet by relinearizing all stored factors (allFactors_) around the current linearization point.


Relinearizing...
Relinearization complete. Posterior HybridBayesNet:
HybridBayesNet
 
size: 2
conditional 0: p(x1 | x0)
  R = [      10       0       0 ]
      [       0      10       0 ]
      [       0       0 57.2958 ]
  S[x0] = [      -10        0        0 ]
          [        0      -10      -10 ]
          [        0        0 -57.2958 ]
  d = [ 0 0 0 ]
  logNormalizationConstant: 5.89658
  No noise model
conditional 1: p(x0)
  R = [ 10  0  0 ]
      [  0 10  0 ]
      [  0  0 20 ]
  d = [ 0 0 0 ]
  mean: 1 elements
  x0: 0 0 0
  logNormalizationConstant: 4.84409
  No noise model

MAP Solution after relinearization:
HybridValues: 
  Continuous: 2 elements
  x0: 0 0 0
  x1: 0 0 0
  Discrete: (d0, 0)
  Nonlinear
Values with 0 values: