Search Unity

  1. How can our website serve you better? Give us your feedback. Take our survey and let us know.
    Dismiss Notice
  2. Read here for Unity's latest plans on OpenXR.
    Dismiss Notice

How to reset orientation of Steam VR tracked object (not the HMD)

Discussion in 'AR/VR (XR) Discussion' started by am_GA, Apr 28, 2020.

  1. am_GA

    am_GA

    Joined:
    Oct 4, 2018
    Posts:
    17
    Some context:
    • I'm using the "Steam VR_Tracked Object" script to track a Vive Tracker in my scene.
    • My SteamVR setup is a "standing-only" setup, not room scale, so that I can use the tracker while sitting at my desk.
    • I am also not using a HMD at all, which seems to be rendering the Room Setup process more-or-less useless.
    Problem:
    I want my tracker's "forward" position in the scene to match my forward-facing IRL position, facing my monitor, but I can't figure out how to achieve this without a room setup. Currently the tracker in the scene appears to be upside down and facing 90 degrees the wrong way. Ideally I would like to be able to "reset" its orientation based on an arbitrary orientation of my choosing so that it can be set at runtime.

    Possible approaches:
    I imagine I could create some kind of orientation handler script that would translate the tracker's orientation based on some painful quaternion math -- this would be my last resort. First I just want to confirm whether I'm overlooking some easier solutions to this. I've noticed around the forums mention of a certain
    Valve.VR.OpenVR.System.ResetSeatedZeroPose();
    but that appears to do nothing for me, and I think in the OpenVR docs it says it's for the HMD (I don't have an HMD).

    Has anyone else previously handled a situation like this who could shed some light on the easiest way forward please?
     
    SlingyVP likes this.
  2. am_GA

    am_GA

    Joined:
    Oct 4, 2018
    Posts:
    17
    I'm using the Steam VR_Tracked Object component to get tracking data to my game object.

    I noticed in the SteamVR input binding UI, in the "Vive Tracker in Hand" controller there is a "Pistol Grip" pose binding available. I switched the binding to use this pose but nothing changed.

    I'm thinking I need to create my own script that reads from this pose action instead of using Steam VR_Tracked Object?
     
    SlingyVP likes this.
  3. SlingyVP

    SlingyVP

    Joined:
    Jul 7, 2020
    Posts:
    2
    Did you ever find a solution to this issue am_GA? Like you, I only have access to trackers and base stations, so cannot run Room Setup in SteamVR. I managed to get the trackers working without an HMD or controllers, but I've run into the same problem with the tracker's orientation in the real world not matching the virtual world. Any help would be much appreciated!
     
  4. am_GA

    am_GA

    Joined:
    Oct 4, 2018
    Posts:
    17
    Hey @SlingyVP it's actually stupid simple: add a child to the tracked object, rotate the child as necessary, then you can use this child's transform across your project to get the corrected tracker position and orientation:
    • GameObj_A (has Steam VR_Tracked Object component)
      • GameObj_B (rotate this as necessary; in my case, rotation.x = 90)
    Then from a script:

    Code (CSharp):
    1. /// Get the child obj
    2. GameObject tracker = GameObject.Find("gameObj_A").transform.Find("GameObj_B");
    3.  
    4. /// Examples for how to use the corrected orientation
    5. Quaternion rot = tracker.transform.localRotation;
    6. Vector3 forward = tracker.transform.TransformDirection(Vector3.forward);
     
    SlingyVP likes this.
  5. fpga

    fpga

    Joined:
    Jul 12, 2017
    Posts:
    5
    I use a fixed joint to attach the tracker to an object. If the tracker button is pressed it leaves a calibration mode and sets the joint relative to current positions of tracker and object. Works nice for things like a chair. The advantage is that the user can decide how to attach vive tracker to an object.
     
    SlingyVP and am_GA like this.
  6. SlingyVP

    SlingyVP

    Joined:
    Jul 7, 2020
    Posts:
    2
    Thanks for the responses guys, will give them a try! I've also been struggling with setting the floor level. I know during SteamVR room setup you set this value, but I haven't found a way to do this with just the tracker. It's not a massive problem as I can just manually adjust the height of the virtual camera, but it would be nice if it lined up between the virtual and real world without any tampering. Have y'all managed to find any way around this issue as well?
     
unityunity