How to populate C values for quaternion

48 Views Asked by At

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.