Class GNSSMeasurements

Class Documentation

class GNSSMeasurements

Public Types

using VectorProvider = std::function<Vec3(Real)>
using CustomIonospherePlasmaDelayModel = std::function<Real(Real, const Vec3&, const Vec3&, GnssFreq)>
using BatchCustomIonospherePlasmaDelayModel = std::function<std::vector<std::vector<Real>>(const std::vector<Real>&, const std::vector<State>&, const std::vector<std::vector<GnssChannel>>&)>

Public Functions

GNSSMeasurements() = default
explicit GNSSMeasurements(Ptr<GnssConstellation> constellation)

Construct with a GNSS constellation to draw transmitter ephemerides/antennas/power from (see BuildChannelForPrn).

inline void SetConstellation(Ptr<GnssConstellation> constellation)

Set the GNSS constellation providing transmitter ephemerides, antennas, and transmit power for BuildChannels()/Compute().

inline Ptr<GnssConstellation> GetConstellation() const

Get the GNSS constellation currently in use.

inline void SetFrequency(GnssFreq frequency)

Set the GNSS frequency (e.g. L1/L2/L5) used for all channels built by BuildChannels().

inline GnssFreq GetFrequency() const

Get the GNSS frequency currently used for built channels.

inline void SetOptions(const GnssMeasurementOptions &options)

Replace the measurement options (observable selection, state layout, light-time/relativity/Shapiro/plasma settings, etc.) used by BuildChannels()/Compute().

inline const GnssMeasurementOptions &GetOptions() const

Get the measurement options currently in use.

inline void SetSunPositionProvider(VectorProvider provider)

Set the callback used by SunPosition() to get the Sun’s position at a given epoch (used for Shapiro delay and GNSS transmitter attitude/antenna-gain computations).

If unset, SunPosition() falls back to a fixed (0, AU, 0) placeholder.

inline void SetBoresightTargetProvider(VectorProvider provider)

Set the callback used by BoresightTarget() to get the receiver’s nadir/boresight-pointing target position (e.g. the Moon or Earth center), used by ComputeCN0() to evaluate the receiver antenna’s off-boresight angle to the transmitter.

inline void SetOccludingBodies(const std::vector<GnssOccludingBody> &bodies)

Set the spherical bodies (e.g. the Moon or Earth) checked for line-of-sight occlusion by BuildChannels() when options.apply_visibility is true (via ComputeVisibility()).

inline void SetReceiverParams(const GnssReceiverParams &params)

Set the receiver tracking-loop parameters (DLL/PLL/FLL bandwidths, integration time, etc.) used by ComputeSigmaRange(), ComputeSigmaRangeRate(), and ComputeSigmaCarrierPhase() to derive per-channel measurement noise sigmas from CN0.

inline void SetReceiverAntenna(const Antenna &antenna)

Set the receiver antenna gain pattern used by ComputeCN0() to evaluate G_rx in the link budget.

inline void SetCN0Threshold(Real cn0_threshold_dbhz)

Set the CN0 threshold [dB-Hz] below which a channel is dropped by BuildChannels() when options.apply_cn0_threshold is true.

inline void SetCustomIonospherePlasmaDelayModel(CustomIonospherePlasmaDelayModel model)

Set a custom per-channel ionosphere/plasma delay model, overriding the ray-trace and default-constant delay options.

If set, ComputeIonospherePlasmaDelay() calls this model instead of using ionosphere_plasma_raytrace_options_ or options_.default_ionosphere_plasma_delay_m, taking the receive time and receiver/transmitter ECI positions and returning the (dispersive) delay for a given GNSS frequency.

inline void SetBatchCustomIonospherePlasmaDelayModel(BatchCustomIonospherePlasmaDelayModel model)

Set a custom batch ionosphere/plasma delay model evaluated once per epoch for all channels, used by Precompute() instead of per-channel calls to ComputeIonospherePlasmaDelay() when options.apply_ionosphere_plasma_delay is true.

inline void SetIonospherePlasmaDelayProvider(CustomIonospherePlasmaDelayModel provider)

Deprecated alias for SetCustomIonospherePlasmaDelayModel().

inline void SetBatchIonospherePlasmaDelayProvider(BatchCustomIonospherePlasmaDelayModel provider)

Deprecated alias for SetBatchCustomIonospherePlasmaDelayModel().

inline void SetIonospherePlasmaRayTraceOptions(const GnssIonospherePlasmaRayTraceOptions &options)

Configure ray-traced ionosphere/plasma delay computation (used by ComputeIonospherePlasmaRayTraceDelay() via ComputeIonospherePlasmaDelay()) when no custom model is set.

inline void ClearIonospherePlasmaRayTraceOptions()

Disable ray-traced ionosphere/plasma delay computation, reverting ComputeIonospherePlasmaDelay() to the custom model (if any) or options_.default_ionosphere_plasma_delay_m.

std::vector<GnssChannel> BuildChannels(Real receive_time, const State &user_state) const

Build the set of visible, above-CN0-threshold GNSS channels for every PRN in the constellation at a receiver epoch/state.

This is the main entry point used by Compute()/Precompute() (and, via GnssMeasurement::Precompute, by truth/filter pipelines) to turn a receiver state into the list of GnssChannel transmitters that should contribute measurements at this epoch: for each non-faulted PRN it resolves the light-time-corrected transmitter state (BuildChannelForPrn), applies the visibility test (ComputeVisibility), computes CN0 (ComputeCN0) and drops channels below options_.cn0_threshold_dbhz if options_.apply_cn0_threshold is set, and fills in the per-channel measurement-noise sigmas.

Parameters:
  • receive_timeReceiver signal-reception epoch [s, options_.receive_time_scale]

  • user_stateReceiver state; must contain position/velocity at options_.indices.position/velocity [m, m/s] in options_.frame

Returns:

One GnssChannel per visible, sufficiently-strong transmitter

GNSSMeasurementsEpoch Compute(Real receive_time, const State &user_state, MatXd *H = nullptr) const

Build channels and compute the full GNSS measurement epoch (values, and optionally the Jacobian/covariance) for a receiver epoch/state.

This is the primary per-epoch API used by the EKF/UKF measurement update (directly or via CreateFunction()) and by GnssMeasurement::Precompute: it calls BuildChannels() to get the visible transmitters, then ComputeFromChannels() to evaluate each channel’s pseudorange/Doppler/carrier-phase observables.

Parameters:
  • receive_timeReceiver signal-reception epoch [s, options_.receive_time_scale]

  • user_stateReceiver state, as in BuildChannels()

  • H[out] If non-null, filled with the stacked measurement Jacobian (same as epoch.jacobian)

Returns:

GNSSMeasurementsEpoch containing the built channels, stacked measurement vector, Jacobian, and diagonal covariance

std::vector<GNSSMeasurementsEpoch> Precompute(const std::vector<Real> &receive_times, const std::vector<State> &user_states, bool compute_jacobians = false)

Compute and cache a GNSSMeasurementsEpoch for each of a series of receiver epochs/states.

Used to generate a full simulation-length sequence of GNSS measurement epochs (e.g. for truth-data generation ahead of a filter run). If options_.apply_ionosphere_plasma_delay is set and a batch custom ionosphere/plasma delay model has been installed (SetBatchCustomIonospherePlasmaDelayModel), channels for all epochs are built first (without per-channel delays), the batch model is evaluated once for all epochs/channels, and the resulting delays are applied before computing each epoch’s measurement values; otherwise each epoch is computed independently via Compute(). Results are also stored in precomputed_ (see GetPrecomputed()).

Parameters:
  • receive_timesReceiver signal-reception epochs [s, options_.receive_time_scale]

  • user_statesReceiver states, one-to-one with receive_times

  • compute_jacobians – If true, also compute and store each epoch’s measurement Jacobian

Returns:

One GNSSMeasurementsEpoch per receive_times entry

inline const std::vector<GNSSMeasurementsEpoch> &GetPrecomputed() const

Get the measurement epochs computed by the most recent Precompute() call.

FilterMeasurementFunction CreateFunction(Real t) const

Build a FilterMeasurementFunction that calls Compute() at a fixed receive time t.

The returned closure captures a copy of this GNSSMeasurements (constellation, options, antennas, providers, etc.) and is suitable for direct use as a filter’s measurement model at epoch t, returning the stacked measurement vector and (if requested) Jacobian/covariance for all visible channels.

Parameters:

tReceiver signal-reception epoch [s, options_.receive_time_scale]

Returns:

Function (x, H, R) -> y computing the full GNSS measurement epoch at t for receiver state x

Public Static Functions

static bool ComputeVisibility(const Vec3 &r1, const Vec3 &r2, Real R_body, const Vec3 &r_body = Vec3::Zero())

Line-of-sight visibility test between two points in a common frame, accounting for a spherical occluding body.

Used by BuildChannels() (when options.apply_visibility is true) to drop transmitter channels whose line of sight to the receiver is blocked by an occluding body (e.g. the Moon or Earth), or whose elevation from a surface point falls below a minimum elevation mask. Handles three cases: either endpoint near the occluding body’s surface (elevation-mask test) or both endpoints elevated (geometric horizon occlusion test).

Parameters:
  • r1 – First point [m], any common frame

  • r2 – Second point [m], same frame as r1

  • R_body – Radius of the occluding body [m]

  • r_body – Center of the occluding body [m], same frame as r1

Returns:

True if r1 and r2 have an unobstructed line of sight (subject to the elevation mask)