cesium-unreal
cesium-unreal copied to clipboard
InaccurateTransformRotatorEastNorthUpToUnreal broken?
Hey,
We recently upgrade to 1.8.1 and it seems InaccurateTransformRotatorEastNorthUpToUnreal no longer returns what I'm used to.
I tried
FRotator A = FRotator(0, 90, 0);
FRotator B =
CesiumGeoreference->InaccurateTransformRotatorEastNorthUpToUnreal(A, {0, 0, 0});
FRotator C =
CesiumGeoreference->InaccurateTransformRotatorUnrealToEastNorthUp(B, {0, 0, 0});
FRotator D = FRotator(inverse.ToQuat() * A.Quaternion());
UE_LOG(LogTemp, Warning, TEXT("CesiumGeoreference origin at: %f,%f,%f"),
CesiumGeoreference->OriginLatitude, CesiumGeoreference->OriginLongitude,
CesiumGeoreference->OriginHeight);
UE_LOG(LogTemp, Warning,
TEXT("RPY: %f,%f,%f -> %f,%f,%f -> %f,%f,%f Mine: %f,%f,%f"), A.Roll, A.Pitch, A.Yaw,
B.Roll, B.Pitch, B.Yaw, C.Roll, C.Pitch, C.Yaw, D.Roll, D.Pitch, D.Yaw);
And I get:
CesiumGeoreference origin at: 48.858372,2.294486,549.033264
RPY: 0.000000,0.000000,90.000000 -> 90.000008,0.000000,0.000000 -> 0.000000,-90.000008,0.000000
I'm not sure what the output is supposed to be, but the fact that EastNorthUpToUnreal then UnrealToEastNorthUp doesn't give me the original input seems wrong.
Any idea what's going on?
Thanks
@julien443 we're taking a look at this. It's all a bit crazy because Unreal's FRotator uses a weird convention (Roll is clockwise when looking down +X, and Pitch is clockwise when looking down +Y, but Yaw is counter-clockwise when looking down +Z), and when we go between ENU and Unreal we're going between a left-handed and a right-handed system. All of which is to say it's not obvious to me what this method is even meant to be doing (though it's also clear that whatever it's meant to do, it's not doing it correctly).
Maybe it would help to discuss a bit what problem you're trying to solve with it, and that might help us either see how to fix it to meet those expectations, or suggest an alternative approach.
Hi,
In my case I have some real world pose (location + orientation) and I want to either put the camera there, or place an object at this location. For example, I want to put an object in front of a wall and look at it. I need to set the orientation property for my object to be properly aligned with the wall. And I need to set the camera orientation property for it to look at this wall.
In my mind, this "InaccurateTransformRotatorEastNorthUpToUnreal" would take "something" and convert that into a FRotator I can pass unreal to have my object/camera properly oriented. This input "something" is supposed to represent the rotation from the local ENU space to the object space. I don't know if a FRotator is the best representation for it, or if we should have another object with roll/pitch/yaw as well but better defined in ENU space, or maybe a quaternion, or whatever.
Thanks @julien443, that makes sense. I think maybe take a look at InaccurateComputeEastNorthUpToUnreal. It's used in GlobeAwareDefaultPawn to solve a similar problem to the one you've described:
https://github.com/CesiumGS/cesium-unreal/blob/36a25c58235ae70de371ec39f9edd3c94c3ad097/Source/CesiumRuntime/Private/GlobeAwareDefaultPawn.cpp#L73
In that function, localRotation is an FRotator describing an orientation in a local ENU system (really East-South-Up because Unreal is left-handed). The comment just above where I linked describes the meaning of yaw/pitch/roll in this context. this->GetPawnViewLocation() is the origin of that system in Unreal world coordinates (if you have longitude/latitude/height, use InaccurateTransformLongitudeLatitudeHeightToUnreal to get the equivalent Unreal coordinates). InaccurateComputeEastNorthUpToUnreal returns an FMatrix that can be pre-multiplied with the local rotation from ESU to find the equivalent rotation in Unreal world coordinates. And then it converts that back to an FRotator that can be used to set an Actor's orientation, for example.
Let me know if that hits the mark.
Hey
Sorry for the delay.
If you want to use East-South-Up, I would rename the functions :)
Are you saying I should use 'InaccurateComputeEastNorthUpToUnreal' instead and 'InaccurateTransformRotatorEastNorthUpToUnreal' is broken and will not be fixed? I still think 'InaccurateTransformRotatorEastNorthUpToUnreal is broken because InaccurateTransformRotatorEastNorthUpToUnreal(InaccurateTransformRotatorUnrealToEastNorthUp(XXX)) != XXX
Right now, I copied the old implementation of 'InaccurateTransformRotatorEastNorthUpToUnreal' in my own codebase, and this guy is indeed using 'ComputeEastNorthUpToUnreal'. I'm basically using the commented out code that has been "updated" here: https://github.com/CesiumGS/cesium-unreal/commit/eefdb1f1666942327bc89a9a8c47019cd61f5ae2#diff-af1df48f999c7d544f69dfc8d3fe921f3196f2619bf9645cfe88e033f993deb4L93
Fixed by #1179