BjarneBitscrambler / OrientationSensorFusion-ESP

Files for performing orientation sensor fusion using NXP version 7 algorithm, ported to Espressif platforms.
BSD 3-Clause "New" or "Revised" License
23 stars 12 forks source link

Reduce SV_xxxx structs to SV_COMMON #14

Closed BjarneBitscrambler closed 3 years ago

BjarneBitscrambler commented 3 years ago

The fusion code has 7 different algorithms (with various combinations of accel, gyro, and magnetometer sensors, plus complexity). Each algorithm deposits its results in its own struct, named on the pattern SV_xxxx (e.g. SV_6DOF_GB_BASIC).

All these structs are part of the sensor fusion global sfg object. We could decrease memory used by creating a union of these structs and access them through a SV_COMMON struct. This might also reduce the number of conditional compilation #ifdef - #endif code blocks.

BjarneBitscrambler commented 3 years ago

Only used structs are instantiated; the rest are only declared. Memory use is decreased simply by not using any of the lower-order fusion algorithms, which was accomplished by using the #defines in build.h to turn off all except the 9DOF algorithm.

If one wanted to use all the algorithms, while still saving some memory, then it might be worthwhile combining the structs into one. This would, however, preclude running all the algorithms in parallel.