Search Unity

XR input vs. Oculus Go

Discussion in 'AR/VR (XR) Discussion' started by PatrickHogenboom, Sep 9, 2019.

  1. PatrickHogenboom

    PatrickHogenboom

    Joined:
    Dec 10, 2018
    Posts:
    3
    Hi there,
    I'm trying to use Unity's native XR input to read the device velocity of the Oculus Go.
    Attached is a screenshot with the device's reported usages which includes deviceVelocity.
    But when I try to read the value with the code below, I'm only reading zeros.
    I'm using Unity 2019.2.4f1

    Code (CSharp):
    1.  
    2.     void Update()
    3.     {
    4.         if (!m_hmd.isValid) return;
    5.  
    6.         Vector3 speed = Vector3.zero;
    7.         if (m_hmd.TryGetFeatureValue(CommonUsages.deviceVelocity, out speed))
    8.         {
    9.             float vignette = (speed.magnitude - SpeedRemapRange.Start) / SpeedRemapRange.Range;
    10.             vignette = Mathf.Clamp(vignette * VignetteRemapRange.Range + VignetteRemapRange.Start, 0, VignetteLimit);
    11.          
    12.             // Communicate vignette amount to VR180 shader
    13.             Shader.SetGlobalFloat("_Vignette", vignette);
    14.  
    15.             // Debug output of 3D HMD speed and corresponding vignette value
    16.             if (DebugVignetteData)
    17.                 m_debugOutput.SetText(string.Format("{0,5:0.00}\n{1,5:0.00}\n{2,5:0.00}\n\n{3,5:0.00}", speed.x, speed.y, speed.z, vignette));
    18.         }
    19.     }
    20.  
    21.  
     

    Attached Files:

  2. PatHightree

    PatHightree

    Joined:
    Aug 18, 2009
    Posts:
    259
    AH, found the problem.
    The Go doesn't supply velocity, it only supplies acceleration.
    Does anybody have sample code to calculate speed from acceleration reliably, avoiding drift ?
     
    Last edited: Sep 10, 2019