Skip to content

Latest commit

 

History

History
76 lines (58 loc) · 2.88 KB

set-up-coarse-reloc-cpp-winrt.md

File metadata and controls

76 lines (58 loc) · 2.88 KB
title description author manager services ms.author ms.date ms.topic ms.service
Coarse relocalization in C++/WinRT
In-depth explanation of how to create and locate anchors using coarse relocalization in C++/WinRT.
pamistel
MehranAzimi-msft
azure-spatial-anchors
pamistel
11/20/2020
tutorial
azure-spatial-anchors

How to create and locate anchors using coarse relocalization in C++/WinRT

[!div class="op_single_selector"]

Azure Spatial Anchors can associate on-device, positioning sensor data with the anchors you create. This data can also be used to quickly determine whether there are any anchors nearby your device. For more information, see Coarse relocalization.

Prerequisites

To complete this guide, make sure you have:

[!INCLUDE Configure Provider]

// Create the sensor fingerprint provider
PlatformLocationProvider sensorProvider = PlatformLocationProvider();

// Allow GPS
SensorCapabilities sensors = sensorProvider.Sensors()
sensors.GeoLocationEnabled(true);

// Allow WiFi scanning
sensors.WifiEnabled(true);

// Populate the set of known BLE beacons' UUIDs
std::vector<winrt::hstring> uuids;
uuids.emplace_back("22e38f1a-c1b3-452b-b5ce-fdb0f39535c1");
uuids.emplace_back("a63819b9-8b7b-436d-88ec-ea5d8db2acb0");

// Allow the set of known BLE beacons
sensors.BluetoothEnabled(true);
sensors.KnownBeaconProximityUuids(uuids);

[!INCLUDE Configure Provider]

// Set the session's sensor fingerprint provider
cloudSpatialAnchorSession.LocationProvider(sensorProvider);

// Configure the near-device criteria
NearDeviceCriteria nearDeviceCriteria = NearDeviceCriteria();
nearDeviceCriteria.DistanceInMeters(5.0f);
nearDeviceCriteria.MaxResultCount(25);

// Set the session's locate criteria
anchorLocateCriteria = AnchorLocateCriteria();
anchorLocateCriteria.NearDevice(nearDeviceCriteria);
cloudSpatialAnchorSession.CreateWatcher(anchorLocateCriteria);

[!INCLUDE Locate]

[!INCLUDE Configure Provider]