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.

BinaryMeasurement

Created by Codex.

Store a typed measurement between two keys without defining an error function.

Open In Colab

Mathematical idea

A binary measurement record packages an observation zabz_{ab} and covariance Σab\Sigma_{ab} with its ordered endpoint keys (a,b)(a,b):

(a,b,zab,Σab).(a,b,z_{ab},\Sigma_{ab}).

It deliberately does not define a prediction h(xa,xb)h(x_a,x_b) or residual h(xa,xb)zabh(x_a,x_b)-z_{ab}; 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.X

When 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 for Unit3, 3 for Rot3 and Point3.

  • Use Unit3 measurements for translation or bearing directions, Rot3 for rotation averaging, and Point3 when magnitude is known.

  • See TranslationRecovery, GlobalPositioner, and MFAS for algorithms that consume these measurements.