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.

StereoFactor

Open In Colab

GenericStereoFactor<POSE, LANDMARK> is a factor for handling measurements from a calibrated stereo camera. It relates a 3D LANDMARK (usually Point3) to a StereoPoint2 measurement observed by a stereo camera system defined by a POSE (usually Pose3) and a fixed stereo calibration Cal3_S2Stereo.

StereoPoint2 contains (uL,uR,v)(u_L, u_R, v), the horizontal pixel coordinates in the left (uLu_L) and right (uRu_R) images, and the vertical pixel coordinate (vv), which is assumed the same for both images in a rectified stereo setup. Cal3_S2Stereo holds the intrinsic parameters (focal length, principal point) common to both cameras and the stereo baseline (distance between camera centers).

Key features:

  • Templated: Works with different pose and landmark types.

  • Fixed Calibration: Assumes the Cal3_S2Stereo object (K_) is known and fixed.

  • Sensor Offset: Optionally handles a fixed body_P_sensor_ (Pose3) transform.

  • Cheirality Handling: Can be configured for points behind the camera.

The error is the 3D vector difference:

error(P,L)=projectStereo(P⋅S,L)−z\text{error}(P, L) = \text{projectStereo}(P \cdot S, L) - z

where projectStereo uses the StereoCamera model, PP is the pose, LL the landmark, SS the optional offset, and zz is the measured_ StereoPoint2.

Creating a GenericStereoFactor

Instantiate by providing:

  1. The measurement (StereoPoint2).

  2. The noise model (typically 3D).

  3. The key for the pose variable.

  4. The key for the landmark variable.

  5. A shared_ptr to the fixed stereo calibration object (Cal3_S2Stereo).

  6. (Optional) The fixed Pose3 sensor offset body_P_sensor.

  7. (Optional) Cheirality handling flags.

Factor with offset:   keys = { x0 l1 }
  noise model: unit (3) 
Factor with offset: .z(330, 305, 250)
  sensor pose in body frame:  R: [
	6.12323e-17, 6.12323e-17, 1;
	-1, 3.7494e-33, 6.12323e-17;
	-0, -1, 6.12323e-17
]
t: 0.1   0 0.2

Factor without offset:   keys = { x0 l1 }
  noise model: unit (3) 

Factor without offset: .z(330, 305, 250)

Evaluating the Error

The error is the 3D difference between the predicted stereo projection and the measurement.

Expected landmark point (no offset): [ 1.54225239 -2.27112649  2.95849821]

Error (no offset) at expected landmark: 48664.883462255115 (Should be near zero)

Expected landmark point (offset): [ 2.89128008 -3.54882535  1.19789333]
Error (with offset) at recomputed landmark: 1783675.2295780657 (Should be near zero)

Error (no offset) at noisy landmark: 54320.22670263611