SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By khatarat
#105009
hi
i want to implement kalman filter for extract euler angles from data of gyro accelerometer and magnetometer.
i have road lots of papers about kalman filter but because of im not english and much math and Probability i cant understand kalman filter.
can u help me for implementing kalman filter?its very important for me.
By sebmadgwick
#105024
The Kalman filter is by no means the best solution for the fusion of gyroscope, magnetometer and/or accelerometer data. There are other simpler, more efficient, and maybe even more accurate algorithms for the job.

My report details the derivation of my contribution; provides source code; and details the methods and results of the evaluation and benchmarking of my algorithm against the Kalman based algorithm of a leading off-the-shelf product.

Download from: http://code.google.com/p/imumargalgorithm30042010sohm/

If you don’t like my algorithm, the dozens of cited alternatives within my report should provide an adequate choice.
By khatarat
#105064
sebmadgwick wrote:The Kalman filter is by no means the best solution for the fusion of gyroscope, magnetometer and/or accelerometer data. There are other simpler, more efficient, and maybe even more accurate algorithms for the job.

My report details the derivation of my contribution; provides source code; and details the methods and results of the evaluation and benchmarking of my algorithm against the Kalman based algorithm of a leading off-the-shelf product.

Download from: http://code.google.com/p/imumargalgorithm30042010sohm/

If you don’t like my algorithm, the dozens of cited alternatives within my report should provide an adequate choice.
if kalman filter is not the best way for combining data of gyro , accelerometer and magnetometer ,why all companies that create imu with gyro accelerometer and magnetometer use kalman filter?like memsense.com.
By socoj2
#105069
khatarat wrote:
sebmadgwick wrote:The Kalman filter is by no means the best solution for the fusion of gyroscope, magnetometer and/or accelerometer data. There are other simpler, more efficient, and maybe even more accurate algorithms for the job.

My report details the derivation of my contribution; provides source code; and details the methods and results of the evaluation and benchmarking of my algorithm against the Kalman based algorithm of a leading off-the-shelf product.

Download from: http://code.google.com/p/imumargalgorithm30042010sohm/

If you don’t like my algorithm, the dozens of cited alternatives within my report should provide an adequate choice.
if kalman filter is not the best way for combining data of gyro , accelerometer and magnetometer ,why all companies that create imu with gyro accelerometer and magnetometer use kalman filter?like memsense.com.
because its the most common...
By socoj2
#105070
sebmadgwick wrote:The Kalman filter is by no means the best solution for the fusion of gyroscope, magnetometer and/or accelerometer data. There are other simpler, more efficient, and maybe even more accurate algorithms for the job.

My report details the derivation of my contribution; provides source code; and details the methods and results of the evaluation and benchmarking of my algorithm against the Kalman based algorithm of a leading off-the-shelf product.

Download from: http://code.google.com/p/imumargalgorithm30042010sohm/

If you don’t like my algorithm, the dozens of cited alternatives within my report should provide an adequate choice.
That is a Crazy paper man... props on that one.
By khatarat
#105072
sebmadgwick wrote:The Kalman filter is by no means the best solution for the fusion of gyroscope, magnetometer and/or accelerometer data. There are other simpler, more efficient, and maybe even more accurate algorithms for the job.

My report details the derivation of my contribution; provides source code; and details the methods and results of the evaluation and benchmarking of my algorithm against the Kalman based algorithm of a leading off-the-shelf product.

Download from: http://code.google.com/p/imumargalgorithm30042010sohm/

If you don’t like my algorithm, the dozens of cited alternatives within my report should provide an adequate choice.
the paper of your project is very difficult for me to understand.can u write a simple one?

in videos the real time demonstrations filtered object has a little shake.i think kalman filter doesnt has this shake.

after see two videos from imu and MARG i thought that what different between IMU and MARG? both of them can give us pitch rool and yaw what is the reson of use magnetometer?
By socoj2
#105078
khatarat wrote:
sebmadgwick wrote:The Kalman filter is by no means the best solution for the fusion of gyroscope, magnetometer and/or accelerometer data. There are other simpler, more efficient, and maybe even more accurate algorithms for the job.

My report details the derivation of my contribution; provides source code; and details the methods and results of the evaluation and benchmarking of my algorithm against the Kalman based algorithm of a leading off-the-shelf product.

Download from: http://code.google.com/p/imumargalgorithm30042010sohm/

If you don’t like my algorithm, the dozens of cited alternatives within my report should provide an adequate choice.
the paper of your project is very difficult for me to understand.can u write a simple one?

in videos the real time demonstrations filtered object has a little shake.i think kalman filter doesnt has this shake.

after see two videos from imu and MARG i thought that what different between IMU and MARG? both of them can give us pitch rool and yaw what is the reson of use magnetometer?
If you have a problem reading his paper then implementing a Kalman is above the level of your skills.
By khatarat
#105092
if it possible tell me about variables and constants and how i can calcute them?
Code: Select all

