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.

GPSFactor Family

Open In Colab

Overview

The GPSFactor family provides factors for incorporating Global Positioning System (GPS) measurements into a GTSAM factor graph. GPS typically provides measurements of position in Latitude/Longitude/Height. These GPS factors, however, assume the GPS measurement has been converted into a local Cartesian navigation frame (e.g., ENU, NED, or ECEF).

Different variants exist to handle:

  • State type: Pose3 or NavState.

  • Lever arm: Whether the GPS antenna is offset from the body frame origin.

  • Calibration: Whether the lever arm itself is being estimated.

Factor Variants

For Pose3 states:

  • GPSFactor:

    • Connects to: Pose3 key.

    • Assumes: Zero lever arm (GPS measurement corresponds directly to the Pose3 origin).

    • Measurement: 3D position (Point3) in the navigation frame.

    • Error: ppose−pmeasuredp_{pose} - p_{measured}

  • GPSFactorArm:

    • Connects to: Pose3 key.

    • Assumes: Known, fixed lever arm (bL vector in the body frame).

    • Measurement: 3D position (Point3) in the navigation frame.

    • Error: (ppose+Rnb⋅bL)−pmeasured(p_{pose} + R_{nb} \cdot bL) - p_{measured}

  • GPSFactorArmCalib:

    • Connects to: Pose3 key, Point3 key (for the lever arm).

    • Assumes: Lever arm (bL) is unknown and estimated.

    • Measurement: 3D position (Point3) in the navigation frame.

    • Error: (ppose+Rnb⋅bLestimated)−pmeasured(p_{pose} + R_{nb} \cdot bL_{estimated}) - p_{measured}

For NavState states:

  • GPSFactor2: Like GPSFactor but connects to a NavState key.

  • GPSFactor2Arm: Like GPSFactorArm but connects to a NavState key.

  • GPSFactor2ArmCalib: Like GPSFactorArmCalib but connects to a NavState key and a Point3 lever arm key.

(The ‘2’ suffix historically denoted factors using NavState).

Mathematical Formulation (GPSFactorArm Example)

Let:

  • Tnb=(Rnb,pnb)T_{nb} = (R_{nb}, p_{nb}) be the Pose3 state (body frame bb in navigation frame nn).

  • LbL_b be the known lever arm vector from the body origin to the GPS antenna, expressed in the body frame.

  • pgpsp_{gps} be the measured GPS position in the navigation frame.

The predicted position of the GPS antenna in the navigation frame is:

pant,pred=pnb+Rnb⋅Lbp_{ant, pred} = p_{nb} + R_{nb} \cdot L_b

The factor’s 3D error vector is the difference between the predicted antenna position and the measured GPS position:

e=pant,pred−pgpse = p_{ant, pred} - p_{gps}

The noise model reflects the uncertainty of the pgpsp_{gps} measurement in the navigation frame.

Key Functionality / API (Common Patterns)

  • Constructor: Takes the relevant key(s), the measured Point3 position gpsIn (in nav frame), the noise model, and potentially the leverArm (Point3 in body frame).

  • evaluateError(...): Calculates the 3D error vector based on the connected state variable(s) and the measurement.

  • measurementIn(): Returns the stored Point3 measurement.

  • leverArm() (For Arm variants): Returns the stored Point3 lever arm.

Usage Example (GPSFactor and GPSFactorArm)

Assume we have a GPS reading converted to a local ENU frame.

Created GPSFactor (zero lever arm):
GPSFactor on x0
  GPS measurement: 10.5
20.2
 5.1
  noise model: diagonal sigmas [0.5; 0.5; 1];

GPSFactor Error: [-0.5 -0.2 -0.1]

Created GPSFactorArm:
GPSFactorArm on x0
  GPS measurement: 10.5 20.2  5.1
  Lever arm: -0.1    0 0.05
  noise model: diagonal sigmas [0.5; 0.5; 1];

GPSFactorArm Error: [-0.6  -0.2  -0.05]
 ( Pose:       [10. 20.  5.] )
 ( Lever Arm:  [-0.1   0.    0.05] )
 ( Predicted Antenna Pos:  [ 9.9  20.    5.05] )
 ( Measured GPS Pos:     [10.5 20.2  5.1] )

Created GPSFactorArmCalib:
GPSFactorArmCalib on x0
  GPS measurement: 10.5 20.2  5.1
  noise model: diagonal sigmas [0.5; 0.5; 1];

Coordinate Frames

It’s crucial to ensure consistency in coordinate frames:

  • GPS Measurement (gpsIn): Must be provided in the chosen local Cartesian navigation frame (e.g., ENU, NED).

  • Lever Arm (leverArm): Must be provided in the body frame.

  • Pose/NavState Variables: Represent the pose of the body frame in the navigation frame (TnbT_{nb}).