Created by Codex.
Store a typed measurement between two keys without defining an error function.
Mathematical idea¶
A binary measurement record packages an observation and covariance with its ordered endpoint keys :
It deliberately does not define a prediction or residual ; an algorithm consuming the record chooses that model.
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.XWhen to use it¶
BinaryMeasurement<T> is data, not an optimizable factor. It keeps an ordered key pair, a value, and its noise model together. The edge direction matters: (a, b) is not interchangeable with (b, a).
Python exposes BinaryMeasurementUnit3, BinaryMeasurementRot3, and BinaryMeasurementPoint3. The wrapper support containers BinaryMeasurementsUnit3, BinaryMeasurementsRot3, and BinaryMeasurementsPoint3 are mainly useful for MATLAB interoperability; ordinary Python code can pass a list.
direction_noise = gtsam.noiseModel.Isotropic.Sigma(2, 0.01)
measurement = gtsam.BinaryMeasurementUnit3(
X(0), X(1), gtsam.Unit3(np.array([1.0, 0.0, 0.0])), direction_noise
)
print("keys:", measurement.key1(), measurement.key2())
print("direction:", measurement.measured().point3())
print("noise sigmas:", measurement.noiseModel().sigmas())keys: 8646911284551352320 8646911284551352321
direction: [1. 0. 0.]
noise sigmas: [0.01 0.01]
Practical notes¶
Choose a noise-model dimension matching the manifold dimension of
T: 2 forUnit3, 3 forRot3andPoint3.Use
Unit3measurements for translation or bearing directions,Rot3for rotation averaging, andPoint3when magnitude is known.See
TranslationRecovery,GlobalPositioner, andMFASfor algorithms that consume these measurements.