golpesar132
Posts: 6
Joined: Wed Dec 13, 2017 11:12 am

mpu6050 with kalman filter

Sat Jan 27, 2018 5:31 pm

is there any mpu6050 with kalman code in C/C++ for RPi? I found some codes for mpu6050 without kalman filter and all of them have wrong outputs. can any one help me???

User avatar
bitbank
Posts: 248
Joined: Sat Nov 07, 2015 8:01 am
Location: Sarasota, Florida
Contact: Website

Re: mpu6050 with kalman filter

Tue Jan 30, 2018 5:15 pm

Your question is worded in a way which implies "please give me a working solution for my problem". What have you tried? What wrong values are you seeing? Are you reading the accelerometer or gyroscope? I've written a simple C library which can read the accel/gyro values from a MPU6050:

https://github.com/bitbank2/accelerometers

It's up to you to take that output and send it through a Kalman filter. If you find someone else doing the exact same work as you and they shared their code, great. Otherwise, like most projects, you'll need to gather the available info and write the code.
The fastest code is none at all :)

danjperron
Posts: 2977
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: mpu6050 with kalman filter

Tue Jan 30, 2018 5:54 pm

This will be easy to implement on the Raspberry PI.

Already in C++

https://github.com/TKJElectronics/KalmanFilter

1dot0
Posts: 430
Joined: Mon Nov 28, 2016 12:31 pm

Re: mpu6050 with kalman filter

Tue Jan 30, 2018 6:29 pm

danjperron wrote:
Tue Jan 30, 2018 5:54 pm
This will be easy to implement on the Raspberry PI.

Already in C++

https://github.com/TKJElectronics/KalmanFilter
that is an Arduino lib, I 'm not sure if it will work for the Pi out of the box, but maybe....

danjperron
Posts: 2977
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: mpu6050 with kalman filter

Tue Jan 30, 2018 8:40 pm

that is an Arduino lib
So what ?

it's c++. If you look at the class by itself it's pure c++. It won't matter if it is an arduino or an intel I9.

And the MPU6050 example will be quite simple to adapt for the raspberry Pi.

Find yourself a good mpu6050 implementation.

I did make one a couple of years ago.

https://github.com/danjperron/mpu6050TestInC

BBUK
Posts: 133
Joined: Tue Dec 18, 2012 10:34 am

Re: mpu6050 with kalman filter

Wed Feb 07, 2018 2:16 pm

Have a look at this file in one of my repos https://github.com/BBUK/Bell-Boy/blob/m ... b_dcmimu.c. Specifically the calculate function. This implements an EKF from https://github.com/hhyyti/dcm-imu with what I found to be really stunning results for my use case. It is not for the MPU6050 (it uses another IMU) but the calculate function can accept inputs from anywhere, you just need to supply it with gyro measurements (in degrees/sec) and accelerometer measurements (in g) and a time interval (in seconds). Outputs are roll, pitch and yaw in degrees.

The file is WIP and is for a project that I am only going to properly release in a couple of months so the file may change (but the calculate function won't - I absolutely don't understand what magic it performs!).

Have fun

BBUK

BBUK
Posts: 133
Joined: Tue Dec 18, 2012 10:34 am

Re: mpu6050 with kalman filter

Wed Mar 28, 2018 4:28 pm

Just a little follow up to anyone that is trying to click the link I posted above - it won't work and the solution has developed.

The released version of the code combines the data from two MPU6050s and pushes that to an extended Kalman filter. The main part of the code is now in the "grabber.c" file in the grabber directory. In case anyone finds it useful, that directory also has some code that undertakes accelerometer calibration "MPU6050_calibrate.c".

Repository is here: https://github.com/BBUK/Bell-Boy

Have fun

BBUK

Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 5 guests