Creating local world anchors on HoloLens 2

When HoloLens 1 was released, one of it’s greatest strengths was the ability to create persistent, so called world anchors, that would reliably lock objects into a position in the real world.

World anchors could be retrieved during later sessions, or even shared across devices! This was groundbreaking in 2015 and still pretty cool today.

With the HoloLens 2, the competition has caught up a bit and it is now possible to create spatial anchors on most AR/MR platforms. Still, the ability to create robust anchors using only the onboard device capabilities is an attractive feature of the HoloLens.

Microsoft are now pushing the use of Azure Spatial Anchors, which in many ways is a superior successor to the “old” spatial anchors. Created and managed by a cloud service, it leverages both the cached, local anchors, as well as an online database of anchors that can grow to host millions of anchors.

Still, sometimes it is preferable to use the classic world anchors, for instance, when you cannot, or do not want, to use any cloud services. I wanted to try if this was still possible, since the “WorldAnchorManager” script is available in MRTK (the Mixed Reality ToolKit).

Turns out that with some minor tweaks, it’s perfectly possible to create world anchors on HoloLens 2.

Based on these steps: https://docs.microsoft.com/en-us/windows/mixed-reality/develop/unity/persistence-in-unity, I wrote a small example app that enables the user to place a cube at any location, automatically creating and saving an anchor each time the cube is released. When the app is closed and re-started, the anchor is loaded and the cube is placed at its saved location.

The source can be found here: https://github.com/anders-lundgren/mrtk-world-anchors

Verified on Unity 2019.4.9f1, Visual Studio 2019, HoloLens 2 (Build 10.0.19041.1377).

In addition to the above steps, I added the base MRTK components, according to the MRTK getting started tutorial at https://docs.microsoft.com/en-us/windows/mixed-reality/develop/unity/tutorials/mr-learning-base-02 . I also added a simple debugging prefab from this example: https://docs.microsoft.com/en-us/windows/mixed-reality/develop/unity/tutorials/mr-learning-asa-02#importing-the-tutorial-assets , and the manipulation handler from this example: https://microsoft.github.io/MixedRealityToolkit-Unity/Documentation/README_ManipulationHandler.html.

4 Replies to “Creating local world anchors on HoloLens 2”

  1. Hi dear,

    I am started to create an origami game with HoloLens 2. I have a lot of problems with the location of holographic objects. The objects’ locations change every time after each run and it makes me disappointed because I can not rely on the locations for developing the next step… I read your nice text. Can I contact you if I need more help?

    Best,
    Sajjad

      1. Thanks, admin. I have tried to run your project. Unfortunately, I always receive the below error. Even in my own applications. I have searched for solving it but the proposed solutions did not work for me.
        [XRInputSubsystem] A device disconnection with the id 2000000271 has been reported but no device with that id was connected.
        Could you please let me your ideas?

        1. That sounds like an error from Holographic Remoting. Working with anchors requires full access to the device so you need to deploy the app and run it from the device.

Leave a Reply

Your email address will not be published. Required fields are marked *