Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Tracking loss of 6Dof on WMR and other headsets.

Discussion in 'AR/VR (XR) Discussion' started by vtewari, Jan 14, 2020.

  1. vtewari

    vtewari

    Joined:
    Oct 20, 2015
    Posts:
    4
    • Does the UnityEngine.XR API have a way to track loss of 6-dof ( six degrees of freedom ) on an HMD?
    • If not, is there a Windows Mixed Reality ( WMR ) specific way to listen for the 6-dof loss event?
    The closest thing I could find was:
    Code (CSharp):
    1.  
    2.             InputTracking.GetNodeStates(nodeStates);
    3.             foreach( XRNodeState ns in nodeStates )
    4.             {
    5.                 if( ns.nodeType == XRNode.Head )
    6.                 {
    7.                     IsSixDofActive = ns.tracked;
    8.                 }
    9.             }
    10.  
    However this returns whether all tracking ( position + orientation ) is active. I'm not looking for a way to detect 6-dof by processing position data and guesstimating, I need the event raised by the HMD.
     
    Last edited: Jan 14, 2020
  2. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
  3. vtewari

    vtewari

    Joined:
    Oct 20, 2015
    Posts:
    4
    Thanks joejo, this is what i'm looking for! However the WorldManager seems to only return the 'Unavailable' state.

    I've tried two approaches:
    Code (CSharp):
    1.  
    2. switch( WorldManager.state )
    3.         {
    4.  
    5. case PositionalLocatorState.Active:
    6. {
    7.       IsSixDofActive = true;
    8.       break;
    9. }
    10.  
    11.             case PositionalLocatorState.Activating:
    12.             case PositionalLocatorState.Inhibited:
    13.             case PositionalLocatorState.OrientationOnly:
    14.             case PositionalLocatorState.Unavailable:
    15.             default:
    16.             {
    17.                 IsSixDofActive = false;
    18.                 break;
    19.             }
    20. }
    Code (CSharp):
    1. void Start()
    2.     {
    3.         IsSixDofActive = false;
    4.  
    5.         WorldManager.OnPositionalLocatorStateChanged += OnSixDofStateChange;
    6.     }
    7.  
    8. void OnSixDofStateChange(PositionalLocatorState PrevState, PositionalLocatorState State)
    9.     {
    10.         switch( State )
    11.         {
    12.             case PositionalLocatorState.Active:
    13.             {
    14.                 IsSixDofActive = true;
    15.                 break;
    16.             }
    17.  
    18.             default:
    19.             {
    20.                 IsSixDofActive = false;
    21.                 break;
    22.             }
    23.         }
    24.     }
    Do I need to retrieve a WorldManager instance specific to my Windows Mixed Reality headset? Or it is a player XR API setup issue?
     
  4. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    It's static so if you are getting callbacks you are using it correctly. If prev and state are incorrect then there is something else going that you'll need to figure out. What device are you running on?
     
  5. vtewari

    vtewari

    Joined:
    Oct 20, 2015
    Posts:
    4
    • I'm running a 'Samsung Windows Mixed Reality 800ZAA' headset.
    • My XR player settings has only the 'OpenVR' api setup.
    • Unity Version 2019.2.17f1
    • Windows 10, v1909

    Here's the script i'm running:
    Code (CSharp):
    1.  
    2.     public bool IsSixDofActive = false;
    3.     public PositionalLocatorState SixDofState = PositionalLocatorState.Unavailable;
    4.  
    5.     void Start()
    6.     {
    7.         WorldManager.OnPositionalLocatorStateChanged += OnSixDofStateChange;
    8.     }
    9.  
    10.     void Update()
    11.     {
    12.         var prevSixDofState = SixDofState;
    13.         SixDofState = WorldManager.state;
    14.         if( SixDofState != prevSixDofState )
    15.         {
    16.             Debug.Log("6Dof polled: " + SixDofState);
    17.             switch( SixDofState )
    18.             {
    19.                 case PositionalLocatorState.Active:
    20.                 {
    21.                     IsSixDofActive = true;
    22.                     break;
    23.                 }
    24.  
    25.                 case PositionalLocatorState.Activating:
    26.                 case PositionalLocatorState.Inhibited:
    27.                 case PositionalLocatorState.OrientationOnly:
    28.                 case PositionalLocatorState.Unavailable:
    29.                 default:
    30.                 {
    31.                     IsSixDofActive = false;
    32.                     break;
    33.                 }
    34.             }
    35.         }
    36.     }
    37.  
    38.     void OnSixDofStateChange(PositionalLocatorState PrevState, PositionalLocatorState State)
    39.     {
    40.         Debug.Log("6Dof change: " + PrevState + " > " + State);
    41.         switch( State )
    42.         {
    43.             case PositionalLocatorState.Active:
    44.             {
    45.                 IsSixDofActive = true;
    46.                 break;
    47.             }
    48.  
    49.             default:
    50.             {
    51.                 IsSixDofActive = false;
    52.                 break;
    53.             }
    54.         }
    55.     }
    I'm not receiving the 'OnSixDofStateChange' event, and the polling always returns 'Unavailable'
     
    Last edited: Jan 14, 2020
  6. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    The OpenVR MR driver doesn't report that information up so you won't get it. This is an issue with Valve and not Unity. :-(
     
  7. vtewari

    vtewari

    Joined:
    Oct 20, 2015
    Posts:
    4
    Ah i see, thanks so much for the quick replies! Is there anything I could do that is WMR specific? Does Unity have any direct interface with the WMR api like Unreal?
     
  8. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    For stand alone applications no. For UWP you can use the WIndows Mixed Reality XR Provider in Unity.
     
    vtewari likes this.