ARAnchorManagerExtensions

Extensions to AR Foundation's ARAnchorManager class.

Summary

Public static functions

AddAnchor(this ARAnchorManager anchorManager, double latitude, double longitude, double altitude, Quaternion eunRotation)
Creates a new anchor at the specified geospatial location and orientation relative to the Earth.
EstimateFeatureMapQualityForHosting(this ARAnchorManager anchorManager, Pose pose)
Estimates the quality of the visual feature points seen by ARCore in the preceding few seconds and visible from the provided camera pose .
HostCloudAnchor(this ARAnchorManager anchorManager, ARAnchor anchor) Deprecated. Please use ARAnchorManagerExtensions.HostCloudAnchorAsync(this ARAnchorManager, ARAnchor, int) instead with ttlDays=1.
Creates a new Cloud Anchor using an existing local ARAnchor.
HostCloudAnchor(this ARAnchorManager anchorManager, ARAnchor anchor, int ttlDays) Deprecated. Use HostCloudAnchorAsync(this ARAnchorManager, ARAnchor, int) instead with ttlDays=1.
Creates a new Cloud Anchor with a given lifetime using an existing local ARAnchor.
HostCloudAnchorAsync(this ARAnchorManager anchorManager, ARAnchor anchor, int ttlDays)
Uses the pose and other data from anchor to host a new Cloud Anchor.
ResolveAnchorOnRooftopAsync(this ARAnchorManager anchorManager, double latitude, double longitude, double altitudeAboveRooftop, Quaternion eunRotation)
Creates an anchor at a specified horizontal position and altitude relative to the horizontal position’s rooftop.
ResolveAnchorOnTerrain(this ARAnchorManager anchorManager, double latitude, double longitude, double altitudeAboveTerrain, Quaternion eunRotation) Deprecated. Use ARAnchorManagerExtensions.ResolveAnchorOnTerrainAsync(this ARAnchorManager, double, double, double, Quaternion) instead.
Creates a ARGeospatialAnchor at a specified horizontal position and altitude relative to the horizontal position's terrain.
ResolveAnchorOnTerrainAsync(this ARAnchorManager anchorManager, double latitude, double longitude, double altitudeAboveTerrain, Quaternion eunRotation)
Asynchronously creates a ARGeospatialAnchor at a specified horizontal position and altitude relative to the horizontal position's terrain.
ResolveCloudAnchorAsync(this ARAnchorManager anchorManager, string cloudAnchorId)
Attempts to resolve a Cloud Anchor using the provided cloudAnchorId.
ResolveCloudAnchorId(this ARAnchorManager anchorManager, string cloudAnchorId) Deprecated. Use ARAnchorManagerExtensions.ResolveCloudAnchorAsync(this ARAnchorManager, string) instead.
Creates a new local Cloud Anchor from the provided Id.
SetAuthToken(this ARAnchorManager anchorManager, string authToken)
void
Set the token to use when authenticating with the ARCore API on the iOS platform.

Public static functions

AddAnchor

ARGeospatialAnchor AddAnchor(
  this ARAnchorManager anchorManager,
  double latitude,
  double longitude,
  double altitude,
  Quaternion eunRotation
)

Creates a new anchor at the specified geospatial location and orientation relative to the Earth.

Latitude and longitude are defined by the WGS84 specification, and altitude values are defined by the elevation above the WGS84 ellipsoid. To create an anchor using an altitude relative to the Earth's terrain instead of altitude above the WGS84 ellipsoid, use ARAnchorManagerExtensions.ResolveAnchorOnTerrainAsync(this ARAnchorManager, double, double, double, Quaternion).

Creating anchors near the north pole or south pole is not supported. If the latitude is within 0.1 degrees of the north pole or south pole (90 degrees or -90 degrees), this function will return null.

The rotation provided by eunRotation is a rotation with respect to an east-up-north coordinate frame. An identity rotation will have the anchor oriented such that X+ points to the east, Y+ points up away from the center of the earth, and Z+ points to the north.

