Inertial Sensors
Overview
The glasses include inertial sensors managed through M2SensorsService (accessed from Evs.sensorsService):
| Sensor | Description |
|---|---|
| Gyroscope | Measures orientation and angular velocity |
| Magnetometer | Measures changes in the Earth's magnetic field |
| Accelerometer | Measures acceleration |
The raw inertial sensor base rate is 204 Hz. The quaternion (fused) base rate matches the display refresh at ~67 Hz.
All inertial sensors are disabled by default when the glasses are turned on.
The inertial sensors are also the foundation for the Line of Sight (LOS) augmented reality system, which uses the fused quaternion data to anchor virtual content to real-world positions.
Sensor Data
Using the SDK, the sensors can be enabled and consumed in the following ways:
| Type | Description |
|---|---|
| Base Sensors | The sensor x,y,z values are corrected according to the glasses calibration parameters |
| Fused (Composite) | All sensors are fused and the SDK supplies the calibrated Quaternion information |
Sensor Rates
The sensors rate is configurable:
| Rate | Quaternion Hz | Description |
|---|---|---|
SensorsRate.Slow |
1 Hz | Low power |
SensorsRate.Normal |
2 Hz | Default |
SensorsRate.Medium |
4 Hz | Moderate |
SensorsRate.Fast |
33 Hz | High rate |
SensorsRate.VeryFast |
66 Hz | Full display-rate (matches on-board LOS) |
Coordinate System
The sensors axes follow the standard right-hand coordinate system aligned with the glasses frame.
Sensors Rate and Rendering Rate
When the inertial sensors are active, they are capturing data at the requested SensorsRate.
To optimize the usage of the Bluetooth channel, the collected sensor information is sent from the glasses to the SDK in batches at the requested rendering interval.
As a result, when you register for sensor events, the event will be triggered before the rendering cycle, and it may be called multiple times to report each of the collected sensor data within the batch.
Base Sensors
In order to receive calibrated sensors you should:
- Register for the required sensor callbacks
- Enable the required sensors via
Evs.sensorsService.enableInertialSensors(rate)
Measurement units:
| Sensor | Units | Description |
|---|---|---|
| Accelerometer | m/s² | meter/(second²) |
| Magnetometer | mGauss | milli-Gauss |
| Gyroscope | rad/s | radians/seconds |
Don't forget to disable the sensor and to unregister the events when they are not required.
Fused (Composite)
The fused sensors provide orientation as a quaternion (M2Quaternion).
In order to receive the fused sensors information you should:
- Register to
IM2SensorsEventsfor quaternion events - Enable the sensors fusion via
Evs.sensorsService.enableInertialSensors(rate)
Enabling the sensors fusion will enable the glasses Gyroscope, Magnetometer, Accelerometer and will start the fusion algorithm process.
Quaternion Example
Evs.sensorsService.registerListener(object : IM2SensorsEvents {
override fun onQuaternion(
timestampMs: Long,
quaternion: M2Quaternion,
calibrationState: M2ImuCalibrationState
) {
val w = quaternion.w
val x = quaternion.x
val y = quaternion.y
val z = quaternion.z
}
})
Evs.sensorsService.enableInertialSensors(SensorsRate.Normal)
class QuaternionHandler: IM2SensorsEvents {
func onQuaternion(
timestampMs: Int64,
quaternion: M2Quaternion,
calibrationState: M2ImuCalibrationState
) {
let w = quaternion.w
let x = quaternion.x
let y = quaternion.y
let z = quaternion.z
}
}
Evs.shared.sensorsService.registerListener(listener: QuaternionHandler())
Evs.shared.sensorsService.enableInertialSensors(rate: .normal)
Cleanup
Don't forget to disable the sensor fusion and to unregister the events when they are not required:
Sensor Calibration
The inertial sensors report their calibration state via M2ImuCalibrationState. Monitor it through the quaternion callback to know when calibration is needed:
Evs.sensorsService.registerListener(object : IM2SensorsEvents {
override fun onQuaternion(
timestampMs: Long,
quaternion: M2Quaternion,
calibrationState: M2ImuCalibrationState
) {
when (calibrationState) {
M2ImuCalibrationState.Ok -> { /* sensors calibrated */ }
M2ImuCalibrationState.Calibrating -> { /* calibration in progress */ }
M2ImuCalibrationState.Required -> { /* calibration needed - prompt user */ }
M2ImuCalibrationState.Unknown -> { /* state not yet determined */ }
}
}
})
class CalibrationMonitor: IM2SensorsEvents {
func onQuaternion(
timestampMs: Int64,
quaternion: M2Quaternion,
calibrationState: M2ImuCalibrationState
) {
switch calibrationState {
case .ok:
break // sensors calibrated
case .calibrating:
break // calibration in progress
case .required:
break // calibration needed - prompt user
default:
break
}
}
}
Evs.shared.sensorsService.registerListener(listener: CalibrationMonitor())
See Also
- Line of Sight Overview - AR features built on inertial sensors
- Glasses - Device info, battery, and system events
- Communication - BLE connection and data exchange