Jump to content

Magnetometer

From VR & AR Wiki

A magnetometer is an instrument that measures the strength and direction of a magnetic field, and in consumer electronics it is most often used to sense the Earth's magnetic field so a device can work out which way it is facing. A magnetometer reports the field as three values along the X, Y and Z axes, which together describe the magnetic vector passing through the sensor.[1] Because the field points toward magnetic north, the sensor acts as an electronic compass and gives an absolute heading reference, meaning a direction that is fixed relative to the world rather than measured from where the device started.

In virtual reality and augmented reality hardware, the magnetometer is one of the motion sensors packed into the IMU (inertial measurement unit). Its main job there is to help with rotational tracking of head-mounted displays and input devices by providing a north reference that the other sensors cannot supply on their own.

What it measures

The Earth's magnetic field at the surface is weak, roughly 25 to 65 microtesla depending on location, and the magnetometer measures the part of that field along each of its three axes.[2] From those three readings the device can compute a compass heading. Unlike a gyroscope, which only senses how fast the device is turning, or an accelerometer, which senses gravity and acceleration, the magnetometer is the only common sensor that points to something fixed in the outside world. That is what makes it valuable for correcting the slow errors that build up in the other sensors.

MEMS magnetometers

The magnetometers in headsets, phones and controllers are tiny MEMS (micro-electro-mechanical systems) chips, the same class of part as the accelerometer and gyroscope they sit next to. Two sensing approaches are common. Hall-effect sensors produce a voltage when placed in a magnetic field perpendicular to the sensor, and the voltage is proportional to the field strength, which is then read out as a value in teslas; this is the most widely used type in smartphones and tablets.[1] Anisotropic magnetoresistive (AMR) sensors are an alternative whose electrical resistance changes with the surrounding field, offering good sensitivity and temperature stability.[1] A complete part contains three such sensors arranged on perpendicular axes so it can read the full X, Y and Z field vector in one small package.[1]

Role inside a 9-axis IMU

A basic IMU combines an accelerometer and a gyroscope. When a magnetometer is added, the unit becomes a 9-axis IMU, three axes each of acceleration, rotation and magnetic field.[3] The reason the magnetometer is wanted is yaw drift. A gyroscope tracks orientation by adding up tiny rotation measurements, and small errors in each measurement accumulate over time, so the reported heading slowly slides away from the true one. The accelerometer can fix tilt errors in pitch and roll because it always knows where "down" is from gravity, but gravity points straight down and so carries no information about heading; it cannot correct rotation about the vertical (yaw) axis.[4]

The magnetometer fills that gap. Because it senses magnetic north, it supplies an absolute yaw reference that a sensor fusion filter blends with the gyroscope to pull heading back into line. The original Oculus Rift, for example, stored a magnetometer reading together with the estimated orientation as a reference point, then compared later readings against it and fed the difference back through a complementary filter so the correction was gradual and imperceptible to the wearer.[5] Without this kind of correction, a user who spun around in place could find that virtual north and real north no longer matched.[6]

Interference and calibration

The magnetometer's weakness is that it measures the sum of every magnetic field reaching the sensor, not just the Earth's. Anything ferromagnetic or any live electric circuit nearby adds its own field to the reading.[5] Inside a headset or controller the circuit boards, batteries, speakers, motors and metal parts all contribute, and the surrounding room adds more from furniture, steel framing, appliances and electronics.

These distortions fall into two kinds. Hard iron effects come from permanent magnets or magnetized metal in the device and add a constant offset to each axis. Soft iron effects come from materials that do not produce a field of their own but bend whatever field passes through them, and they vary with the orientation of the device.[4] If a clean magnetometer were rotated through every direction its readings would trace a sphere; hard and soft iron warp that sphere into an offset, squashed ellipsoid. Calibration corrects this by collecting readings while the device is turned in many directions, fitting an ellipsoid to the data, and then using the fit to offset, scale and rotate the raw output back toward a true sphere.[4] Early Oculus Rift development kits exposed this directly, asking the user to press a key to calibrate the magnetometer in the demo software.[6]

Why some VR devices omit or de-weight it

Indoor use is the hardest case for a magnetometer because the magnetic environment is cluttered and inconsistent, and a fixed calibration done in one spot does not hold as the user moves through a room full of metal and electronics. For this reason some VR designers deliberately leave the magnetometer out of the heading solution or give it little weight. Ceva, a maker of sensor-fusion technology, advises that it is "not recommended to use a magnetometer as your method to determine the absolute orientation of the headset or controllers" because magnetic interference is hard to verify against ground truth, and instead recommends 6-axis sensors (accelerometer plus gyroscope) "to avoid these issues at the cost of heading drift over time."[3] In that approach the system accepts a slow heading drift rather than trust an unreliable compass.

Modern VR controllers and headsets that track position optically sidestep the problem by getting their absolute reference from cameras rather than from magnetic north. The Oculus Touch controllers, for instance, are tracked through a ring of infrared LEDs seen by cameras, not by a magnetometer.[7] Oculus even chose not to put magnets in the shipping Touch controllers after finding that users could feel the two controllers pulling toward each other.[8] Headsets with inside-out tracking likewise lean on their cameras for a world-fixed reference, which reduces how much they need to rely on the magnetometer for heading.

References