Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gyro data is not reflected #113

Open
ArusTaimika opened this issue May 8, 2024 · 1 comment
Open

Gyro data is not reflected #113

ArusTaimika opened this issue May 8, 2024 · 1 comment

Comments

@ArusTaimika
Copy link

We are trying to estimate the attitude using the IMU of the Madgwick filter.
However, the gyro data is not reflected and the attitude estimation is wrong.
The code used is as follows.
Graphs of the acquired acceleration, gyro, and estimated attitude are also attached.
Can you tell what is causing this?
If it is my mistake, I really apologize.

q = ahrs.filters.Madgwick(gyr = np.array([g]),acc = np.array([a]))
qq= ahrs.common.Quaternion(q.Q[0])
self.euler = qq.to_angles()
acc_gyr_euler

@Mayitzin
Copy link
Owner

Hi, can you share more of your code? What I can see is the following:

  • You estimate all orientations as Quaternions from a set of gyroscope measurements (all stored in g) and accelerometers (all stored in a)
  • q is the Madgwick object, whose estimated quaternions are stored in Q.

From here only 1 quaternion is used:

  • qq is the first estimated quaternion only (Q[0]) stored as a single Quaternion object.
  • From this Quaternion object (corresponding to the first quaternion only) you get the Euler angles using its method to_angles().

My questions are:

  • After you estimate all quaternions with Madgwick, what do you do with the rest?
  • Is the call to self.euler = qq.to_angles() performed more than once?
  • If so, consider updating it, as you are calling it all the time with the same quaternion (Q[0])
  • The class QuaternionArray could be useful to simplify and accelerate your estimations. It is used similarly.
    madgwick = ahrs.filters.Madgwick(gyr=np.array(all_gyro_samples), acc=np.array(all_acc_samples))
    QQ = ahrs.QuaternionArray(madgwick.Q)
    euler_angles = QQ.to_angles()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants