Skip to main content
←API Reference ←com.nianticspatial.nsdk.vps2

Vps2Session

↳ extends SessionBase
A session for VPS2 localization.

Declaration​

class Vps2Session

Properties​

NameTypeSummary
anchorPollingIntervalMsLong
-
anchorUpdatesFlow<AnchorUpdate>
Flow of anchor updates for all tracked anchors.
Anchors are automatically added when created via [trackAnchor] or [createAnchor].
ardkHandleLong
-
debuggerEventsFlow<VpsDebuggerDataEvent>
Flow of VPS debugger events.
Each emission is a single [VpsDebuggerDataEvent] from the latest delta batch.
Events are emitted only when new ones are available. Enable logging via
[Vps2Config.enableVpsDebugger] before starting the session.
localizationPollingIntervalMsLong
-
localizationRequestRecordsFlow<Vps2LocalizationRequestRecord>
Flow of localization request records.
Each emission is a single [Vps2LocalizationRequestRecord] from the latest batch.
Records are emitted only when new ones are available.
localizationUpdatesFlow<Vps2Localization>
Flow of the latest localization snapshot.
This is useful for consumers that want to reactively drive UI or downstream computations
without manually polling [getLatestLocalization].

Functions​

NameTypeSummary
anchorIdToStringString
Convert a VPS2 anchor id (32-byte ASCII hex) to a printable string.
configurevoid
Configure VPS2. Must be called while stopped.
createAnchorUUID
Create and start tracking an anchor at the specified pose.
featureStatusFeatureStatus
-
getAnchorPayloadString?
Gets the payload data of a specified anchor.
The payload encodes the data needed to localize an anchor across multiple devices or sessions.
It can be shared or stored for later use with [trackAnchor].
getAnchorUpdateAnchorUpdate
Gets the latest tracking update for a specified anchor.
getAssetTrackingDataVps2AssetTrackingData?
Gets the pose and tracking confidence of a VPS asset's origin in the device's AR tracking space.
Call this regularly to place content authored in the asset's coordinate space: the pose is
refined as the device moves and VPS relocalizes.
Tracking starts on demand and may take time to spin up, so keep polling.
Data is only served while the asset is fully tracked — no localization, limited, and lost all
return null, and content should not be placed in any of those states. This is independent of
the VPS2 tracking state, which describes the geolocation estimate: an asset with no
georeference serves tracking data while the tracking state stays coarse.
This function only accepts a VPS map asset ID, not a mesh or splat asset ID.
getDeviceGeolocationVps2GeolocationData?
Get the geolocation of the device's last known camera pose.
getLatestDebuggerEventsList<VpsDebuggerDataEvent>
Get VPS debugger events since the last call.
getLatestLocalizationVps2Localization
Gets the most recent VPS2 localization result.
The returned localization contains the spatial mapping between
the device's AR coordinate space and real-world geolocation.
getLatestLocalizationRequestRecordsList<Vps2LocalizationRequestRecord>
Get diagnostic localization request records since the last call.
getPosePose
Convert a geolocation to an AR pose using a localization snapshot.
In most cases you want the overload that uses the latest localization automatically; use
this one only when a batch of geolocations must share a single snapshot.
getTrackedAnchorsSet<UUID>
Get the set of all tracked anchors.
insertCustomDebuggerEventvoid
Insert a custom event into the VPS debugger log.
localizevoid
Requests localization to a site, identified by its site ID.
Localizes against the site's production-deployed VPS assets and only those: an asset that
has not been deployed to production cannot be localized against. This is an asynchronous
operation: progress is reported on [localizationRequestRecords] as a record of type
[Vps2LocalizationRequestType.ASSET_INFO] — [Vps2LocalizationRequestStatus.PENDING] on
dispatch, then [Vps2LocalizationRequestStatus.COMPLETED], or
[Vps2LocalizationRequestStatus.FAILED] with the record's error set (e.g.
[Vps2LocalizationError.SITE_NOT_FOUND] when no such site exists, or
[Vps2LocalizationError.ASSETS_NOT_FOUND] when the site has nothing localizable in it).
COMPLETED means every production-deployed asset in the site was submitted for
localization, not that localization succeeded — observe [localizationUpdates] for the outcome.
Requests are additive: calling this again does not disturb a request already in flight,
and the sites accumulate. Each request produces its own records, but the caller is not
given its record identifier, so records from concurrent requests are distinguishable
only by the order in which they arrive.
May be called before [start]; requests are deferred and dispatched in order when VPS2
starts.
Note: assets already submitted for localization remain in the localization set for the
lifetime of the session. There is no way to stop localizing against a site once its
assets have been submitted, and no way to cancel a request in progress. Each additional
site permanently increases the size of every cloud localization request and the
per-frame target-selection cost, so keep the number of sites small.
onDestroyvoid
-
onInitvoid
-
removeAnchorvoid
Stop tracking an anchor.
startvoid
-
stopvoid
-
trackAnchorUUID
Start tracking an anchor specified by a base64 payload.