0

I am trying to work out the appropriate tilt calculations for a 3 axis accelerometer, I have tried many formulas using atan or atan2. The obvious issue with atan is I only get values -90/+90. With atan2 I can get -180/+180 but when pitch or roll hits 90 the other value jumps to 180.

Atan2(y,sqrt(XX)+(zz)

Someone suggested to include a sign change to the sqrt if z was -ve or +ve but I still get the same effect on the pitch.

If I rely purely on my gyro it's accurate only for a few turns then drift kicks in.

The suggestion is to use quaternion as this provides better repsentation of the orientation addressing the singularities that orthogonal or Euler presents but I can't understand how to fabricate heading/pitch/roll in the first places to calculate C1/C2/C3.

Apologies if this is a really dumb question I have progressed quite far with my programming and understanding but now my study needs to be able to move past the 90 rotations.

If anyone has advice or a pointer to where I can find this as I may have saturated my google search parameters as it draws up the same pages regarding accelerometers.

  • What are C values? – Vasily Mitch Nov 01 '18 at 13:46
  • 1
    It's not very clear what the specific problem is. But I know that with Euler angles, $\pm 90$ degrees pitch is a big problem that immediately breaks the equations. You have to avoid it somehow. – Matti P. Nov 01 '18 at 13:48
  • From what I understand I should use my gyro and Accel for tilt orientation and the magnetometer for bearing. But the atan2 fomula gives erroneous readings when the device is roll -90/+90 or pitch -90/+90, I assume my equation must be wrong. – Ian Bloomfield Nov 01 '18 at 14:09
  • Roll = atan2( sqrt(YY + XX), Z) * 180/M_PI; Pitch = atan2( sqrt(XX + ZZ), Y) – Ian Bloomfield Nov 01 '18 at 14:12
  • w = c1 c2 c3 - s1 s2 s3 x = s1 s2 c3 +c1 c2 s3 y = s1 c2 c3 + c1 s2 s3 z = c1 s2 c3 - s1 c2 s3 where: c1 = cos(heading / 2) c2 = cos(attitude / 2) c3 = cos(bank / 2) s1 = sin(heading / 2) s2 = sin(attitude / 2) s3 = sin(bank / 2) – Ian Bloomfield Nov 01 '18 at 23:55
  • this is the quaternion calculation I had found most clear, but what I can't understand is if my accelerometer values are not giving me bank or attitude reliably >90 degrees I'm not sure how I can populate the quaternion? – Ian Bloomfield Nov 01 '18 at 23:56

0 Answers0