Is it possible to "set" the Session Origin?

I understand that when an ARSession starts the device’s current position is initialized as the ARSessions “origin” (like local model space). The Pose Driver then updates the parent GameObjects Transform.

Is it possible to “set” the current Pose to a Transform in world space so that updated poses deltas are added to that coordinate?

ARCameraGameObject (gameObject)
-PoseDriver (script)

Scenario:

  • ARSession has a current translation of (1,6,5)

ARSession.SetCurrentLocation(3,1,8)

This would make it so that the current “pose” calculated by the Pose Driver is (3,1,8).

Hey @adammpolak - give the method ARSessionOrigin.MakeContentAppearAt() a try.

Please let us know if that doesn’t work!

1 Like

@TreyK-47 sorry so the method would be ARSessionOrigin.MakeContentAppearAt(3,1,8)?

And thank you for the response!

Here is the link to this method, you need to give a GameObject and the Position. Maybe the PoseDrive GameObject and is current position will work.

Thank yoU!

@TreyK-47 it doesn’t seem to work but I am not sure if its because I am implementing this incorrectly.

  • Pose Driver starts at (0,0,0) and the AR device moves around and let’s say they are at (5,6,8)
  • I want to “spawn” the AR player at (1,3,-4) (so the equivalent of reseting the Pose Driver to (0,0,0) but at (1,3,-4))

I would like the response after setting origin to new location to be the value of the new location.

Note 1:
Calling MakeContentAppearAt() seems to be additive?

What I am doing:
float3 newPostTranslation = (some value)
quaternion newPostRotation = (some value)

Transform dummyTransform = new GameObject().transform;
m_ARSessionOrigin.MakeContentAppearAt(dummyTransform, newPoseTranslation, newPoseRotation);

If I call this several times the AR position seems to “travel forward”.

Below you can see the Debug.Log() of the following steps:

  • Getting a spawn position
  • Calculating where the camera should be (relative to the spawn position it’s (0,2,-10)
  • After calling MakeContentAppearAt I log the camera transform
spawn position is: float3(-2.11f, 9.44f, 16.13f)
ARPoseSampler:Update()
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

calculated camera position is: float3(-2.11f, 11.44f, 6.129999f)
ARPoseSampler:Update()
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

transform after MakeContentAppearAt: (2.2, -11.4, -6.1)
ARPoseSampler:Update()

It appears to be -1 of where I want it to be.

Weirder still is that as I call it more times the offset seems to change based on previous calls. Seems like maybe I need an equivalent “clear” call before I call it again?

I am going to save each update, reverse it, then apply the new one *-1

Note 2:
I got it working by saving the last update, reversing it, then creating the new update

           Transform dummyTransform = new GameObject().transform;
            //First we will undo our last MakeContentAppearAt
            m_ARSessionOrigin.MakeContentAppearAt(dummyTransform, -1f*m_LastPosition, Quaternion.Inverse(m_LastRotation));
        
            //Now we will do our current MakeContentAppearAt
            m_LastPosition = -1f * newPoseTranslation;
            m_LastRotation = Quaternion.Inverse(newPoseRotation);
            m_ARSessionOrigin.MakeContentAppearAt(dummyTransform, m_LastPosition, m_LastRotation);

Result from Debug.Log:

spawn position is: float3(6.33f, 9.88f, 2.03f)
ARPoseSampler:Update()
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

calculated camera position is: float3(6.33f, 11.88f, -7.97f)
ARPoseSampler:Update()
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)

transform after MakeContentAppearAt: (6.3, 11.9, -8.0)
ARPoseSampler:Update()

This isn’t great because rounding errors causes it to drift away from being correct. Is there anyway to “reset” so I can 0 out? Should I adjust the actual ARSessionOrigin’s Translation and Rotation?

@Treyrannosaurus-Rex hey sorry this isn’t resolved.

Is there any Unity way of updating the origin? This is needed for AR applications. If you want to correct for drip or make the player “exist” in another location.

My method doesn’t work for the reasons explained above.

https://forum.unity.com/threads/set-ar-session-origin.1137070/#post-7348127