#define deltat 0.001f // sampling period in seconds (shown as 1 ms)
#define gyroMeasError 3.14159265358979 * (5.0f / 180.0f) // gyroscope measurement error in rad/s (shown as 5 deg/s)
#define gyroMeasDrift 3.14159265358979 * (0.2f / 180.0f) // gyroscope measurement error in rad/s/s (shown as 0.2f deg/s/s)
#define beta sqrt(3.0f / 4.0f) * gyroMeasError // compute beta
#define zeta sqrt(3.0f / 4.0f) * gyroMeasDrift // compute zeta
// Global system variables
float a_x, a_y, a_z; // accelerometer measurements
float w_x, w_y, w_z; // gyroscope measurements in rad/s
float m_x, m_y, m_z; // magnetometer measurements
float SEq_1 = 1, SEq_2 = 0, SEq_3 = 0, SEq_4 = 0; // estimated orientation quaternion elements with initial conditions
float b_x = 1, b_z = 0; // reference direction of flux in earth frame
float w_bx = 0, w_by = 0, w_bz = 0; // estimate gyroscope biases error

for example what is the gyroMeasDrift and how can i calcute it?i think the algorithm should calk this.
By khatarat
#105108
i want to know what are this variables exactly and how can i calculate it?
gyroMeasError
gyroMeasDrift

and other variables
By sebmadgwick
#105110
khatarat wrote:if kalman filter is not the best way for combining data of gyro... why all companies that create imu with gyro accelerometer and magnetometer use kalman filter?
The justification of my statement are the presented results, report content, and within the cited literature.
khatarat wrote:the paper of your project is very difficult for me to understand.can u write a simple one?
I am sorry if you are having difficulties interrupting my report. Re-writing a simpler report would result in the same report but with basic introductions to geometry, non-linear programming and control theory. If you have any specific questions, I will be happy to answer.
The source code in the appendix should make the algorithm useable even with no understanding of the underlying processes.
I would tend to agree with socoj2; that this is of an equal or lower level of complexity than that of a Kalman or Extended-Kalman fitler.
khatarat wrote:both of them can give us pitch rool and yaw what is the reson of use magnetometer?
The titles in each videos explain that the IMU is susceptible to integral drift in yaw whereas the MARG is not.
khatarat wrote:i want to know what are this variables exactly and how can i calculate it? ...and other variables
gyroMeasError and gyroMeasDrift are the real-world characteristic that may be directly related to the filter gains beta and zeta. See section 3.6. As I say in the report these parameters will, in practise, have to be estimated; i.e. tuned, ad Hoc.
Other variables have suitable names and comments when declared. Again: I will be happy to answer and specific questions.
By khatarat
#105114
sebmadgwick wrote: gyroMeasError and gyroMeasDrift are the real-world characteristic that may be directly related to the filter gains beta and zeta. See section 3.6. As I say in the report these parameters will, in practise, have to be estimated; i.e. tuned, ad Hoc.
Other variables have suitable names and comments when declared. Again: I will be happy to answer and specific questions.
apologize me but if it possible explain more about this two variables and also beta and zeta. are this variables has a constant value and can i use values in your program?
By sebmadgwick
#105118
khatarat wrote:...possible explain more about this two variables and also beta and zeta.
I will summarise the algorithm and explain beta’s role:

The filter uses a quaternion to represent orientation. Gyroscope data is represented as the rate of change of a quaternion which, when integrated, provides the estimated orientation of the sensor array. However, this estimate alone will drift over time and so must be ‘corrected’.

The accelerometer and magnetometer provide measurements of the earth’s gravitational and magnetic fields (respectively) which may be compared to the expected measurements of each field (according to the estimated orientation of the sensor array) to compute an error. Using non-linear programming methods, this error can be used to compute a vector in quaternion space that defines the required ‘corrective step’ that must be taken to reduce the error in the quaternion describing the estimated orientation . If this vector is normalised to a unit vector then it may be multiplied by a gain (beta) that defines the rate of ‘correction’ or the ‘rate of convergence’.

If the rate of convergence (beta) is too great then the filter output will be ‘noisy’ as it tries to track all accelerometer and magnetometer data; but if the rate of convergence is too small integral drift may take hold. Therefore an optimal value of beta may be defined as that which ensures the rate of convergence due to the ‘corrective step’ is equal to the rate of divergence due to integral drift. The divergence due to integral drift is the the gyroscope measurement error (gyroMeasError). The units of beta are defined as the ‘magnitude of the rate of change of quaternion’, the units of gyroMeasError are degrees per second; therefore a simple conversion is required (section 3.6 of report).
khatarat wrote:... can i use values in your program?
I recommend using zeta=0 initially on the condition that you observe gyroscope bias drift as being negligible. Once you have a beta value that provides suitable convergences, then tune a zeta value to suitable tackle your gyroscope bias drift.