An anchor's tracking state will be TrackingState.None while AREarthManager.EarthTrackingState is TrackingState.None. The tracking state will permanently become TrackingState.None if the configuration is set to GeospatialMode.Disabled.

Details
Parameters
anchorManager
The ARAnchorManager instance.
latitude
The latitude of the anchor relative to the WGS84 ellipsoid.
longitude
The longitude of the anchor relative to the WGS84 ellipsoid.
altitude
The altitude of the anchor relative to the WGS84 ellipsoid.
eunRotation
The rotation of the anchor with respect to the east-up-north coordinate frame where X+ points east, Y+ points up away from gravity, and Z+ points north. A rotation about the Y+ axis creates a rotation counterclockwise from north.
Returns
If successful, a ARGeospatialAnchor, otherwise, null.

EstimateFeatureMapQualityForHosting

FeatureMapQuality EstimateFeatureMapQualityForHosting(
  this ARAnchorManager anchorManager,
  Pose pose
)

Estimates the quality of the visual feature points seen by ARCore in the preceding few seconds and visible from the provided camera pose .

Cloud Anchors hosted using higher feature map quality will generally result in easier and more accurately resolved ARCloudAnchor poses.

Details
Parameters
anchorManager
The ARAnchorManager instance.
pose
The camera pose to use in estimating the quality.
Returns
The estimated feature map quality.

HostCloudAnchor

ARCloudAnchor HostCloudAnchor(
  this ARAnchorManager anchorManager,
  ARAnchor anchor
)

Creates a new Cloud Anchor using an existing local ARAnchor.

Deprecated. Please use ARAnchorManagerExtensions.HostCloudAnchorAsync(this ARAnchorManager, ARAnchor, int) instead with ttlDays=1.

Details
Parameters
anchorManager
The ARAnchorManager instance.
anchor
The local ARAnchor to be used as the basis to host a new Cloud Anchor.
Returns
If successful, a ARCloudAnchor, otherwise null.

HostCloudAnchor

ARCloudAnchor HostCloudAnchor(
  this ARAnchorManager anchorManager,
  ARAnchor anchor,
  int ttlDays
)

Creates a new Cloud Anchor with a given lifetime using an existing local ARAnchor.

Deprecated. Use HostCloudAnchorAsync(this ARAnchorManager, ARAnchor, int) instead with ttlDays=1.

Details
Parameters
anchorManager
The ARAnchorManager instance.
anchor
The local ARAnchor to be used as the basis to host a new Cloud Anchor.
ttlDays
The lifetime of the anchor in days. Must be positive. The maximum allowed value is 1 if using an API Key to authenticate with the ARCore API, otherwise the maximum allowed value is 365.
Returns
If successful, an ARCloudAnchor, otherwise null.

HostCloudAnchorAsync

HostCloudAnchorPromise HostCloudAnchorAsync(
  this ARAnchorManager anchorManager,
  ARAnchor anchor,
  int ttlDays
)

Uses the pose and other data from anchor to host a new Cloud Anchor.

A Cloud Anchor is assigned an identifier that can be used to create an ARAnchor in the same position in subsequent sessions across devices using ARAnchorManagerExtensions.ResolveCloudAnchorAsync(this ARAnchorManager, string). See the Cloud Anchors developer guide for more information.

The duration that a Cloud Anchor can be resolved for is specified by ttlDays. When using Keyless authorization or Token authorization, the maximum allowed value is 365 days. When using an API Key to authenticate with the ARCore API, the maximum allowed value is 1 day.

Cloud Anchors requires a ARCoreExtensionsConfig.CloudAnchorMode with CloudAnchorMode.Enabled set on this session. Use ARCoreExtensionsConfig.CloudAnchorMode to enable the Cloud Anchors API.

Hosting a Cloud Anchor works best when ARCore is able to create a good feature map around the ARAnchor. Use EstimateFeatureMapQualityForHosting(this ARAnchorManager anchorManager, Pose) to determine the quality of visual features seen by ARCore in the preceding few seconds. Cloud Anchors hosted using higher quality features will generally result in quicker and more accurately resolved Cloud Anchor poses.

This launches an asynchronous operation used to query the Google Cloud ARCore API. See InterruptiblePromise for information on obtaining results and cancelling the operation.

ARCore can have up to 40 simultaneous Cloud Anchor operations, including resolved anchors and active hosting operations.

Details
Parameters
anchorManager
The ARAnchorManager instance.
anchor
The local ARAnchor to be used as the basis to host a new Cloud Anchor.
ttlDays
The lifetime of the anchor in days. Must be positive. The maximum allowed value is 1 if using an API Key to authenticate with the ARCore API, otherwise the maximum allowed value is 365.
Returns
Returns a HostCloudAnchorPromise. See InterruptiblePromise for more information on how to retrieve results from the Promise.

ResolveAnchorOnRooftopAsync

ResolveAnchorOnRooftopPromise ResolveAnchorOnRooftopAsync(
  this ARAnchorManager anchorManager,
  double latitude,
  double longitude,
  double altitudeAboveRooftop,
  Quaternion eunRotation
)

Creates an anchor at a specified horizontal position and altitude relative to the horizontal position’s rooftop.

See the Rooftop anchors developer guide for more information.

The specified altitudeAboveRooftop is interpreted to be relative to the top of a building at the given horizontal location, rather than relative to the WGS84 ellipsoid. If there is no building at the given location, then the altitude is interpreted to be relative to the terrain instead. Specifying an altitude of 0 will position the anchor directly on the rooftop whereas specifying a positive altitude will position the anchor above the rooftop, against the direction of gravity.

This launches an asynchronous operation used to query the Google Cloud ARCore API. See InterruptiblePromise for information on obtaining results and cancelling the operation.

You may resolve multiple anchors at a time, but a session cannot be tracking more than 100 Terrain and Rooftop Anchors at time.

Creating a Rooftop anchor requires AREarthManager.EarthState to be EarthState.Enabled and AREarthManager.EarthTrackingState to be TrackingState.Tracking or TrackingState.Paused. If it is not, then ResolveAnchorOnRooftopResult.Anchor will be null. This call also requires a working internet connection to communicate with the ARCore API on Google Cloud. See Enable the Geospatial API for more details on required permissions and setup steps. ARCore will continue to retry if it is unable to establish a connection to the ARCore service.

Latitude and longitude are defined by the WGS84 specification.

The rotation provided by eunRotation is a rotation with respect to an east-up-north coordinate frame. An identity rotation will have the anchor oriented such that X+ points to the east, Y+ points up away from the center of the earth, and Z+ points to the north.

To create a quaternion that represents a clockwise angle theta from north around the +Y anchor frame axis, use the following formula: Quaternion.AngleAxis(180f - theta, Vector3.up);

Details
Parameters
anchorManager
The ARAnchorManager instance.
latitude
The latitude of the anchor relative to the WGS84 ellipsoid.
longitude
The longitude of the anchor relative to the WGS84 ellipsoid.
altitudeAboveRooftop
The altitude of the anchor above the Earth's Rooftop.
eunRotation
The rotation of the anchor with respect to the east-up-north coordinate frame where X+ points east, Y+ points up away from gravity, and Z+ points north. A rotation about the Y+ axis creates a rotation counterclockwise from north.
Returns
Returns a ResolveAnchorOnRooftopPromise. See InterruptiblePromise for more information on how to retrieve results from the Promise.

ResolveAnchorOnTerrain

ARGeospatialAnchor ResolveAnchorOnTerrain(
  this ARAnchorManager anchorManager,
  double latitude,
  double longitude,
  double altitudeAboveTerrain,
  Quaternion eunRotation
)

Creates a ARGeospatialAnchor at a specified horizontal position and altitude relative to the horizontal position's terrain.

See the Terrain anchors developer guide for more information. If the altitude relative to the WGS84 ellipsoid is known, use ARAnchorManagerExtensions.AddAnchor(this ARAnchorManager, double, double, double, Quaternion) instead.

The specified altitudeAboveTerrain is interpreted to be relative to the Earth's terrain (or floor) at the specified latitude/longitude geospatial coordinates, rather than relative to the WGS84 ellipsoid. Specifying an altitude of 0 will position the anchor directly on the terrain (or floor) whereas specifying a positive altitude will position the anchor above the terrain (or floor), against the direction of gravity.

This creates a new ARGeospatialAnchor and schedules a task to resolve the anchor's pose using the given parameters. You may resolve multiple anchors at a time, but a session cannot be tracking more than 100 Terrain anchors at time.

The returned Terrain anchor will have its ARGeospatialAnchor.terrainAnchorState set to TerrainAnchorState.TaskInProgress, and its ARGeospatialAnchor.trackingState set to TrackingState.None. The anchor will remain in this state until its pose has been successfully resolved. If the resolving task results in an error, the anchor's ARGeospatialAnchor.terrainAnchorState will detail error information.

Creating a Terrain anchor requires AREarthManager.EarthState to be EarthState.Enabled, and AREarthManager.EarthTrackingState to be TrackingState.Tracking or TrackingState.Paused. If it is not, then If it is not, then this function returns null. This call also requires a working internet. connection to communicate with the ARCore API on Google Cloud. ARCore will continue to retry if it is unable to establish a connection to the ARCore service.

Latitude and longitude are defined by the WGS84 specification. Creating anchors near the north pole or south pole is not supported. If the latitude is within 0.1 degrees of the north pole or south pole (90 degrees or -90 degrees), this function will return null.

The rotation provided by eunRotation is a rotation with respect to an east-up-north coordinate frame. An identity rotation will have the anchor oriented such that X+ points to the east, Y+ points up away from the center of the earth, and Z+ points to the north.

An anchor's tracking state will be TrackingState.None while AREarthManager.EarthTrackingState is TrackingState.None. The tracking state will permanently become TrackingState.None if the configuration is set to GeospatialMode.Disabled.

Deprecated. Use ARAnchorManagerExtensions.ResolveAnchorOnTerrainAsync(this ARAnchorManager, double, double, double, Quaternion) instead.

Details
Parameters
anchorManager
The ARAnchorManager instance.
latitude
The latitude of the anchor relative to the WGS84 ellipsoid.
longitude
The longitude of the anchor relative to the WGS84 ellipsoid.
altitudeAboveTerrain
The altitude of the anchor above the Earth's terrain (or floor).
eunRotation
The rotation of the anchor with respect to the east-up-north coordinate frame where X+ points east, Y+ points up away from gravity, and Z+ points north. A rotation about the Y+ axis creates a rotation counterclockwise from north.
Returns
If successful, a ARGeospatialAnchor, otherwise, null.

ResolveAnchorOnTerrainAsync

ResolveAnchorOnTerrainPromise ResolveAnchorOnTerrainAsync(
  this ARAnchorManager anchorManager,
  double latitude,
  double longitude,
  double altitudeAboveTerrain,
  Quaternion eunRotation
)

Asynchronously creates a ARGeospatialAnchor at a specified horizontal position and altitude relative to the horizontal position's terrain.

See the Terrain anchors developer guide for more information.

The specified altitudeAboveTerrain is interpreted to be relative to the terrain at the specified latitude/longitude geodetic coordinates, rather than relative to the WGS-84 ellipsoid. Specifying an altitude of 0 will position the anchor directly on the terrain whereas specifying a positive altitude will position the anchor above the terrain, against the direction of gravity.

This launches an asynchronous operation used to query the Google Cloud ARCore API. See InterruptiblePromise for information on obtaining results and cancelling the operation.

Creating anchors near the north pole or south pole is not supported. If the latitude is within 0.1 degrees of the north pole or south pole (90 degrees or -90 degrees), ResolveAnchorOnTerrainResult.Anchor will be null.

This schedules a task to resolve the anchor's pose using the given parameters. You may resolve multiple anchors at a time, but a session cannot be tracking more than 100 Terrain and Rooftop anchors at time.

