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.

ShonanAveragingParameters

Created by Codex.

Configure the relaxation, gauge handling, anchoring, robustness, and certification used by Shonan averaging.

Open In Colab

Mathematical idea

At each staircase level, the optimizer searches on SO(p)\mathrm{SO}(p) and evaluates a certificate matrix SS. A nonnegative minimum eigenvalue,

λmin(S)0,\lambda_{\min}(S)\ge 0,

certifies the relaxed optimum under the Shonan construction; a negative eigenvector supplies an escape direction to the next level. The embedded Levenberg–Marquardt (LM) parameters control each nonlinear solve.

import gtsam
import numpy as np

from gtsam import symbol_shorthand

C = symbol_shorthand.C
K = symbol_shorthand.K
P = symbol_shorthand.P
S = symbol_shorthand.S
X = symbol_shorthand.X

Python variants

Use ShonanAveragingParameters2 with planar rotations and ShonanAveragingParameters3 with spatial rotations. Both wrap a LevenbergMarquardtParams object and add Shonan-specific controls.

lm = gtsam.LevenbergMarquardtParams()
lm.setMaxIterations(100)

parameters = gtsam.ShonanAveragingParameters3(lm)
parameters.setAnchor(0, gtsam.Rot3())
parameters.setAnchorWeight(1e3)
parameters.setUseHuber(True)
parameters.setCertifyOptimality(True)
parameters.setOptimalityThreshold(1e-4)

print("anchor:", parameters.getAnchor()[0])
print("Huber enabled:", parameters.getUseHuber())
print("certification enabled:", parameters.getCertifyOptimality())
anchor: 0
Huber enabled: True
certification enabled: True

Tuning guidance

Start from defaults. Set an anchor when a particular world frame matters; otherwise the algorithm handles the global rotation gauge. Huber loss helps with moderate outliers, but severely corrupted rotation graphs may need explicit outlier rejection before averaging. Certification costs extra eigenvalue work and is valuable when a global-optimality statement matters.