Skip to content

Class inertialsim::sensors::Magnetometer

ClassList > inertialsim > sensors > Magnetometer

Simulate magnetometer sensors. More...

  • #include <magnetometer.h>

Inherits the following classes: inertialsim::sensors::Sensor

Public Functions

Type Name
Magnetometer (const MagnetometerModel & model, const MagnetometerSpecification & specification, std::optional< uint64_t > seed=std::nullopt, SimulationMode mode=SimulationMode::BATCH, std::optional< double > max_duration=std::nullopt)
Construct a Magnetometer from a model and specification.
MagnetometerData Simulate (const geometry::Vector & magnetic_field, const std::optional< Scalar1D > & temperature=std::nullopt)
Simulate magnetometer measurements from magnetic field.
MagnetometerData Simulate (const geometry::Vector & magnetic_field, const geometry::Rotation & attitude, const std::optional< Scalar1D > & temperature=std::nullopt)
Simulate magnetometer measurements from magnetic field and attitude.
MagnetometerData Simulate (const geodesy::GlobalPose & global_pose, const geodesy::MagneticDatum & datum, std::optional< double > date=std::nullopt, const std::optional< Scalar1D > & temperature=std::nullopt)
Simulate magnetometer measurements from global pose.
~Magnetometer () override

Public Functions inherited from inertialsim::sensors::Sensor

See inertialsim::sensors::Sensor

Type Name
Sensor (const SensorModel & model, const SensorSpecification & specification, std::optional< uint64_t > seed=std::nullopt, SimulationMode mode=SimulationMode::BATCH, std::optional< double > max_duration=std::nullopt)
Construct a Sensor .
virtual const SensorModel & model () const
Get the sensor model.
const std::mt19937_64 & rng () const
Get the rng generator.
virtual const SensorSpecification & specification () const
Get the sensor specification.
virtual SensorState & state ()
Get the sensor state.
virtual const SensorState & state () const
virtual ~Sensor () = default

Public Static Functions inherited from inertialsim::sensors::Sensor

See inertialsim::sensors::Sensor

Type Name
Array ApplyQuantization (const Array & signal, const SpecificationArray & quantization)
Apply quantization to a signal.

Detailed Description

A magnetometer is a "device to measure the magnetic field strength of the earth in three orthogonal directions." [Standard 03].

All inputs are reduced to a magnetic field model in sensor coordinates and sources of error from the magnetometer specification are then applied to produce the measurement outputs.

Public Functions Documentation

function Magnetometer

Construct a Magnetometer from a model and specification.

inertialsim::sensors::Magnetometer::Magnetometer (
    const  MagnetometerModel & model,
    const  MagnetometerSpecification & specification,
    std::optional< uint64_t > seed=std::nullopt,
    SimulationMode mode=SimulationMode::BATCH,
    std::optional< double > max_duration=std::nullopt
) 

Magnetometers require a model which specifies which sources of error to simulate; a specification which includes the parameters necessary to model deterministic and random errors; and optionally a random number generator seed to control determinism and repeatability of the simulation.

Two modes are supported: BATCH (default) and REAL_TIME. In BATCH mode, the Simulate() method should be called once with all inputs to return all simulated measurement outputs. In REAL_TIME mode, the Simulate() method can be called repeatedly to incrementally simulate measurements. In REAL_TIME mode, a max_duration input (specified in seconds) should supply an upper bound on the expected simulation duration. If the expected duration is unknown it is safe and efficient to specify a value up to several hours.

Parameters:

  • model Magnetometer model options specifying error sources.
  • specification Magnetometer specification with error parameters.
  • seed Random number generator seed (nullopt for random, 0 for deterministic default).
  • mode Simulation mode: BATCH (default) or REAL_TIME.
  • max_duration Maximum simulation duration in seconds (required for REAL_TIME mode).

function Simulate [1/3]

Simulate magnetometer measurements from magnetic field.

MagnetometerData inertialsim::sensors::Magnetometer::Simulate (
    const  geometry::Vector & magnetic_field,
    const std::optional< Scalar1D > & temperature=std::nullopt
) 

The input must be the magnetic field experienced by the sensor as measured in sensor coordinates.

Sources of error from the magnetometer specification are applied to produce the measurement output.

The temperature input is optional. If included, it will be used in combination with any temperature dependent specifications when simulating measurement outputs.

Parameters:

  • magnetic_field Magnetic field experienced by the magnetometer, measured in sensor coordinates. Must include time data.
  • temperature Optional array of temperatures corresponding to the magnetic field inputs (degrees C).

Returns:

MagnetometerData with simulated magnetic field measurements.


function Simulate [2/3]

Simulate magnetometer measurements from magnetic field and attitude.

MagnetometerData inertialsim::sensors::Magnetometer::Simulate (
    const  geometry::Vector & magnetic_field,
    const  geometry::Rotation & attitude,
    const std::optional< Scalar1D > & temperature=std::nullopt
) 

The magnetic field input must be the magnetic field experienced by the sensor in world (navigation) coordinates. The magnetic field may be a single fixed vector or an array of vectors of the same dimension as the attitude.

The attitude input must be the attitude (orientation) of the sensor frame relative to the world (navigation) frame. The attitude rotation transforms the magnetic field from world frame to sensor coordinates.

Sources of error from the magnetometer specification are applied to produce the measurement output.

The temperature input is optional. If included, it will be used in combination with any temperature dependent specifications when simulating measurement outputs.

Parameters:

  • magnetic_field Magnetic field experienced by the magnetometer, measured in world (navigation) coordinates.
  • attitude Attitude (orientation) of the sensor frame relative to the world (navigation) frame. Must include time data.
  • temperature Optional array of temperatures corresponding to the inputs (degrees C).

Returns:

MagnetometerData with simulated magnetic field measurements.

Exception:

  • std::invalid_argument if attitude has no time.

function Simulate [3/3]

Simulate magnetometer measurements from global pose.

MagnetometerData inertialsim::sensors::Magnetometer::Simulate (
    const  geodesy::GlobalPose & global_pose,
    const  geodesy::MagneticDatum & datum,
    std::optional< double > date=std::nullopt,
    const std::optional< Scalar1D > & temperature=std::nullopt
) 

The global pose input must be the pose (position and orientation) of the sensor relative to Earth. Earth's core magnetic field will be simulated using the World Magnetic Model specified in the datum at the given date and pose.

The date must be a decimal year (e.g., 2025.67). If not supplied, the epoch of the datum will be used as a default (e.g., 2025.0 for WMM2025).

The pose must use Earth-referenced coordinates (GEODETIC, ECEF, or TOPOCENTRIC), not LOCAL or INERTIAL frames.

Sources of error from the magnetometer specification are applied to produce the measurement output.

The temperature input is optional. If included, it will be used in combination with any temperature dependent specifications when simulating measurement outputs.

Parameters:

  • global_pose Pose (position and orientation) of the magnetometer relative to Earth. Must include time data.
  • datum Magnetic datum for the World Magnetic Model.
  • date Date as decimal year (e.g., 2025.5). If not provided, uses the default epoch for the datum.
  • temperature Optional array of temperatures corresponding to the pose inputs (degrees C).

Returns:

MagnetometerData with simulated magnetic field measurements.

Exception:

  • std::invalid_argument if global_pose has no time.
  • std::invalid_argument if navigation frame is LOCAL or INERTIAL.

function ~Magnetometer

inertialsim::sensors::Magnetometer::~Magnetometer () override


The documentation for this class was generated from the following file cpp/include/inertialsim/sensors/magnetometer.h