Created by Codex.
Configure the relaxation, gauge handling, anchoring, robustness, and certification used by Shonan averaging.
Mathematical idea¶
At each staircase level, the optimizer searches on and evaluates a certificate matrix . A nonnegative minimum eigenvalue,
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.XPython 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.