Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
MELT's avatar
MELT
Honored Guest
11 years ago

Fixing position of positional tracker in virtual space Unity

Hi guys!

I'm trying to make a site-sepcific, sitting installation where the positional tracker will always be in the same place and there will be some real-world scale unmovable surroundings to touch and interact (leap motion). It'd be best to position the tracker in virtual space in Unity mirroring the real world, but I don't know how to get my hands on it. The TrackerAnchor always sets up a bit differently on Play or when Recentering.

Any ideas appreciated :)

4 Replies

Replies have been turned off for this discussion
  • This is a problem we're actively working on. For now, I would recommend computing the position and rotation offset from the initial TrackerAnchor pose to the one you want and making that offset the local position and rotation of the TrackingSpace GameObject.
  • I basically want the same thing.

    Could you go in a litte more Detail vrdaveb?

    I know there is OVRManager.tracker.GetPose() and OVRManager.display.RecenteredPose but why do I move the Tracker Anchor?

    Isnt the OVRPlayerController my User and its position should resemble the users real world position?

    Also I am very confused about the "initial values" all the GameObject under the OVRPlayerController get when I hit Play with a stationary HMD.

    OVRPLayerController Position is (0, 1.01, 2.242651e-1)
    OVRCameraRig Position (0, 0, 0.0805)
    TrackingSpace Position X And Z are close to 0 but constantly changing. Y is always 0.

    I can find any meaning in those numbers. How am i supposed to move the HMD in the right position taking into acccount his real world position, body height etc. given I know exactly where my tracking camera is located in the real world as well as in Unity, both (0, 1.72, 0).
  • "MELT" wrote:
    It'd be best to position the tracker in virtual space in Unity mirroring the real world
    Yes, you need to move the tracking reference frame so that the virtual tracker lines up with the physical tracker. The origin and basis vectors of our tracking space space are the initial pose of your head when the app starts, but the x and z rotation are set to be parallel to the floor to avoid tilting the whole world. When you call InputTracking.Recenter(), it moves the origin to your current head position and changes the yaw to match your current head yaw. This is known as "eye level" tracking. As of Oculus SDK 0.8, we always report the poses of your head, eyes, and tracker relative to the "eye level" origin. OVRCameraRig.trackingSpace is always at that origin. If you move trackingSpace, all the other anchors will move to follow it. So if you want the trackerAnchor to be at a specific pose, move trackingSpace to the inverse of that pose with code like the following:
    using UnityEngine;

    public class TrackerToOrigin : MonoBehaviour
    {
    public OVRPose origin = OVRPose.identity;
    public bool useWorldSpace = true;

    void Awake()
    {
    var rig = GameObject.FindObjectOfType<OVRCameraRig>();
    rig.UpdatedAnchors += OnUpdatedAnchors;
    }

    void OnUpdatedAnchors(OVRCameraRig rig)
    {
    var oldPose = rig.trackerAnchor.ToOVRPose(!useWorldSpace);

    var offset = origin * oldPose.Inverse();

    if (useWorldSpace)
    offset = rig.transform.ToOVRPose() * offset;

    rig.trackingSpace.FromOVRPose(offset, !useWorldSpace);
    }
    }