Skip to content

Unable to get raw accelerometer data after calculating quaternion #39

@lannerxiii

Description

@lannerxiii

Hello, I am facing a problem getting raw accelerometer data. I need to substract the gravity from my raw accel data,so I am calculating my quaternions with DPM. My code is the following

  float q0 = imu.calcQuat(imu.qw);
  float q1 = imu.calcQuat(imu.qx);
  float q2 = imu.calcQuat(imu.qy);
  float q3 = imu.calcQuat(imu.qz);

  Serial.println("Q: " + String(q0, 4) + ", " + String(q1, 4) + ", " + String(q2, 4) + ", " + String(q3, 4));
  float g0,g1,g2 = 0;

  g0 = 2 * (q1 * q3 - q0 * q2);
  g1 = 2 * (q0 * q1 - q2 * q3);
  g2 = q0 * q0 - q1 * q1 - q2 * q2 + q3 * q3;

  ax =  imu.calcAccel(imu.ay);
  ay =  imu.calcAccel(imu.ay);
  az =  imu.calcAccel(imu.az);

  cax =  (9.8 * ax - g0);
  cay =  (9.8 * ay - g1);
  caz =  (9.8 * az - g2);
  Serial.println("A: " + String(g0, 4) + ", " + String(g1, 4) + ", " + String(g2, 4) );

Im using the DPM Quaternion example and made those modifications, but my ax, ay and Az values are zero. The main loop it's exactly the one from the example, I only removed the call to computeEulerAngles() because I do not need it. I think Im not understanding exactly how to get the raw data, because the basic example is different, also I know understand that the dpm code utilizes a FIFO Buffer to store the data. I need to get the raw AY,AY and AZ values that were used to calculate the quaternion. Am I doing something wrong?

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions