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
Use ShonanAveragingParameters2 with planar rotations and ShonanAveragingParameters3 with spatial rotations. Both wrap a LevenbergMarquardtParams object and add Shonan-specific controls.
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.