10DOF FreeIMU port for FreeIMU v4 board and GY-86. This library was modified extensively to specifically suit the Mbed platform. Used threads and interrupts to achieve async mode.

Dependencies:   HMC58X3 AK8963 MS561101BA MODI2C MPU9250

Dependents:   MTQuadControl FreeIMU_serial FreeIMU_demo

Port of FreeIMU library from Arduino to Mbed

10DOF FreeIMU port for FreeIMU v4 board and GY-86. This library was modified extensively to specifically suit the Mbed platform. Maximum sampling rate of 500hz can be achieved using this library.

Improvements

Sensor fusion algorithm fast initialization

This library implements the ARHS hot start algorithm, meaning that you can get accurate readings seconds after the algorithm is started, much faster than the Arduino version, where outputs slowly converge to the correct value in about a minute.

Caching

Sensors are read at their maximum output rates. Read values are cached hence multiple consecutive queries will not cause multiple reads.

Fully async

Acc & Gyro reads are performed via timer interrupts. Magnetometer and barometer are read by RTOS thread. No interfering with main program logic.

Usage

Declare a global FreeIMU object like the one below. There should only be one FreeIMU instance existing at a time.

#include "mbed.h"
#include "FreeIMU.h"
FreeIMU imu;

int main(){
    imu.init(true);
}

Then, anywhere in the code, you may call imu.getQ(q) to get the quarternion, where q is an array of 4 floats representing the quarternion structure.

You are recommended to call getQ frequently to keep the filter updated. However, the frequency should not exceed 500hz to avoid redundant calculation. One way to do this is by using the RtosTimer:

void getIMUdata(void const *);     //method definition

//in main
RtosTimer IMUTimer(getIMUdata, osTimerPeriodic, (void *)NULL);
IMUTimer.start(2);     //1 / 2ms = 500hz

//getIMUdata function
void getIMUdata(void const *dummy){
    imu.getQ(NULL);
}

Changes

RevisionDateWhoCommit message
29:484a501b8674 2018-04-18 tyftyftyf change to I2C 1 default tip
28:de24fce0509a 2018-03-29 tyftyftyf parameter tuning
27:d1042e848b07 2018-03-29 tyftyftyf wip
26:0ca554a1b39a 2018-03-28 tyftyftyf jhgfdsa
25:0e71a244dde1 2018-03-28 tyftyftyf calibrate
24:dc802ce22e75 2018-03-28 tyftyftyf wip
23:c32831f2b234 2018-03-28 tyftyftyf wip
22:c2810d91ab11 2018-03-28 tyftyftyf wip
21:1b22e19f4ec6 2018-03-28 tyftyftyf fix build error
20:a2edd3ced80e 2018-03-28 tyftyftyf wip
19:de9da9b46a5e 2018-03-28 tyftyftyf wip
18:3f4803a943d3 2018-03-28 tyftyftyf wip
17:faefcafc8822 2018-03-07 tyftyftyf test
16:ec4300068695 2014-09-24 tyftyftyf Allow starting and stopping MPU6050 sampling (credits to joe4465)
15:ea86489d606b 2014-09-18 joe4465 Moved _sampling into header file under private
14:2e61e49cc3f5 2014-09-18 joe4465 Added ability to pause MPU6050 sampling and to get gyro rate.
13:21b275eeeda2 2014-09-18 joe4465 Same as MPU6050
12:2ceb5950ee44 2014-02-10 tyftyftyf (none)
11:b8f894e7d9d8 2014-02-10 tyftyftyf (none)
10:4e8ac6acd336 2014-02-10 tyftyftyf Updated MODI2C
9:a79af1283446 2014-01-10 tyftyftyf Tuning parameters
8:cd43764b9623 2013-12-23 tyftyftyf (none)
7:248255b21c2e 2013-12-23 tyftyftyf (none)
6:6b1185b32814 2013-12-23 tyftyftyf Bug fixes
5:80c9e84751cd 2013-11-29 tyftyftyf (none)
4:773bd4e605eb 2013-11-09 tyftyftyf Adds custom I2C library.
3:f9b100a9aa65 2013-11-09 tyftyftyf Implemented async mode. 1/10 the previous round time. Capable of sampling at 1Khz. +/- 0.05 deg accuracy
2:5c419926dcd7 2013-11-05 tyftyftyf Sensor fusion algorithm cold start
1:794e9cdbc2a0 2013-11-05 tyftyftyf (none)
0:21840c01d3d7 2013-11-02 tyftyftyf Initial commit