Device Mapping
What is Device Mapping?
Device Mapping is a system that scans and tracks real-world objects, allowing you to place content in alignment with the real world. On the surface, it is functionally similar to VPS, but the Device Mapping system does all its processing on the device and does not require a network connection to localize. Instead, Device Mapping serializes a scan from one client device and distributes it to the others, which then deserialize the data and recreate the scanned map. This allows multiple devices to share a map and play a multiplayer experience without an Internet connection.
For a better idea of how Device Mapping works, compare it to VPS:
VPS | Device Mapping | |
---|---|---|
Where can you use it? | VPS-Activated Locations Only | Anywhere |
How is the map built? | Using scans from many users at different times | A single scan |
Do you need to scan to use the map? | No | Yes |
Do you need network connection to localize? | Yes | No |
Where does the map data live? | Niantic servers | Your device |
Localization robustness | Consistent because it generates the map from multiple scans | Robustness depends on the quality of the single scan |
How to access associated visual data | Download mesh from the internet | Extract point cloud from device map data |
High-Level API Overview
At a high level, the Device Mapping API follows these steps:
- Mapping
- Using
ARDeviceMappingManager
, scan and generate a device map. - Using
ARDeviceMap
, save the serialized device map data somewhere, such as the device's local file system.
- Using
- Tracking
- Using
ARDeviceMap
again, restore a device map from the serialized map data on the device. - Using
ARPersistentAnchorManager
, track the scanned real-world data by setting the device map via theARDeviceMappingManager
. - Once the device has achieved tracking, populate the virtual objects under
ARPersistentAnchor
to show them aligned to the real world.
- Using
Once StopMapping()
is called and the final map is generated, the ARDeviceMappingManager.DeviceMapFinalized
event triggers, allowing ARDeviceMap
to serialize the map data. ARDeviceMap
also provides the necessary API to restore this map data later on. Optionally, you can also show the user the coverage of the device map by listening to the ARDeviceMappingManager.DeviceMapUpdated
event and receiving additional device map data that allows you to do so.
Limitations
Device Mapping is subject to some of the same localization limitations as VPS, such as:
- Visual conditions (lighting, weather, time of day) changing between mapping and localization
- Mapped areas with few distinguishing features (such as grassy fields or indoor areas with little difference in color)
- Scans taken from a limited viewing angle
Without the robustness of generating the map from multiple scans, Device Mapping may perform worse than VPS if these limitations come into play. If your multiplayer experience depends on an area that changes regularly or lacks distinguishing features, consider using VPS instead.
Next Steps
To get started using Device Mapping, see (links to How-Tos go here).