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.

BarometricFactor

Open In Colab

Overview

The BarometricFactor (contributed by Peter Milani in 2021) provides a way to incorporate altitude information derived from barometric pressure measurements into a GTSAM factor graph. It acts as a unary factor on a Pose3 state variable but also connects to a double variable representing a slowly varying atmospheric pressure bias (or equivalently, an altitude offset).

Barometers measure absolute atmospheric pressure. Under the assumption of a standard atmosphere model, this pressure can be converted into an estimate of altitude above sea level. However, local atmospheric pressure changes constantly due to weather, making the direct pressure-to-altitude conversion inaccurate over longer periods. The BarometricFactor accounts for this by simultaneously estimating the vehicle’s altitude (Z-component of the Pose3) and a bias term that absorbs the slow variations in local atmospheric pressure relative to the standard model.

Mathematical Formulation

Measurement Model

  1. Pressure to Altitude: The factor internally converts the input barometric pressure measurement PmeasP_{meas} (in kPa) to an altitude estimate hstdh_{std} (in meters) using a standard atmosphere model (approximated by the factor’s heightOut method, based on NASA GRC). This hstdh_{std} becomes the factor’s internal measurement nT_.

    hstd=heightOut(Pmeas)h_{std} = \text{heightOut}(P_{meas})
  2. Factor Error: The factor constrains the Z-component of the Pose3 variable’s translation (pzp_z) and the bias variable (bb). The error is the difference between the altitude predicted by the state and bias, and the altitude derived from the measurement:

    e=(pz+b)−hstde = (p_z + b) - h_{std}

    where:

    • pzp_z is the Z-coordinate of the Pose3 translation.

    • bb is the estimated altitude bias (in meters).

    • hstdh_{std} is the altitude calculated from the pressure measurement.

Bias Modeling

The bias bb is typically connected between successive time steps using a BetweenFactor<double> with a very small noise model, enforcing that the bias changes slowly over time (approximating a random walk).

Key Functionality / API

  • Constructor: BarometricFactor(poseKey, biasKey, baroIn_kPa, model): Creates the factor, taking the Pose3 key, the double bias key, the pressure measurement in kilopascals (kPa), and the 1D noise model for the altitude error.

  • evaluateError(pose, bias): Calculates the 1D error e=(pose.z()+bias)−hstde = (pose.z() + bias) - h_{std}.

  • measurementIn(): Returns the internally stored altitude measurement hstdh_{std} (converted from the input pressure).

  • heightOut(pressure_kPa): Converts pressure (kPa) to altitude (m) using the standard atmosphere model.

  • baroOut(altitude_m): Converts altitude (m) back to pressure (kPa) using the inverse model.

  • print / equals: Standard factor methods.

Usage Example

Assume we have a pressure reading and want to add a factor constraining a Pose3 and a bias.

Created BarometricFactor:
Barometric Factor on x0Barometric Bias on b0
  Baro measurement: 108.939
  noise model: unit (1) 

Internal altitude measurement: 108.94 m
Current Pose Z: 110.00 m
Current Bias: -1.50 m
Predicted Altitude (Pose Z + Bias): 108.50 m
Error (Predicted - Measured): -0.44 m