Closed alexs7 closed 2 years ago
Assuming you mean real world then you should use the localPosition
of the camera that is the child of the AR Session Origin
that will get you the camera position relative to the session origin and handle any cases where the session origin has been translated, rotated. If any scaling has been applied then you will need some math to undo the scaling to properly determine the real world position.
Edit: Misused phrasing when describing the relationship between AR Session Origin
and AR Camera
.
Does that pose correspond to https://developers.google.com/ar/reference/java/com/google/ar/core/Camera#getDisplayOrientedPose() in ARCore or https://developers.google.com/ar/reference/java/com/google/ar/core/Camera#getPose() ?
@DavidMohrhardt You meant the camera has to be a child of ARSessionOrigin
right ? I am confused because you said "camera parented to the AR Session Origin", which means the camera is the parent of AR Session Origin.
Yes, I mis-phrased it. Edited the comment to reflect the proper phrasing.
Does that pose correspond to https://developers.google.com/ar/reference/java/com/google/ar/core/Camera#getDisplayOrientedPose() in ARCore or https://developers.google.com/ar/reference/java/com/google/ar/core/Camera#getPose() ?
It would be the DisplayOrientedPose
From debugging, it seems that z-axis in unity is flipped compared to the android poses.. What is the expected coordinate system in Unity ? I mean for the local camera one (not the world.)
Unity is left-handed, Y-Up whereas ARCore is right-handed Y-Up so a conversion must happen to get the ARCore pose in Unity space.
@DavidMohrhardt Ok this makes sense! So this arSessionOrigin.camera.transform
will be a left-handed coordinate system but
https://developers.google.com/ar/reference/java/com/google/ar/core/Camera#getDisplayOrientedPose() this in a right-handed coordinate system ?
That is correct. Under the hood the ARCore Provider Plug-In performs the conversion before reporting to the input subsystem. The input subsystem then surfaces that information to the Unity input system from which the XROrigin
TrackedPoseDriver
or the legacy ARPoseDriver
will drive the camera pose in the scene.
@DavidMohrhardt ARPoseDriver
is not legacy is it ? TrackedPoseDrive
is if I recall ?
@DavidMohrhardt btw are all of this documented somewhere ? Dor example what you just mentioned, is it written online somewhere ? I found ARFoundation docs to only provide the basics.
@DavidMohrhardt
ARPoseDriver
is not legacy is it ?TrackedPoseDrive
is if I recall ?
XROrigin
contains a new TrackedPoseDriver
that is not legacy. ARPoseDriver
is now legacy.
@DavidMohrhardt btw are all of this documented somewhere ? Dor example what you just mentioned, is it written online somewhere ? I found ARFoundation docs to only provide the basics.
The ARFoundation documentation for XR Origin and ARInputManager are the key pieces of documentation for input in terms of ARFoundation.
XRInputSubsystem is a Unity core API and can be found in the main Unity documentation. For platform specific details you should refer to the documentation on those platforms.
@DavidMohrhardt Ok XROrigin
is a 5.0 version class. I am still at 4.1, makes sense.
Great! Thanks a lot for the links! :)
How do I get the world camera position ?
Is it as simple as getting the position and rotation of the camera game object that is a child of the AR Session Origin?
If so which one will give me the world position ?
Do I need to attach an AR Pose Driver script to that camera game object ? Does it make a difference ?
Thanks!