'INS positioning attitude update with quaternions gives wrong direction solution

I'm trying to calculate position with accelerometer and gyroscope data I get from the phone. In this calculation I am using quaternations for attitude update but the calculated point coordinates are going left rather than right. So actually, if I take the symmetric right side, I will get the correct values.

Calculation results:

image

Arrow shows the North direction. The actual route to go is shown in red.

The formula I used is as follows:

T_s = sampling period
w = refers to gyro values.
q_k = updated attitude

enter image description here

The yaw angle, which should be referenced for the left deflection, is 355 degrees, but as I mentioned before, it turns to the right with this angle. I couldn't figure out where the problem came from, can you help?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source