Skip to main content

Prior Pose Covariance

A 6×6 prior pose covariance states how uncertain a prior pose is, and so how large a region around it the SDK searches. PoseEstimator::updatePose() / updatePosition() accept one; see the PoseEstimator Integration Guide.

The covariance is always expressed in the camera frame (DIN 9300: x forward, y right, z down). PoseEstimator's output covariance uses the same frame.

Building the covariance from search ranges​

Use raptor::poseCovarianceFromSearchRanges() from <raptor/covariance.hpp> to create this matrix from per-axis search ranges. A position value of 10 m on X means ±10 m from the prior position along X (20 m end to end); Y and Z work the same way. Attitude values specify ± angular offsets about Z, Y, and X (yaw, pitch, roll), in radians. Supply the orientation of each search-range frame relative to the camera; these can differ for position and attitude. The context argument is only used for diagnostic logging; invalid ranges or confidence intervals throw std::invalid_argument.

The optional confidenceInterval argument (default 0.9) converts the extents to variances as described in Search Range. Pass the same value as EstimationOptions::confidenceInterval so the search covers exactly the requested extents.

The rotation arguments give the orientation of each search-range frame relative to the camera (DIN 9300); their rotation matrices convert search-range frame components into camera components. The covariance helper itself does not need a pose. For ranges in local NED, raptor::nedRelativeToCamera(pose) supplies the orientation of NED relative to the camera, even when the pose uses ECEF coordinates. Its conjugate, raptor::cameraRelativeToNed(pose), is the camera orientation relative to NED, i.e. the attitude of a pose::Geodetic. Both helpers are declared in raptor/transforms.hpp; in Python they are raptor.ned_relative_to_camera(pose) and raptor.camera_relative_to_ned(pose).

Search ranges relative toRotation to pass
Cameraraptor::Quaternion{} (identity)
Aircraft body / IMUIMU orientation relative to the camera (mounting rotation)
Local NEDraptor::nedRelativeToCamera(pose)

Ranges already expressed in camera axes need no pose or frame conversion:

const auto covariance = raptor::poseCovarianceFromSearchRanges(
context, {10.0, 20.0, 30.0}, {}, {0.1, 0.05, 0.02}, {});

For a vehicle with a reliable barometer and gyro, but uncertain horizontal position and compass heading, search ±100 m north and east, ±5 m down, approximately ±20° in yaw, and approximately ±2° in pitch and roll. Express both position and attitude ranges in local NED using the orientation of NED relative to the prior pose's camera. Attitude values are passed in radians, and the matching confidence interval is passed to both calls:

raptor::guide::EstimationOptions options{};
options.confidenceInterval = 0.95;
const auto nedRelativeToCamera = raptor::nedRelativeToCamera(priorPose);
const auto covariance = raptor::poseCovarianceFromSearchRanges(
context, {100.0, 100.0, 5.0}, nedRelativeToCamera,
{0.35, 0.035, 0.035}, nedRelativeToCamera, options.confidenceInterval);
auto result = estimator.updatePose(image, lens, priorPose, timestamp, covariance, options);

The same in Python:

from raptor import ned_relative_to_camera, pose_covariance_from_search_ranges
from raptor.guide import EstimationOptions

options = EstimationOptions()
options.confidence_interval = 0.95
ned_to_camera = ned_relative_to_camera(prior_pose)
covariance = pose_covariance_from_search_ranges(
context, [100.0, 100.0, 5.0], ned_to_camera,
[0.35, 0.035, 0.035], ned_to_camera, options.confidence_interval)
result = estimator.update_pose(image, lens, prior_pose, timestamp, covariance, options)

For ranges measured along an IMU's axes, pass the IMU orientation relative to the camera (mounting rotation) for both frames (or different rotations if the position and attitude sources differ):

const auto covariance = raptor::poseCovarianceFromSearchRanges(
context, {10.0, 20.0, 30.0}, imuRelativeToCamera,
{0.1, 0.05, 0.02}, imuRelativeToCamera);

The pose_estimator example shipped with the SDK (examples/cpp/pose_estimator.cpp and examples/python/pose_estimator.py) builds the covariance this way. Its --search-position, --search-attitude and --axes options let you try search ranges in local NED and in the camera frame; see SDK Usage Examples.

