Issues with quaternion rotation

Hi,
I have a IMU that returns the rotation in quaternions, but when running if I rotate the IMU yaw at 90° at right, in Unreal it reaches not more than 60°, at 90° at left the rotation is 180°.
Pitch and roll are wrong too: at 80° and more the vector rotates on himself.
In the IMU proprietary control program angles looks right, is this a sort of bug?
Thank you very much for your help.

Can you post the code where you are seeing this issue? Are you converting things to an FRotator or anything like that?

Unreal likes to use degrees rather than radians for everything, so likely you’re just missing a conversion somewhere.

AActor a* = GetOwner();
FQuat rot = FQuat();
rot.X = valuesentbysocket;
rot.Y = valuesentbysocket;
rot.Z = valuesentbysocket;
rot.W = valuesentbysocket;

 a->SetActorRotation(rot);

Thanks!

And what units are those values in? Radians or degrees?

In radians

Hmm, if the IMU is sending the values as radians you could try something like this:

FRotator rotator;
rotator.pitch = RadiansToDegrees(PitchValueFromSocket);
rotator.yaw = RadiansToDegrees(YawValueFromSocket);
rotator.roll = RadiansToDegrees(RollValueFromSocket);

a->SetActorRotation(FQuat(rotator));

Another thing to be aware of is that in UE, Z is “up”, X is “forward”, and Y is “right”. So if your IMU is sending you an rotation geared towards a specific orientation - you’ll need to convert that.

Yes, but I don’t have pitch/yaw/roll, I have the XYZW components of a quaternion (where W is the real part and X,Y,Z are the imaginary parts).
How can I convert those values ìn yaw-pitch-roll values?
Thank you!

FQuat rot(xValue, yValue, zValue, wValue);

FRotator rotator = rot.Rotator(); // This will convert your quat to a Pitch/Yaw/Roll values in degrees, so you can debug exactly what values you are seeing.

Thanks, I’ll try!