Magnetometer

To simulate the measurements produced by a magnetometer, we resort to the same declination D, nclination I angles, and magnetic strength S pre-computed tables provided in PX4-SITL [MHP15], obtained from the World Magnetic Model (WMM) from 2018 [oC20].

Author: Marcelo Jacinto (marcelo.jacinto@tecnico.ulisboa.pt)
License: BSD-3-Clause. Copyright (c) 2023, Marcelo Jacinto. All rights reserved.
Description: Simulates a magnetometer. Based on the original implementation provided in PX4 stil_gazebo (https://github.com/PX4/PX4-SITL_gazebo) by Elia Tarasov

Classes:

Magnetometer

The class that implements a magnetometer sensor.

class pegasus.simulator.logic.sensors.magnetometer.Magnetometer

Bases: Sensor

The class that implements a magnetometer sensor. This class inherits the base class Sensor.

Methods:

__init__([config])

Initialize the Magnetometer class

update(state, dt)

Method that should be implemented by the class that inherits Sensor.

Attributes:

state

(dict) The 'state' of the sensor, i.e. the data produced by the sensor at any given point in time.

__init__(config={})

Initialize the Magnetometer class

Parameters:

config (dict) – A Dictionary that contains all the parameters for configuring the Magnetometer - it can be empty or only have some of the parameters used by the Magnetometer.

Examples

The dictionary default parameters are

>>> {"noise_density": 0.4e-3,           # gauss / sqrt(hz)
>>>  "random_walk": 6.4e-6,             # gauss * sqrt(hz)
>>>  "bias_correlation_time": 6.0e2,    # s
>>>  "update_rate": 250.0}              # Hz
update(state, dt)

Method that should be implemented by the class that inherits Sensor. This is where the actual implementation of the sensor should be performed.

Parameters:
  • state (State) – The current state of the vehicle.

  • dt (float) – The time elapsed between the previous and current function calls (s).

Returns:

(dict) A dictionary containing the current state of the sensor (the data produced by the sensor)

property state

(dict) The ‘state’ of the sensor, i.e. the data produced by the sensor at any given point in time