rbv188 / IMU-algorithm

Sensor fusion algorithm to determine roll and pitch in 6-DOF IMUs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Algorithm problem

ethan42411 opened this issue · comments

Sorry,
I have a qustion about algorithm in the IMU-algorithm-master.ino.
I don't know, why the wx, wy, wz they are gx, gy, gz multiply by 0.0005323?

Thanks.

Sorry, I have a qustion about algorithm in the IMU-algorithm-master.ino. I don't know, why the wx, wy, wz they are gx, gy, gz multiply by 0.0005323?

Thanks.

Hello @ethan42411 and @rbv188
This is strange converted RAW gyro to rad/sec

gyro_scale = 32768;
0.0174533f; // PI / 180
gyro_x *= gyro_scale  * 0.0005323 / 1000

My math also comes out strange, but this is the only way I could justify this coefficient chosen by the author.
In general, I'm looking for another thing in the code - how to change the direction of the gyroscope and accelerometer axes so that the roll and pitch angles are adequate.
I use lsm303dlh and l3gd20 sensors.
I feed the angular velocity into the filter in rad/sec, acceleration as is, in its raw form (as the author did in the code), without scaling to 1G or 9.81 m/s/s.
Code for output:

  Serial.print("A ");
  Serial.print(int(angles.roll));
  Serial.print(" ");
  Serial.print(int(angles.pitch));
  Serial.print(" ");
  Serial.println(int(angles.yaw));

The angles that the filter produces are as follows:

A  R  P  Y
A 176 2  0
A 156 13 0
A 123 34 0
A 180 0  0

Yaw doesn't work, we need to figure it out.
Judging by the lack of answers for more than 3 years, the author abandoned his work ... and this is very sad!
I rewrote the code a little for C++, changed the variables in the fast square root function so that the Arduino compiler assembles the code into a program.
I don’t know how to include in the code of my version, I’ll just attach an archive with code for Arduino in C++.
IMU_algorithm_С++.zip
https://forum.arduino.cc/t/algorithm-problem/1189504