Creating a Terrain anchor requires an AREarthManager.EarthState to be EarthState.Enabled and AREarthManager.EarthTrackingState to be TrackingState.Tracking or TrackingState.Paused. If it is not, then ResolveAnchorOnTerrainResult.Anchor will be null. This call also requires a working internet connection to communicate with the ARCore API on Google Cloud. See Enable the Geospatial API for more details on required permissions and setup steps. ARCore will continue to retry if it is unable to establish a connection to the ARCore service.

Latitude and longitude are defined by the WGS84 specification.

The rotation provided by eunRotation is a rotation with respect to an east-up-north coordinate frame. An identity rotation will have the anchor oriented such that X+ points to the east, Y+ points up away from the center of the earth, and Z+ points to the north.

To create a quaternion that represents a clockwise angle theta from north around the +Y anchor frame axis, use the following formula: Quaternion.AngleAxis(180f - theta, Vector3.up);

Details
Parameters
anchorManager
The ARAnchorManager instance.
latitude
The latitude of the anchor relative to the WGS84 ellipsoid.
longitude
The longitude of the anchor relative to the WGS84 ellipsoid.
altitudeAboveTerrain
The altitude of the anchor above the Earth's terrain.
eunRotation
The rotation of the anchor with respect to the east-up-north coordinate frame where X+ points east, Y+ points up away from gravity, and Z+ points north. A rotation about the Y+ axis creates a rotation counterclockwise from north.
Returns
Returns a ResolveAnchorOnTerrainPromise. See InterruptiblePromise for more information on how to retrieve results from the Promise.

ResolveCloudAnchorAsync

ResolveCloudAnchorPromise ResolveCloudAnchorAsync(
  this ARAnchorManager anchorManager,
  string cloudAnchorId
)

Attempts to resolve a Cloud Anchor using the provided cloudAnchorId.

The Cloud Anchor must previously have been hosted by ARAnchorManagerExtensions.HostCloudAnchorAsync(this ARAnchorManager, ARAnchor, int) or another Cloud Anchor hosting method within the allotted ttlDays. See the Cloud Anchors developer guide for more information.

When resolving a Cloud Anchor, the ARCore API periodically compares visual features from the scene against the anchor's 3D feature map to pinpoint the user's position and orientation relative to the anchor. When it finds a match, the task completes.

This launches an asynchronous operation used to query the Google Cloud ARCore API. See InterruptiblePromise for information on obtaining results and cancelling the operation.

Cloud Anchors requires a ARCoreExtensionsConfig.CloudAnchorMode with CloudAnchorMode.Enabled set on this session. Use ARCoreExtensionsConfig.CloudAnchorMode to enable the Cloud Anchors API.

ARCore can have up to 40 simultaneous Cloud Anchor operations, including resolved anchors and active hosting operations.

Details
Parameters
anchorManager
The ARAnchorManager instance.
cloudAnchorId
The Cloud Anchor ID to resolve.
Returns
Returns a ResolveCloudAnchorPromise. See InterruptiblePromise for more information on how to retrieve results from the Promise.

ResolveCloudAnchorId

ARCloudAnchor ResolveCloudAnchorId(
  this ARAnchorManager anchorManager,
  string cloudAnchorId
)

Creates a new local Cloud Anchor from the provided Id.

A session can be resolving up to 40 Cloud Anchors at a given time. If resolving fails, the anchor will be automatically removed from the session.

Deprecated. Use ARAnchorManagerExtensions.ResolveCloudAnchorAsync(this ARAnchorManager, string) instead.

Details
Parameters
anchorManager
The ARAnchorManager instance.
cloudAnchorId
String representing the Cloud Anchor.
Returns
If successful, a ARCloudAnchor, otherwise null.

SetAuthToken

void SetAuthToken(
  this ARAnchorManager anchorManager,
  string authToken
)

Set the token to use when authenticating with the ARCore API on the iOS platform.

This should be called each time the application's token is refreshed.

Details
Parameters
anchorManager
The ARAnchorManager instance.
authToken
The authentication token to set.