Magnetometer Overview

The magnetometer measures the intensity of the magnetic field around the camera in microteslas (μT). The magnetometer determines the orientation of the earth magnetic field which gives the absolute orientation of the camera according to the north magnetic pole.

Output Data

The following information is accessible from the camera sensor stack:

Output Data Description Units
Magnetometer (50 Hz)
magnetic_field_uncalibrated Ambient geomagnetic field for all three physical axes (x, y, z) in μT. Values are uncalibrated. μT

Using the API

The magnetometer measures the intensity of the magnetic fields around the camera. By measuring the earth’s magnetic field, the sensor can estimate the camera’s absolute orientation according to the north magnetic pole.

Magnetometer values are stored in the SensorData::MagnetometerData which can be accessed with:

SensorsData sensors_data;
SensorsData::MagnetometerData magnetometer_data;

// Grab new frames and retrieve sensors data
while(zed.grab() == SUCCESS){
  zed.getSensorsData(sensors_data, TIME_REFERENCE::IMAGE); // Retrieve only frame synchronized data

  // Extract magnetometer data
  magnetometer_data = sensors_data.magnetometer;

  // Retrieve magnetic field
  float3 magnetic_field = magnetometer_data.magnetic_field_uncalibrated;
}
sensors_data = sl.SensorsData()
magnetometer_data = sl.SensorsData.MagnetometerData()

# Grab new frames and retrieve sensors data
while zed.grab() == sl.ERROR_CODE.SUCCESS :
  zed.get_sensors_data(sensors_data, sl.TIME_REFERENCE.IMAGE) # Retrieve only frame synchronized data

  # Extract magnetometer data
  magnetometer_data = sensors_data.magnetometer

  # Retrieve magnetic field
  magnetic_field = magnetometer_data.magnetic_field_uncalibrated;
SensorsData sensors_data = new SensorsData();
MagnetometerData magnetometer_data = new MagnetometerData();

RuntimeParameters runtimeParameters = new RuntimeParameters();
// Grab new frames and retrieve sensors data
while(zed.Grab(ref runtimeParameters) == ERROR_CODE.SUCCESS){
  zed.GetInternalSensorsData(sensors_data, TIME_REFERENCE.IMAGE); // Retrieve only frame synchronized data

  // Extract magnetometer data
  magnetometer_data = sensors_data.magnetometer;

  // Retrieve magnetic field
  float3 magnetic_field = magnetometer_data.magneticFieldUncalibrated;
}

Note: At the moment, magnetometer data is provided uncalibrated. Measurements might be distorted due to hard and soft iron biases, but they can be corrected with user-side magnetometer calibration.

Code Example

For code example, check out the Getting Sensor Data tutorial.