Download

Quaternion Axis flips / Gimbal problems

I am streaming data into unreal from an inertial sensor. It outputs UnNormalized quaternion data in the format:



 X = 6561.00000
 Y = 6691.00000
 Z = 2118.00000
 W = 2078.00000

I am applying this to an actor, in c++, using:


 this->SetActorRelativeRotation(rotsQ);

And it gives me strange gimbal issues.

When i rotate pitch 90 degrees, it rotates in Pitch.

I rotate 90 degrees in Yaw.

When i rotate pitch 90 degrees, it rotates in Roll.

I have tried Converting it to a FRotator and flipping axes, applying axes one at a time and switching the rotation order. I have tried setting the Actor to 0,0,0 every tick then adding the rotation value. No matter what I do, I see the same thing. Any help here would be very much appreciated!

Could it be a handedness problem? What can i try here?

I notice you are setting the relative rotation. Is their a reason you are not setting the world rotation? Can you make a video showing the behavior?

@<a href=“https://forums.unrealengine.com/member.php?u=28286” target="_blank">antithing</a>: i do not know you method, but i had that problem too and found the quite undocumented Quaternion multiplication function in c++ which is the Blueprint fmethod COmpose Rotators.

Try this if you have not done before:

Get the original Component Rotation as a Rotationmatrix and the new one to ADD and multiply it with Quaternion Multiplication:
Warning: Order matters, it is always original Rotation * Added value here, i do not know why but it gives you weired results if you do not use it this way.

I spin Tankwheels with this… not sure if this helps, but this it what i got:

https://www.youtube.com/watch?v=I3s1-YO-yTg

I spin the wheels and sprocket with this method correctly, whatever position in the world the tank has.

Please let me know, if this works for you.

The object is in a hierarchy, so the rotation must be relative.
I have a mostly working fix, by negating the x and y values of the quaternion. Thanks!