Matrix Layout​

The covariance argument is a row-major 6×6 matrix passed as std::array<double, 36>. Off-diagonal entries are accepted; the diagonal carries the per-dimension variances.

IndexComponentUnitMeaning
[0]X (forward)m²Position variance along the camera's forward axis
[7]Y (right)m²Position variance along the camera's right axis
[14]Z (down)m²Position variance along the camera's down axis
[21]Yawrad²Rotation variance about the camera's down axis
[28]Pitchrad²Rotation variance about the camera's right axis
[35]Rollrad²Rotation variance about the camera's forward axis

Variances are applied symmetrically around the prior pose, with extents determined by the search-range calculation.

Rotating between frames​

If your uncertainty is expressed in a different frame (e.g. local NED, ECEF, aircraft body), rotate it into the camera frame before passing it in. With a 3×3 rotation R = R_camera_from_source:

Position block (top-left 3×3):

C_pos_camera = R · C_pos_source · Rᵀ

Attitude block (bottom-right 3×3):

The SDK stores this block in (yaw, pitch, roll) order, corresponding to rotations about (z, y, x). R operates on (x, y, z) components, so reorder both rows and columns into (roll, pitch, yaw) before rotating, then reorder the result back. Let P reverse the axis order:

P = [0 0 1
0 1 0
1 0 0]

C_att_source_xyz = P · C_att_source_ypr · Pᵀ
C_att_camera_xyz = R · C_att_source_xyz · Rᵀ
C_att_camera_ypr = Pᵀ · C_att_camera_xyz · P

Store C_att_camera_ypr in the bottom-right block of the SDK covariance. If the source already supplies an XYZ rotation covariance, start from C_att_source_xyz and still reorder the rotated result into SDK order. These equations concern small rotation errors about the specified axes; a navigation system's Euler-angle covariance may first require conversion into that representation. For per-axis search extents, prefer poseCovarianceFromSearchRanges(), which handles the SDK's attitude ordering.

If a full 6×6 source covariance includes position–attitude cross terms, rotate the full matrix rather than only the diagonal blocks. When both source blocks use the same frame, the transform in (x, y, z, yaw, pitch, roll) order is:

A = Pᵀ · R · P
T = [R 0
0 A]
C_camera = T · C_source · Tᵀ

R_camera_from_source for common source frames (let Q = pose.attitude.toMatrix(), which is row-major, same layout as raptor::Quaternion::toMatrix()):

  • Local NED (covariance from a pose::Geodetic-style nav output). Q encodes R_NED_from_camera, so

    R_camera_from_NED = Qᵀ
  • ECEF (covariance from a pose::Ecef-style nav output). Q encodes R_ECEF_from_camera, so

    R_camera_from_ECEF = Qᵀ
  • Aircraft body (covariance from an IMU bolted to the airframe, on a camera mounted at a non-trivial orientation). R is the camera mount rotation derived as the example in Conventions § Camera to platform:

    R_camera_from_aircraft = R_body_from_cameraᵀ

    For a camera rigidly aligned with the airframe (forward-looking, no tilt) this is the identity and the covariance can be passed through unchanged.

Search Range​

Per pose dimension the search range is

searchRange = ±sqrt(chiSquaredValue × variance)

where chiSquaredValue is determined by EstimationOptions::confidenceInterval and the 6 degrees of freedom of the pose. confidenceInterval controls how much of your uncertainty region to search, not how confident you are in the covariance values themselves.

Common values (Wilson–Hilferty approximation, 6 dof):

confidenceIntervalχ²
0.68~7.011σ
0.90~10.62default
0.95~12.572σ
0.99~16.83high confidence

Worked example. To search ±100 m along a camera-frame axis at 95% confidence (χ² ≈ 12.57), set the corresponding diagonal variance to

variance = 100² / 12.57 ≈ 795 m²   (≈ 28 m std. dev.)

Performance impact​

  • Larger variances → larger search → more hypotheses → longer runtime.
  • Smaller variances → faster, but the algorithm may fail to find the true pose if the prior is outside the searched region.
  • No covariance → single hypothesis, fastest; only safe when the prior is known to be accurate.

Further reference​