Search code examples
cembeddedmicrocontrollerkalman-filtersensor-fusion

Integer Based Sensor Fusion/Kalman Filter


Is anyone aware of a sensor fusion implementation that uses only integer operations instead of all the floating point accumulates/divides/multiplies in most open source implementations?

On my processor performing repeated floating point calculations are expensive and I want to reduce them as much as possible. I might lose some precision but my application does not require a highly precise output.

Is there any issue turning all the variables to ints and just taking the hit in precision? Any advice would be great, thanks all.


Solution

  • The use of fixed-point is the best solution for flexible maths operations on a device with no FPU.

    Anthony Williams' fixed point maths library would suit, it uses a 64 bit integer type to provide a 34Q28 (34 integer bits, 28 fractional bit) format floating point type with extensive maths, operator and conversion functions. It is written in C++ to create a fixed type as a class, with extensive operator overloading and standard maths functions so that it is largely inter-changeable with float or double in existing code.

    I realise the the question is tagged C but you need not use C++ syntax extensively, just compile your C code as C++, include the fixed.hpp header, replace float or double with fixed and compile/link the fixed.cpp file with your project.