Go Down

### Topic: Guide to gyro and accelerometer with Arduino including Kalman filtering (Read 513574 times)previous topic - next topic

#### futureM

#360
##### Jan 10, 2013, 07:08 am
Hi Lauszus,

Like the many others, I got my IMU working by studying at lot of your hard work, just wanted you to know that I really appreciate it!
I have a question, with the project I'm working on - I need to filter out the accel data that is affecting the
Kalman output such as when the IMU is under accel in any of the 3 axis. For example while placing the IMU
on a rotating platform, the addition of of the X or Y accel vectors start to affect the roll
and pitch angles. What do you recommend to eliminate these bias errors for when the IMU is not stationary and under accel/decel?

-futureM

#### Lauszus

#361
##### Jan 10, 2013, 08:33 pm
@futureM
That's the whole purpose of the Kalman filter. If you are not satisfied with the performance as it is right now, then you have to tune the values.

#### triplenox

#362
##### Jan 15, 2013, 11:53 amLast Edit: Jan 15, 2013, 01:48 pm by triplenox Reason: 1
Hi Lauszus,

I'm working with the Quaternion Values getting from the DMP of the MPU6050. i've some problems to get a full 360° Range.
Maybe you have a hint to convert the DMP Quaternion Values to Degrees. Normally the calculation is based on the Sensitivity Scale Factor for both Gyro and Accel. I'm correct?
But i'm getting one fusion Value of the Gyro and Accel. So i don't now how to convert this to a 360° Range ....

Why do you not use the DMP Values like Quaternion?
Is it better to work with raw Vaules and Kalman Filter?

With atan2 i should get the 360°:
mpu.dmpGetQuaternion(&q, fifoBuffer);

but if i move the MPU6050 90° i get on the Serial only 70°

many Thanks!

#### Lauszus

#363
##### Jan 15, 2013, 05:50 pm
@triplenox
I have never used the DMP on the MPU-6050 before as I thought it were a bit overkill as I usually only need the angle in one of the axis.

You can't use atan2 or anything like that on Quaternions!

To use Quaternions see the following recourses:

• https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050

• http://www.i2cdevlib.com/devices/mpu6050#source

• http://www.x-io.co.uk/quaternions/

• http://www.x-io.co.uk/open-source-imu-and-ahrs-algorithms/

#### aziz-qessate_arduino

#364
##### Jan 19, 2013, 01:30 am
hello , i'm working on the same subject , and it's my first time i use the ARDUINO uno AND the IMU 6050s ,
i'm a beginner, now i try to finish the mechanical par ,
it'is possible to give my the full code, because it's a subject that i must give to the school , and the mechanical part it took a lot of time to built,
please i wayit for somewone to help my.
and thank you four your solidarity

#### Lauszus

#365
##### Jan 20, 2013, 02:33 pm
@aziz-qessate_arduino
Hi,

I can't write all the code for you, but for now take a look at this example code I wrote: https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/blob/master/IMU6DOF/MPU6050/MPU6050.ino

#### ezikiel12

#366
##### Jan 28, 2013, 01:42 am
So here's the issue I'm running into. I'm using Lauszus' code to try and set up a self stabilizing camera system. Although what I am finding is that the kalAngleX value is greatly effected by any acceleration in the z axis. If I shake the MPU6050 up and down the servo just goes crazy. When I hook it up to the bike the bumpiness of the road basically ruins it. I though that was the whole point of kalman filtering was to minimize this?

#### michinyon

#367
##### Jan 28, 2013, 01:27 pm
You have run into the fundamental problem,  that no scheme based on accelerometers can
distinguish between movement acceleration and gravity acceleration.

#### Lauszus

#368
##### Jan 28, 2013, 02:12 pm
@ezikiel12
You have to tune the Kalman filter. See my blog post on how to do so: http://blog.tkjelectronics.dk/2012/09/a-practical-approach-to-kalman-filter-and-how-to-implement-it/
The problem is that you are trusting the measurements from the accelerometer too much.

Or you could try to tune a complimentary filter to start with.

@michinyon
That's the whole point of the filter

#### mamette

#369
##### Jan 28, 2013, 02:33 pm
How if i connect IMU to my Arduino Board using I2C ? How to read and filter it?

#### Lauszus

#370
##### Jan 28, 2013, 02:37 pmLast Edit: Jan 28, 2013, 02:40 pm by Lauszus Reason: 1
See this code I wrote a while back: https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/blob/master/IMU6DOF/MPU6050/MPU6050.ino for the MPU6050

#### michinyon

#371
##### Jan 28, 2013, 05:59 pm
Quote
That's the whole point of the filter

Well no.  The whole point of the filter is dealing with noise.  The problem of distinguishing true acceleration from the effect of gravity on the sensor remains.  I've yet to see a convincing implementation of the Kalman filter approach which considers more than one dimension.

#### jjspierx

#372
##### Jan 28, 2013, 06:16 pm

Quote
That's the whole point of the filter

Well no.  The whole point of the filter is dealing with noise.  The problem of distinguishing true acceleration from the effect of gravity on the sensor remains.  I've yet to see a convincing implementation of the Kalman filter approach which considers more than one dimension.

You should look at the FreeIMU's implentation of MARG orientation fusion algorithm.  I am using a modified version of this and it seems to work well.

#### longlongvn

#373
##### Jan 28, 2013, 09:50 pm
@Lauszus
I'm working with an MPU6050 for my balancing robot project. But the model required yaw measurement. I wonder if the MPU6050 is capable of measure the yaw accurate enough or it needs additional magnetometer. Please help

#### jjspierx

#374
##### Jan 28, 2013, 10:17 pm

@Lauszus
I'm working with an MPU6050 for my balancing robot project. But the model required yaw measurement. I wonder if the MPU6050 is capable of measure the yaw accurate enough or it needs additional magnetometer. Please help

It can do short term yaw measurements just fine, but it drifts over time.  So if you just need to know incremental yaw measurements during yaw events it will work fine. However if you are using to it maintain a specific orientation for extended periods of time, it will not work well unless you integrate a magnetometer.

Go Up

Please enter a valid email to subscribe