Search Unity

TrackedPoseDriver in 2019.1

Discussion in 'AR/VR (XR) Discussion' started by col000r, Feb 25, 2019.

  1. col000r

    col000r

    Joined:
    Mar 27, 2008
    Posts:
    699
    Where has TrackedPoseDriver gone in 2019.1? Am I supposed to use something else instead? It's even gone from the docs with the entire UnityEngine.SpatialTracking namespace :(
     
  2. col000r

    col000r

    Joined:
    Mar 27, 2008
    Posts:
    699
    Ah. Apparently it's moved to the "XR Legacy Input Helpers" Package. But what am I supposed to use instead?
     
  3. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    182
    That's the correct package at the moment. The use of 'legacy' is a little premature, but it's in expectation of the currently in development new input system as an alternative source for Tracked Pose Driver data.
     
  4. fariazz

    fariazz

    Joined:
    Nov 21, 2016
    Posts:
    55
    Will there be an equivalent component that allows to track position in a similar way? In which version of Unity do you think it will be removed? (asking because I'm using it in a training, and would like to know when we will need to update this material)
     
  5. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    182
    I don't have a conclusive date yet on when the TrackedPoseDriver using the existing Input APIs will be deprecated, but it's a long way out. Once the new input system is out of experimental and beta, then we will look to tag the old components as obsolete, and then it's another 2 years before they are fully removed.
     
    ROBYER1 and fariazz like this.
  6. bensenior

    bensenior

    Joined:
    Aug 31, 2017
    Posts:
    4
    I ran into the same issue, and gradually pieced together the steps I needed to take. I am using Unity 2019.1.0b9. With the package manager I installed XR Legacy Input Helpers (2.0.2). I can see it correctly listed in manifest.json.

    In my class which uses the TrackedPoseDriver, the " using UnityEngine.SpatialTracking; " still doesn't compile. "The type or namespace name 'SpatialTracking' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)". I cannot find a reference to the TrackedPoseDriver or SpatialTracking in any other assembly.

    This makes me feel incredibly frustrated. I have tried everything I can think of to try to understand what's happening here, or where the problem is, but have come to a dead end (including an install of 2019.2).

    Please... what do I need to do to be able to use the TrackedPoseDriver in Unity 2019?!?!?
     
  7. bensenior

    bensenior

    Joined:
    Aug 31, 2017
    Posts:
    4
    o_O So, many issues seem to come back to the same origin. If you are one of the unicorns who actually unit tests in Unity, you'll be specifying your own assemblies. What happens then is that you'll need to look in your project (in the IDE) where you'll find a Packages folder in the project pane (you learn something new everyday). In there you'll find the XR Legacy Input Handlers folder, and buried inside there (Runtime->TrackedPoseDriver) the UnityEngine.SpatialTracking assembly. Find the assembly where you have a problematic assembly, and add a reference to this SpatialTracking assembly and it'll work.

    Couldn't this have been documented somewhere?:confused:
     
    Last edited: Mar 28, 2019
  8. Matt_D_work

    Matt_D_work

    Unity Technologies

    Joined:
    Nov 30, 2016
    Posts:
    202
    to clarify. you were attempting to inherit (or otherwise use) code from the UnityEngine.SpatialTracking namespace in your own code? and the step that you'd missed was referencing the correct assembly that contains the UnityEngine.SpatialTracking namespace?
     
  9. chmodseven

    chmodseven

    Joined:
    Jul 20, 2012
    Posts:
    120
    In case it helps anyone, I was trying to get EditorXR working and getting the namespace error on SpatialTracking as well. Here's the relatively simple steps I followed to resolve it, from scratch of a new project:

    1. Install the EditorXR Unity package and the XR Legacy Input from Package Manager. The error will show up.
    2. Navigate to the Library/ScriptAssemblies folder of your project, and copy the UnityEngine.SpatialTracking.dll file. I'm not sure if they're needed, but I also grabbed the UnityEditor.SpatialTracking.dll file and both the .pdb files of same name
    3. Create an Assets/Plugins folder in your project and paste the files into that.

    This got me past the error and let me continue on with the troublesome journey of getting the rest of EditorXR to work.
     
    shacharoz and Corysia like this.
  10. Corysia

    Corysia

    Joined:
    Mar 14, 2018
    Posts:
    108
    Bless you, I've been trying to get this working all evening. I'd run in to this before when I tried out the PR to remove the SteamVR and Oculus dependencies in EditorXR. But then, all I had to do was import the Legacy package. I'm glad you posted the extra steps!
     
  11. unitylepi

    unitylepi

    Joined:
    May 21, 2018
    Posts:
    34
    According to the very sparse docs, the InputFeatureUsage<Vector3> centerEyePosition is supposed to give me "The position of the center eye on this device." However, in relation to what? I can deduce that it is not world view because when I place an object at the returned position it's nowhere near where my head is in the VR game. It also doesn't seem to be an exact offset to the camera obj or the camera's parent, so how can I use it to replace the deprecated tracked pose driver on the camera?
     
  12. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    182
    @unitylepi
    All real world tracked points (left eye camera positions, device positions for controller/hmd, hand/eye tracking values, etc...) are in a singular space, which depends on the current SDKs Tracking Space Type. This space type was unclear and we are moving to the concept of a tracking origin. There is no direct relationship between the origin of this space, and the origin of Unity's virtual space, because that's up to you, the developer.

    If you are relying on the built-in automatic camera updating, or the TrackedPoseDriver, you can run into issues with local position vs. global position. The TrackedPoseDriver sets the localPosition of the object, and so if you map that to the 'center eye', and parent the GameObject that has the TrackedPoseDriver to a GameObject 5 meters up, then the world position of that and the InputFeature centerEyePosition would be 5 meters different. The automatic camera movement does the same thing, but one worse. It's takes the starting position of the camera as a local origin. So if your scene has a camera at (0,2,0) and then the center eye position is (0,1,0), the local position of the camera GameObject will actually be (0,3,0) even though it's tracking the center eye, which is only at (0,1,0).

    The way we suggest you use these positions and map them to GameObjects is to have a 'Stage' or 'Tracking Origin' GameObject, and then place all tracked objects as children of that object and update them accordingly. So long as they are using the same parent position, they should be in the correct relative positions. This also means you can teleport your entire player and tracking space within the scene by moving the stage object.

    Does that make sense to you?
     
    Matt_D_work likes this.
  13. mikewarren

    mikewarren

    Joined:
    Apr 21, 2014
    Posts:
    109
    Glad to hear about the incorporation of tracking origin.

    I have a fair amount of experience developing for CAVE type systems. Any plans to integrate general purpose tracking systems (Eg. OptiTrack, ART, Vicon, Motion Analysis) or device aggregators like TrackD or VRPN? I've written a TrackD interface for Unity. Just started looking at the new input system. Is it extensible so that I can add new devices that aren't supported natively?

    Setup is even a little more complicated when dealing with fixed position displays like projection walls where the relationship between the users (tracked) eyes and display surfaces are constantly changing. There's usually coordinate systems for the display space, tracking space, and virtual world space that need to be coordinated. I have scripts to manipulate the camera and projection settings, but I'd like to see some native XR support for those systems.
     
  14. StayTalm_Unity

    StayTalm_Unity

    Unity Technologies

    Joined:
    May 3, 2017
    Posts:
    182
    The New Input System supports device creation in C#. If you look at the Github repo, and check out the tests both in the core project, and in the package, you can see the creation and manipulation of simple C# devices. That means if you can read it in C#, you can funnel it back through the new input system.

    As for tracking spaces, we generally have enough points of data through Tracking References, Tracking Origin Mode, Display Subsystem settings, to be able to jump between the real-world tracking space, virtual world space, and view space, although we are hesitant to make these official systems; it can be up to the developer to decide how to structure his XR rig, for example if he wants a stage gameobject, or a simulated floor offset in the case that he is stuck in device tracking mode for that device.

    For example, we report all tracking values in 'tracking space', and by using a stage gameobject to place those tracked objects under, the developer is now able to define their tracking<->Virtual world spaces and how to translate between the two. For getting the display space, we provide CommonUsages.centerEyePosition & Rotation to translate from Display<->Tracking, as well, you can get the camera's view matrix in Application.onBeforeRender which can help you map from Display<->Virtual world.
     
  15. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Do you have a map of what is new, what you want us to be using and so on? sorry to say even with 35+ years development I'm finding this a complete mess, throughout.

    It is 100% unreasonable for customers to be wading through that without at least a map. I am attempting to use the latest XR.* packages but keep walking into what-ifs, random dev comments and even non-deprecated things that will be deprecated, or just plain not working. This of course is fine with the deprecated or soon to be deprecated stuff, but you're telling us not to use that, and I'm really trying but there's no really solid results.

    Quite a lot of customer stress.

    Just trying to even understand what I should be doing to get proper height (quest) - something that was a 2 min job in UE4. As it is, I'm really feeling confused! :)
     
    farbridgedamon likes this.
  16. Matt_D_work

    Matt_D_work

    Unity Technologies

    Joined:
    Nov 30, 2016
    Posts:
    202
    the "height" of the user will be implicit in the tracked data when using the quest in roomscale mode / using a floor tracking origin.

    all tracking data available from unity is in "tracking space", ala the space the device is reporting its tracking data in. I've not used a quest in roomscale/ floor tracking origin mode. but 0,0,0 of tracking space should be on the floor. the headset should report its position with the users height built in.

    in non xr plugin world, https://docs.unity3d.com/ScriptReference/XR.TrackingSpaceType.html will set the tracking space type. in xr plugin world https://docs.unity3d.com/2019.3/Doc...RInputSubsystem.TrySetTrackingOriginMode.html will set the origin.

    also, if you're running in floor tracking origin / roomscale make sure that you either
    - untick the "use reference transform" option on the tracked pose driver. (this will treat the parent game object of the camera as the tracking space -> world anchor)
    or
    - put the camera on the floor of your scene. (this will effectively create a hidden transform that is the tracking space -> world anchor at the location of the camera on scene start)

    if that doesn't work drop me a line (i've not actually done this on a quest yet!)

    and yes, calling it legacy input helpers has only added to the confusion. it really means that the code in that package will work for XRNode / UnityEngine.Input / InputTracking api's found in unity prior to 19.1 (and supported throughout 2019 and onwards).

    the com.unity.xr.legacyinputhelpers package is essentially the same tracked pose driver code that was in unity prior to 19.1, with a bunch of bug fixes, arm models and a couple of neat helper menu items!

    In terms of "what things should we use". what items specifically would be useful to communicate?
     
    Last edited: Oct 10, 2019
    ROBYER1 and hippocoder like this.
  17. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hey! thanks for reply. Well, I'd love a clear and concrete example of seeing the basic unity character controller doing a simple move with floor tracking on quest - I imagine this fulfils what most people need to decipher getting up and running with the new API.

    So long as the basic height tracking is sorted. For the life of me i'm not getting consistent results, will have to sleep on it :)
     
    Walter_Hulsebos likes this.
  18. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
  19. IgnisIncendio

    IgnisIncendio

    Joined:
    Aug 16, 2017
    Posts:
    223
    I've noticed that there's a new Tracked Pose Driver (New Input System) in the Input System package. Are we supposed to use that instead? It wasn't obvious, since the Unity Manual recommends using the auto XR rig creation thing, and the default XR rig uses the Legacy Tracked Pose Driver.

    The only way I found this out was by searching in the Components menu, after realising that the Tracked Pose Driver from the XR rig linked to the Legacy Helper package documentation after pressing the (?) button. There seems to be no documentation on this new component, aside from a scripting reference page in the Input System package documentation. There's no mention of this new component in the Unity Manual at all either.

    The component seems to work for now though! :D

    Edit: I'm on Unity 2020.2, if that helps!

    upload_2021-2-28_19-47-55.png
     
  20. henymeny

    henymeny

    Joined:
    Apr 19, 2014
    Posts:
    10
    Here's my super simple pose tracker:

    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3. using UnityEngine.InputSystem;
    4.  
    5. [Serializable]
    6. [AddComponentMenu("Simple Tracked Pose Driver")]
    7. public class MyTrackedPose : MonoBehaviour
    8. {
    9.     public InputActionReference centerPosition;
    10.     public InputActionReference centerRotation;
    11.  
    12.     void Start() {
    13.         if (centerPosition != null)
    14.             centerPosition.action.Enable();
    15.  
    16.         if (centerRotation)
    17.             centerRotation.action.Enable();
    18.     }
    19.  
    20.     void Update()
    21.     {
    22.         if (centerPosition != null)
    23.             transform.localPosition = centerPosition.action.ReadValue<Vector3>();
    24.  
    25.         if (centerRotation != null)
    26.             transform.localRotation = centerRotation.action.ReadValue<Quaternion>();
    27.     }
    28. }
    (parameters are input events of centerEye-Position & -Rotation)
     
    farbridgedamon likes this.