Answer the question
In order to leave comments, you need to log in
Getting smooth quaternion from direction cosine matrix?
Good afternoon dear community!
Faced a problem:
1. I work in Matlab/Simulink. I have a block of inertial sensors - a gyroscope, an accelerometer, a compass.
2. From the angular velocities in the bound coordinate system, by integrating the Poisson equation, I obtain the quaternion of rotation of the local coordinate system relative to the global one.
3. According to the data of the accelerometer and magnetometer, by vector multiplication, I get the projections of the orts of the global coordinate system onto the local one. I compose a matrix of direction cosines, I turn the matrix into a quaternion.
4. As a result, I have 2 quaternions, one of them is smooth (from the gyroscope), but with a floating zero. The quaternion from the axel and compass is noisy, but it knows exactly where the global system was.
5. Next, I calculate the mismatch quaternion between these two quaternions and obtain from it the angular velocities to correct the gyroscope data so that its data tends to data from the accelerometer and compass.
6. Quaternions, if they are considered as a tool for rotating a vector around an axis, are equivalent. That is, if I rotate a unit vector with these two quaternions, then it rotates the same way in both cases. With a difference only in the nature of rotation (trembling, drifting away of zero).
But if we consider them as a vector of 4 elements, then the quaternion, which is obtained by transformation from the matrix, is not equal to the quaternion from the gyroscope in the entire domain of definition. It has discontinuities caused by the matrix to quaternion conversion algorithm. And the scalar part never goes into negative values, because it turns out by extracting the square root:
Since two quaternions correspond to the same rotation, then at certain moments (when the quaternion from the gyroscope has a scalar goes into minus) it jumps from one value to another . For rotation, this does not matter, but if we want to compare two quaternions to create a control action, then a problem arises.
The top graph is a quaternion from a gyroscope.
The lower one is from the accelerometer and compass.
They are identical in terms of rotation, but the bottom one does not have a scalar below zero (yellow line), and so the rest of the components jump.
How can I get from the projections of the axes of one coordinate system onto another a smooth quaternion of the mismatch of these two systems? Is there any way to avoid using matrix to quaternion conversion?
I did not find the answer in the fundamental works of Branz and Shmygalevsky. Maybe on Habré someone will tell you.
Thanks in advance for your advice!
PS: Settled down to write my own function crutch . Perhaps this is the only solution.
I tried to be as detailed as possible, but I can clarify the problem if necessary.
Answer the question
In order to leave comments, you need to log in
suddenly help
avs.chat.ru/sphere3d.htm
it seems to me that the problem is in step 3
If I don’t confuse anything, then the transformation A[Rotation Matrix] -> [Quaternion] -> B[Rotation Matrix]: A !=B
Also, if the calculation of the inverse matrix is used somewhere, then it is necessary to check the correctness of this function.
For example, in DirectX D3DX, the calculation of the inverse matrix does not work correctly for all values. I took the implementation from the nVidia SDK
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question