i have a "simple" (i think) problem that's making me troubles finding the right solution.
I have a device on my right wrist with a RH coordinate system (z down) that gives me a Quaternion with his current local orientation and linear accelerations values. From these values i have to create a vector of Accelerations with Gravity.
Coordinate system: Link
(Device and Smartwatch's coordinate systems matches.)
Final values needs to be compared with Smartwatch's values on the same wrist.
I found an easy and working solution to this problem that is: i take the Quaternion of my device's orientation, i rotate the gravity vector (0,0,10) in this position and then add the gravity vector to my Linear acceleration vector.
To add it i converted my quaternion to a Rotation matrix as follows:
1 - 2*(qy^2 + qz^2) 2*(qx*qy + qz*qw) 2*(qx*qz - qy*qw)
2*(qx*qy - qz*qw) 1 - 2*(qx^2 + qz^2) 2*(qy*qz + qx*qw)
2*(qx*qz + qy*qw) 2*(qy*qz - qx*qw) 1 - 2*(qx2 + qy2)
And then i did a matrix multiplication with my g vector.
Problem is if i stand still my device measures an acceleration with gravity vector like this:
(10, -2, 0.5)
while the Smartwatch measues:
(10, 2, -0.5)
I am pretty sure there is a fix for this signs missmatch in my rotation matrix, but i can't find it... Can you help me? Or how can i get the right Rotation matrix from my Quaternion? On the web there are tons of variations of this conversion.
I found this one that doesn't give me an error where other convertions do: while X-Axe is pointing downwards (standing still with the hand on my leg) i measure [10,0,0] if then i roll (X-Axe Rotation) 90 deg. clockwise the Acceleration with gravity vector changes to [0,10,0], like if my X-Axe and Y-Axe were replacing each others, but in fact X-Axe is the only one facing down even if i rotate my wirst.