in sharing my app between two Hololens i need to know if they are at the same space, so both Hololens can see the holograms at the same position in real word and if it not the same space then we will not share the world anchor?
One device needs to load the other device's anchor data and try to locate the world anchor that was exported.
Alternatively you could use Vuforia to have each device place a world anchor in the same physical location without networking the anchor data across.
thank you for replay
but what i want is to have a possibility to know if the both hololens are not in same physical location then i will not load the anchor data
@meah - I don't have a technical solution for you, but the easy solution is to ask the user if they are in a shared space, and if they click yes, then load the anchor data, and if they click no, then don't.
Not sure if that will work for you.
The device is always aware of its surroundings, as soon as it thinks it has a match, it'll trigger an update and download the anchors appropriately. There's no other work you need to do.
@StephenHodgson how would a device know the surroundings match another device's without anchor data?
Pretty sure the sharing service keeps track of this stuff for you. Essentially both devices add an anchor to the room and if it finds a match by the host anchor, then it downloads it. At least that's how it works in my latest PR https://github.com/Microsoft/MixedRealityToolkit-Unity/pull/742 for the SharingWorldAnchor.
I always thought that was the purpose of the rooms? If you are in the same session, you will receive information about other users joining/leaving the session. You can broadcast messages to them through CustomMessages. You can use rooms to represent physical spaces, since each room has a world anchor uploaded by the first user in the room. If someone is in room A, you can join it to share world anchors in the same physical space. If you join room B instead, you are in a different physical space and won't get room A's anchor. Of course, you can also have multiple virtual rooms mapped to one physical room/space, which might be useful for demoing in a smaller space.
Another interesting solution is in Mike Taulty's blog post, where he uses the connected WiFi network to determine if devices are in the same physical space.
As the others have mentioned, I don't think there is a surefire automated way for the HoloLens to detect shared spaces, before downloading the world anchor. If I recall, there is no built-in GPS either.
I believe the intent of the OP was to avoid uploading or downloading anchors, but somehow determine you're in the same space.
WiFi name is a good approach, like the article you linked @edwinckc . I would extend that to also try connecting to other devices using the internal IP addresses. If you're able to connect then you're at least on the same network.
yes WiFi is helpful to determine that the devices are in the same network but even with that we can not know for sure that they are in the same physical space (2 different offices with same network)
If you are using the HTK (MRTK?) Sharing Service, then anchors are shared within server rooms. That means you need to distinguish your local physical setting before you even connect to the server rooms. How you do that really depends on your specific setup. If you are in a controlled environment, you could potentially map out different physical spaces and store them locally, since world anchors persist between app sessions. Then you could connect to different rooms on the server, depending on what you found with your local anchors. Or you could try other more common approaches like QR codes, image recognition, beacons, etc. These may be more reliable if your environment is constantly changing, which makes syncing up world anchors more difficult.
Please reopen if your question was not answered.
There's no simple API that let's you do this. All suggestions above are great.
Most helpful comment
I believe the intent of the OP was to avoid uploading or downloading anchors, but somehow determine you're in the same space.
WiFi name is a good approach, like the article you linked @edwinckc . I would extend that to also try connecting to other devices using the internal IP addresses. If you're able to connect then you're at least on the same network.