'How to place multiple spatial anchors and set up path finding in Unity for HoloLens?

I want to place multiple azure anchors and set up pathfinding (like destination point ). I followed the (https://docs.microsoft.com/en-us/azure/spatial-anchors/tutorials/tutorial-new-unity-hololens-app?tabs=azure-portal) and was able to create and locate a single anchor on Hololens. Now I want to have multiple anchors, and pathfinding to reach a destination point but I don't know how to do it. Neither I am good at scripting. Could anyone help?



Solution 1:[1]

I'm Wayne Wang from the Microsoft for Founders Hub team. Please allow me to share you some thoughts on another angle of path finding.

Azure Spatial Anchor Service is a perfect way of "Mapping Digital World and Real World", which means it was mostly used on recalibration of glitches between these two worlds.

It also has limitations, like the light condition change, like nearby signature decoration, like the size of session and query cost. Balancing these limitations means we cannot create spatial anchors everywhere/as much as possible.

On the other hand, path finding needs more points/dots to connect. Even if you are in single room, you may have paths from point A to B, among many furniture blocks you cannot pass. You may need dots on each meter or each corner, with a n-direction of graph data structure, and vetor2d on X,Z axis stored in you database. We shall call them waypoints, or business anchors.

Then we have 2 terms of points: Spatial Anchor and waypoint.

public class SpatialAnchorItem
{ 
    public guid Id; 
}
public  class WayPointItem
{ 
    public guid Id; 
    public SortedList<WayPointItem> LinkedWaypoints; 
    //SortedList can be sorted by direction so you can filter with angles/directions
    public  Vector2 Position;
    public List<SpatialAnchorItem> NearByAnchors;
  
}

With clear terms, lets review our path finding consuming scene (waypoint A to B) broken down into these steps:

  1. Find where the user is: Pinning the Digital world on real world using ASA
  2. Load All Spatial Anchors ids nearby, for pinning again when get lost
  3. Load All waypoints near anchor (also can do it on a remote server), build a list of waypoints as the route from waypoint A to waypoint B
  4. The app try locating which waypoint user is located, and show a path by connecting waypoints in the lists nearby, and highlight the next waypoint hologram and the destination waypoint hologram, until
  5. If the mapping of Digital world and real world glitches, recalibrate with the spatial anchors nearby. Then goto step 4

With agreement on these steps of consuming data, we can create more steps of building data scene, the "anchor and waypoint maker".

  1. navigate along the place you are trying to do pathfinding, add anchors near place people would like to notice, like a figure, a paint, and on major entrances.
  2. Create waypoints on the same room, with every point people may interested step in. when creating waypoints, remember put anchors nearby on the waypoint you created in case app is missing on digital world.
  3. Connect/link waypoints by adding references to each other.
  4. Save everything

With these data, consuming steps 3 is possible.

Hope these ideas helps.

Solution 2:[2]

The next step is to follow the How-To Guide on How to create and locate anchors using Azure Spatial Anchors in Unity.

There are different options you can use when querying an anchor:

Using Identifiers, NearAnchor and NearDevice .

For your scenario I would leverage the Relationship Strategy to find anchors by making use of existing connected anchors.

See more about Location Strategy here: Understanding the AnchorLocateCriteria class

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mouse On Mars
Solution 2 asergaz