xioTechnologies/Fusion

Make FusionCalibration and FusionMath functions available in Python

Closed this issue · 2 comments

The exported CPython library doesn't allow access to the FusionMath nor FusionCalibration functions. So I can't do something like the advanced C examples that are calibrating gyro and accel inputs.

imufusion does not implement functions from FusionMath.h because this functionality is already provided by numpy. The code below shows how to implement the inertial and magnetic calibration models using numpy.

def inertial(uncalibrated, misalignment, sensitivity, offset):
    return (numpy.matrix(misalignment) * numpy.diag(sensitivity) * numpy.array([uncalibrated - offset]).T).A1

def magnetic(uncalibrated, soft_iron_matrix, hard_iron_offset):
    return (numpy.matrix(soft_iron_matrix) * numpy.array([uncalibrated]).T).A1 - hard_iron_offset

Ah, I see, thanks!