Sensor fusion combines data from different sensors to compute something that cannot be calculated from one sensor alone. MetaMotion boards run a Bosch sensor fusion algorithm that performs computations using BMI160 and BMM150 data in the firmware. When using the sensor fusion algorithm, it is important that you do not simultaneously use the Accelerometer, Gyro, and Magnetometer modules. Use the ISensorFusionBosch interface to configure the algorithm which in turn will appropriately configure the required sensors.
using MbientLab.MetaWear.Core; ISensorFusionBosch sensorFusion = metawear.GetModule<ISensorFusionBosch>();
There are 4 operation modes that use different combinations of the accelerometer, gyro, and magnetometer, enumerated by the Mode enum. This, along with the data ranges for the accelerometer and gyroscope are set with the Configure method.
|NDoF||Calculates absolute orientation from accelerometer, gyro, and magnetometer|
|IMUPlus||Calculates relative orientation in space from accelerometer and gyro data|
|Compass||Determines geographic direction from th Earth’s magnetic field|
|M4G||Similar to IMUPlus except rotation is detected with the magnetometer|
The data rate and sensors used by the algorithm differ on based on the selected mode.
using MbientLab.MetaWear.Core.SensorFusionBosch; // default settings is NDoF mode with +/-16g acc range and 2000dps gyro range sensorFusion.Configure();
The algorithm can compute quaternion values and Euler angles as well as separating acceleration sources into linear motion and gravity. Furthermore, it can use data from the other IMUs to correct the errors from the raw sensors. Note that the units and type casting of the sensor fusion data is different for each type of data.
using MbientLab.MetaWear.Data; // stream quaternion values from the board await sensorFusion.Quaternion.AddRouteAsync(source => source.Stream(data => Console.WriteLine("Quaternion = " + data.Value<Quaternion>())) );