Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved Reset HoloLens Origin

Discussion in 'AR' started by CrazyTegger, May 3, 2017.

  1. CrazyTegger

    CrazyTegger

    Joined:
    Feb 15, 2015
    Posts:
    57
    Is there a way to reset the HoloLens camera origin. I'm finding that if I get too close to a wall, or look down, I get the lost tracking notification, then sometimes my height doesn't match where I was. I'd like to be able to reset the Camera's origins rather than having to set a world anchor.

    Anyone know if there's that ability? I've tried resetting the camera position, but that doesn't seem to help me.
     
  2. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    Maybe VR.InputTracking.Recenter(), this might help you. Are you seeing this happen in a low light situation? Is this happening in the Shell as well or just in the app?
     
  3. CrazyTegger

    CrazyTegger

    Joined:
    Feb 15, 2015
    Posts:
    57
    It happens specifically when I put the HoloLens down on a table, and it loses tracking (for example, I put it upside down in the case to charge). The next time I pick it up to continue where I left off, the tracking resumes only once I've lifted it high enough to clear the case. Under normal circumstances, the HoloLens usually gains tracking once the user has it near head level, resulting in the user being very short in the Unity App.

    I tried your solution, but it only moved the HoloLens camera back to 0,0,0, not resetting what 0,0,0 actually is.

    Any other ideas?
     
  4. CrazyTegger

    CrazyTegger

    Joined:
    Feb 15, 2015
    Posts:
    57
    What did work for me was reloading the scene. I would love to find a solution that fixes it without having to reload the scene though...
     
  5. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    Interesting, this might be an issue with the world coordinate system. Does this happen to you in the shell as well? We might need a bug report with a min repro project for this as well, can you put the case number here so we can investigate?.
     
    Last edited: May 8, 2017
  6. CrazyTegger

    CrazyTegger

    Joined:
    Feb 15, 2015
    Posts:
    57
    i'm not sure how to test in shell only - I'll submit bug report and past case number in here
     
  7. CrazyTegger

    CrazyTegger

    Joined:
    Feb 15, 2015
    Posts:
    57
    I'm at the point now where it's necessary that I address this issue. I can't be reloading the scene many times when the HoloLens loses tracking.
     
  8. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    I noticed this issue as well as other team members, for me it appears to be the OS that is causing the issue. You can test this in the shell following the repro steps you mentioned. The shell is the main HoloLens menu were you can access all your apps, it has spatial mapping as well.

    You can see the whole world tilt when tracking is regained even if you are not close to a wall. Can you give me the case number so I can investigate this further?
     
  9. CrazyTegger

    CrazyTegger

    Joined:
    Feb 15, 2015
    Posts:
    57
    Case 909869
     
  10. CrazyTegger

    CrazyTegger

    Joined:
    Feb 15, 2015
    Posts:
    57
    I'm bumping this as I've not gotten word back or updated bug status.

    In doing more research, Recenter does not work for RoomScale, as outlined here:
    https://docs.unity3d.com/2017.2/Documentation/ScriptReference/XR.InputTracking.Recenter.html

    I've got a partial fix by creating world anchors, that solves the loss of tracking, but what if I load elements at runtime, and notice that the start position is slightly off.

    Other than tracking the rotation and position manually and sending an offset to all shared hologram members, I would really love a way to reset where I am standing to 0,0,0 without having to reload the scene.
     
  11. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    Hello,

    I have updated the bug to the dev team, from what we can see is the API hasn't been hooked up for the HoloLens.
     
  12. JulianoFranz

    JulianoFranz

    Joined:
    Jun 11, 2013
    Posts:
    4
    Any updates on this? I wanted to do something similar: setting the HoloLens origin to the position of a QR Tag.
     
  13. unity_andrewc

    unity_andrewc

    Unity Technologies

    Joined:
    Dec 14, 2015
    Posts:
    228
    I have some changes that landed recently (you should be able to expect them in 2017.2.0-p1 and 2017.3-b8), and part of those changes were hooking up InputTracking.Recenter properly on WindowsMR.

    But if I understand your use case, that's not how Recenter works. To my understanding, you want to specify the position of a particular object as the origin - Recenter doesn't take any parameters, and just makes it so the device's position when Recenter is called then becomes the origin. In other words, to set the QR tag position as the origin, you would have to call Recenter when the HoloLens is exactly at the position of the QR tag in question.

    Can I ask why you need to set the position of a QR tag to the origin? It sounds like an odd way to solve the problem at hand, was wondering if I can help by pointing you in a different direction - or whether you can correct my understanding of your problem so that we can figure out a change or improvement to the API to help support your use case moving forward.
     
  14. JulianoFranz

    JulianoFranz

    Joined:
    Jun 11, 2013
    Posts:
    4
    Currently I solve this by making all objects a child object of that QR code so multiple MR devices can share the same environment. This works but for some reason (at the time I had a good explanation why) I think that setting the hololens origin to a specific point in space can facilitate when I have multiple devices that are not only MR e.g. Rifts, tablets, tabletops + MR;

    Maybe the better answer for your reply will come back to my mind soon :)
     
  15. jvhgamer

    jvhgamer

    Joined:
    Jun 27, 2017
    Posts:
    36
    Have tried using
    Code (CSharp):
    1. UnityEngine.VR.InputTracking.Recenter();
    in a variety of methods to bring my Unity app back into user focus.

    Main case to be handled here is when a user places a Windows App Tile to activate the Unity app and then performs the bloom gesture sending the app into a suspended state and/or removes the Hololens headset without first properly closing the application and takes the app out of the viewing frustum. this as well results in either a suspended or terminated state.

    Then the app is opened again (without closing the prior instance), the application will resume from its suspended/tombstone state at the position of the first instance, not the new instance. This is not ideal or desired behavior. The app needs to always be in the users FOV otherwise they will get lost.

    With that said, I tried using the Recenter method inside of OnApplicationFocus, OnApplicationPause, WorldManager_OnPositionalLocatorStateChanged, OnSuspending, OnResuming, OnLaunched.

    It doesn't do anything. If it is indeed merely updating the world positional system to place the Hololens at the center (0,0,0) and not updating the objects in the hierarchy I am not sure what purpose that serves. Nevertheless, it doesn't appear to be working @unity_andrewc
     
  16. EyePD

    EyePD

    Joined:
    Feb 26, 2016
    Posts:
    63
    See issue 1075676 - "[XR][WMR] HEADSET DOES NOT RECENTER WHEN USING XR.INPUTTRACKING.RECENTER". Unfortunately it was resolved as "Won't Fix" with the note "XR Management has evaluated this issue and determined that it does not meet our current bug severity threshold". Considering that the Microsoft Unity documentation specifies it's usage I hope Unity might reconsider this decision or at least work with Microsoft to find another solution.
     
  17. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    404
    I've verified recenter works on 18.4.8f1 which is our current LTS version, which editor are you working on? You may need to upgrade
     
  18. EyePD

    EyePD

    Joined:
    Feb 26, 2016
    Posts:
    63
    I'm using 2019.1.5f1
     
  19. stepan-stulov

    stepan-stulov

    Joined:
    Nov 26, 2013
    Posts:
    28
    Hey.

    Not to invalidate your original request to go without world anchors. From the very beginning of HoloLens development I've just gotten used to the fact that there is no concept of universal coordinate system when developing for HoloLens. No origin, no zero. Simply none, from the app developer perspective. You have to rely on an anchor if you want something to be fixed in relation to the environment. Or you have to rely on your camera if you want something to be fixed in relation to yourself. Any other coordinate systems are fundamentally volatile. You can only derive from / combine the two, very creatively sometimes. That said you can always turn your initial camera position into an anchor temporary for this application launch and not persist it.

    I know it's not a direct answer to your question but this way of thinking helped me countless times to not rely on something that fundamentally can't be relied on.

    "You're not supposed to need it".

    Cheers
     
    Last edited: Nov 9, 2020
  20. Deleted User

    Deleted User

    Guest

    I'm using the version of Unity 2018.4.17f1 but it seems that Recenter does not work on the y axis. I mean it recenters the hologram on the x and on the z axis but not on the y. Do you know if there is a way to recenter also on the y axis?
     
  21. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    404
    If you could, file a bug with a small repro project and we will confirm this is desired behavior with our engineers
     
    Deleted User likes this.
  22. Deleted User

    Deleted User

    Guest

    Instantiating a cube and calling Recenter in Update, the hologram stays body locked when I move my head from right to left and viceversa (x axis), and if I move back and forward (z axis). But it stays in the same position in which it is instantiated (world locked) on the y axis. I mean if I move my head up and down the hologram doesn't follow the head's movement.
     
  23. ceitel

    ceitel

    Joined:
    Jan 3, 2017
    Posts:
    35
    @JasonCostanza I am having a related issue: between scenes, Hololens 2 (running with holographic remoting) will recenter itself to the local origin, facing local "forward". This essentially places the user's head in the "floor" of the scene any time the scene is changed. This is very different behavior than every other XR experience where the HMD remains at the same local position/rotation and is causing me major headache in my development where I need the Hololens to behave the same as the other XR devices. At the very least, I need a way to "reload" the previous localPos, localRot that the Hololens had in the previous scene. To my best knowledge, the only way to do this was hinted at by @stepan-stulov by possibly temporarily setting the parent (rig) of the camera as a temporary world anchor object and then disabling/removing the world anchor. I haven't tried this yet as I was hoping there was a better solution to this problem, like a flag that can be set that allows the Hololens' position/rotation to persist between scenes as well as when tracking is lost/regained.

    Thanks

    [EDIT]

    Workaround for my issue:
    1. Use a temporary object (Temp) to save/load a world anchor
    2. Use another object to establish the "Offset" of Temp, ie Offset.localPos = -Temp.localPos. Offset.localRotation.EurlerY = - Temp.localRotation.EulerY
    3. Set the Offset as the parent of Camera.main

    I can provide better code examples if anyone is interested.

    This is a very kludgy workaround and not how I would expect Hololens to perform in Unity. I really hope they can add a flag to allow the Hololens (2) transform to persist between scenes.
     
    Last edited: Nov 9, 2020
  24. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    404
    Hi @ceitel,

    From what I gather, the other headsets you're using persists position between scenes but your Hololens device is not? If so, I believe that behavior is by-design as per Microsoft's design and this is because the Hololens doesn't have a true "stage" or sense of what a floor is. This creates a behavior where a new scene is spawned at your head's position, basically the Unity scene places it's 0,0,0 at your head's current position. I'm sure there are ways around this but what just popped into mind is have you tried placing your camera rig in a scene that never unloads and then loading additive scenes on top of it with your actual content? That way the camera itself would never go away and should maintain its position in the world while scenes on top of it come and go with your interactive content.

    If that's not an option I can ask around for suggestions but I believe that is intended behavior of the Hololens at a base level.
     
    stepan-stulov likes this.