Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InaccurateTransformRotatorEastNorthUpToUnreal broken? #724

Closed
julien443 opened this issue Jan 14, 2022 · 5 comments
Closed

InaccurateTransformRotatorEastNorthUpToUnreal broken? #724

julien443 opened this issue Jan 14, 2022 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@julien443
Copy link
Contributor

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

@kring
Copy link
Member

kring commented Jan 26, 2022

@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.

@julien443
Copy link
Contributor Author

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.

@kring
Copy link
Member

kring commented Feb 1, 2022

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:

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.

@julien443
Copy link
Contributor Author

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: eefdb1f#diff-af1df48f999c7d544f69dfc8d3fe921f3196f2619bf9645cfe88e033f993deb4L93

@j9liu
Copy link
Contributor

j9liu commented May 6, 2024

Fixed by #1179

@j9liu j9liu closed this as completed May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants