Unifying Sensor Fusion Code to Abstract Between Sensors And Fusion Algorithms #272

Closed
opened 2026-04-05 17:52:24 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @nekomona on 6/3/2023

The codes for 6/9-axis fusion in BMI160/MPU9250, the codes for linear acceleration extraction in BMIs/MPUs/ICMs, and the codes for DMP+MAG fusion in MPU9250 are all abstracted out and unified into the new SensorFusion classes.

After this modification, sensors with raw gyro/accel/mag data could use the SensorFusion base class to do all the fusion, including upcoming sensors. If some of these sensors also need rest detection to do dynamic calibration like the BMI160, they could use the SensorFusionRestDetect, which could take detection result from vqf or add additional detector to achieve that. MPUs using DMP have a separate class SensorFusionDMP, which abstracts the dmpmag algorithm and provides a similar interface to the raw SensorFusion class.

With the abstraction, it could be more straightforward to introduce new algorithms or new sensors. Besides, it enables the combination previously not written like MPU6050 + QMC5883L + VQF, and future sensors will have access to all algorithms automatically.

I have tested it with MPU6050+QMC5883L and BMI160+QMC5883L in 6/9-axis modes. ICM20948 is not tested but should do exactly the same as before, and no modification is made for BNOs as they do no fusions on the MCU.

*Originally created by @nekomona on 6/3/2023* The codes for 6/9-axis fusion in BMI160/MPU9250, the codes for linear acceleration extraction in BMIs/MPUs/ICMs, and the codes for DMP+MAG fusion in MPU9250 are all abstracted out and unified into the new `SensorFusion` classes. After this modification, sensors with raw gyro/accel/mag data could use the `SensorFusion` base class to do all the fusion, including upcoming sensors. If some of these sensors also need rest detection to do dynamic calibration like the BMI160, they could use the `SensorFusionRestDetect`, which could take detection result from vqf or add additional detector to achieve that. MPUs using DMP have a separate class `SensorFusionDMP`, which abstracts the dmpmag algorithm and provides a similar interface to the raw `SensorFusion` class. With the abstraction, it could be more straightforward to introduce new algorithms or new sensors. Besides, it enables the combination previously not written like *MPU6050 + QMC5883L + VQF*, and future sensors will have access to all algorithms automatically. I have tested it with *MPU6050+QMC5883L* and *BMI160+QMC5883L* in 6/9-axis modes. ICM20948 is not tested but should do exactly the same as before, and no modification is made for BNOs as they do no fusions on the MCU.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/SlimeVR-Tracker-ESP#272