I was trying to compare methods of Quaternion differentiation for propagating quaternion values over time for a body undergoing rotation, but am getting some strange results for some of the differentiation schemes.
The problem at hand is: Starting with an initial quaternion orientation, a body undergoes constant angular velocity over a time period deltat. I want to solve for the new orientation after undergoing the rotation during deltat.
I was able to find 2 competing alternatives that I was hoping to pit against each other:
Standard Euler Integration: Quaternion Differentiation
Euler Integration with quaternion composition:How to use the quaternion derivative
I am using the following quaternion for the test:
q=[-0.8628 0.1753 0.2406 0.4085]
under the following conditions:
deltat=0.5
w=1e-3*[0 0.7003 -0.6825 -0.5632] = [wr, wx, wy, wz]
I first calculate the standard euler integration as such:
omega=[0,-wx,-wy,-wz;
wx 0 wz -wy;
wy -wz 0 -wx;
wz wy -wx 0];
standard_integrated=q+1/2*omega*q*deltat
I then calculate the equivalent rotation using:
qdot=exp(1/2*w*deltat)
composition_integrated=quatmultiply(q,qdot)
I then check for disparities between calculations using:
quatdisparity=standard_integrated*composition_integrated
where quatdisparity should be close to -1 or 1 if the end quaternions are similar.
The end results are:
standard_integrated=[-0.8628 0.1751 0.2407 0.4087]
composition_integrated=[-1.6872 -0.8556 -0.3888 -0.5196]
quatdisparity=.9999
The problem seems to entirely be in the quaternion composition. composition_integrated is not a quaternion, and when one normalizes it to be a valid quaternion, quatdisparity drops to approximately 0.5
Is the quaternion composition formula valid? It clearly cannot produce valid quaternions if 1/2*w*deltat has any positive components. I would expect something like the standard formulation, where the new quaternion is very close to the original. In the quaternion composition formulation, qdot is also not a quaternion, and is very close to a 4x1 array of ones. Is this second formulation wrong?
(1+1/2*w*deltat)*q
, accordingly the second variant should beexp(1/2*w*deltat)*q
, that isqdot*q
, quaternions do not commute. In the disparity, you should take the conjugate in one factor. – Lutz Lehmann Jun 05 '21 at 06:47omega
has some sign errors. Computing withnumpy-quaternion
gives very close results in both cases, with the matching digits being[-0.862732, 0.1751131, 0.2406510, 0.4086935]
. Are you sure the exponential you used is a quaternion exponential? – Lutz Lehmann Jun 05 '21 at 07:37