XR_ANDROID_geospatial_anchor
Name String
XR_ANDROID_geospatial_anchor
Extension Type
Instance extension
Registered Extension Number
798
Revision
1
Ratification Status
Not ratified
Extension and Version Dependencies
XR_ANDROID_geospatial
and
XR_EXT_future
and
XR_EXT_spatial_entity
and
XR_EXT_spatial_anchor
Last Modified Date
2025-10-30
IP Status
No known IP claims.
Contributors
John Ullman, Google
Ben King, Google
Nihav Jain, Google
Jared Finder, Google
Overview
This extension provides Geospatial Anchors and Surface Anchors that build on the base Geospatial extension. Geospatial Anchors are anchors that are positioned in space relative to the Earth at a given latitude, longitude and altitude. Surface Anchors are Earth-relative anchors which are placed at a given latitude, longitude, and altitude relative to a surface as known by the Visual Positioning Service. As the runtime’s accuracy of its position relative to the Earth improves, the Anchor’s pose will adjust accordingly.
System Capability for Geospatial Anchors
The XrSystemGeospatialAnchorPropertiesANDROID structure is defined as:
typedef struct XrSystemGeospatialAnchorPropertiesANDROID {
XrStructureType type;
void* next;
uint32_t maxSurfaceAnchorCount;
} XrSystemGeospatialAnchorPropertiesANDROID;
Member Descriptions
typeis the XrStructureType of this structure.nextisNULLor a pointer to the next structure in a structure chain. No such structures are defined in core OpenXR or this extension.maxSurfaceAnchorCountis auint32_tindicating the maximum number of surface anchors that can be created.
An application can inspect geospatial anchor capabilities of the system by chaining an XrSystemGeospatialAnchorPropertiesANDROID structure to the XrSystemProperties when calling xrGetSystemProperties .
If XrSystemGeospatialPropertiesANDROID :: supportsGeospatial is XR_TRUE , then maxSurfaceAnchorCount indicates the maximum number of surface anchors the runtime supports. The limit must be greater than 0 in this case.
If XrSystemGeospatialPropertiesANDROID :: supportsGeospatial is not XR_TRUE , then maxSurfaceAnchorCount must be 0.
Valid Usage (Implicit)
- The
XR_ANDROID_geospatial_anchorextension must be enabled prior to using XrSystemGeospatialAnchorPropertiesANDROID -
typemust beXR_TYPE_SYSTEM_GEOSPATIAL_ANCHOR_PROPERTIES_ANDROID -
nextmust beNULLor a valid pointer to the next structure in a structure chain
Plane Tracking for Anchors
The XrGeospatialTrackerAnchorTrackingInfoANDROID structure is defined as:
typedef struct XrGeospatialTrackerAnchorTrackingInfoANDROID {
XrStructureType type;
const void* next;
XrBool32 shouldTrackPlanes;
} XrGeospatialTrackerAnchorTrackingInfoANDROID;
Member Descriptions
typeis the XrStructureType of this structure.nextisNULLor a pointer to the next structure in a structure chain.shouldTrackPlanesis anXrBool32indicating if the geospatial tracker will track planes to improve positioning of surface-locked anchors.
Plane tracking can be enabled to improve positioning of surface-locked anchors.
If the application wants to enable plane tracking to improve surface anchor poses, it can chain an XrGeospatialTrackerAnchorTrackingInfoANDROID structure to XrGeospatialTrackerCreateInfoANDROID when calling xrCreateGeospatialTrackerANDROID .
Valid Usage (Implicit)
- The
XR_ANDROID_geospatial_anchorextension must be enabled prior to using XrGeospatialTrackerAnchorTrackingInfoANDROID -
typemust beXR_TYPE_GEOSPATIAL_TRACKER_ANCHOR_TRACKING_INFO_ANDROID -
nextmust beNULLor a valid pointer to the next structure in a structure chain
Geospatial Anchors
The xrCreateGeospatialAnchorANDROID function is defined as:
XrResult xrCreateGeospatialAnchorANDROID(
XrSpatialContextEXT spatialContext,
const XrGeospatialAnchorCreateInfoANDROID* createInfo,
XrSpatialEntityIdEXT* anchorEntityId);
Parameter Descriptions
spatialContextis the XrSpatialContextEXT to create the anchor in. The context must be configured forXR_SPATIAL_CAPABILITY_ANCHOR_EXTotherwise the runtime must returnXR_ERROR_VALIDATION_FAILURE.createInfois a pointer to XrGeospatialAnchorCreateInfoANDROID containing anchor creation parameters.anchorEntityIdis a pointer toXrSpatialEntityIdEXTin which the anchor entity ID is returned.
If the XrGeospatialTrackerANDROID specified in XrGeospatialAnchorCreateInfoANDROID :: geospatialTracker is not in the XR_GEOSPATIAL_TRACKER_STATE_RUNNING_ANDROID state, the runtime must return XR_ERROR_GEOSPATIAL_TRACKER_NOT_RUNNING_ANDROID .
Valid Usage (Implicit)
- The
XR_ANDROID_geospatial_anchorextension must be enabled prior to calling xrCreateGeospatialAnchorANDROID -
spatialContextmust be a valid XrSpatialContextEXT handle -
createInfomust be a pointer to a valid XrGeospatialAnchorCreateInfoANDROID structure -
anchorEntityIdmust be a pointer to anXrSpatialEntityIdEXTvalue
Return Codes
XR_SUCCESSXR_SESSION_LOSS_PENDING
XR_ERROR_FUNCTION_UNSUPPORTEDXR_ERROR_GEOSPATIAL_COORDINATES_INVALID_ANDROIDXR_ERROR_GEOSPATIAL_TRACKER_NOT_RUNNING_ANDROIDXR_ERROR_HANDLE_INVALIDXR_ERROR_INSTANCE_LOSTXR_ERROR_LIMIT_REACHEDXR_ERROR_OUT_OF_MEMORYXR_ERROR_RUNTIME_FAILUREXR_ERROR_SESSION_LOSTXR_ERROR_VALIDATION_FAILURE
The XrGeospatialAnchorCreateInfoANDROID structure is defined as:
typedef struct XrGeospatialAnchorCreateInfoANDROID {
XrStructureType type;
const void* next;
XrGeospatialTrackerANDROID geospatialTracker;
XrGeospatialPoseANDROID geospatialPose;
} XrGeospatialAnchorCreateInfoANDROID;
Member Descriptions
typeis the XrStructureType of this structure.nextisNULLor a pointer to the next structure in a structure chain.geospatialTrackeris the XrGeospatialTrackerANDROID to use for creating the anchor.geospatialPoseis a pointer to XrGeospatialPoseANDROID defining the anchor’s location and orientation.
Valid Usage (Implicit)
- The
XR_ANDROID_geospatial_anchorextension must be enabled prior to using XrGeospatialAnchorCreateInfoANDROID -
typemust beXR_TYPE_GEOSPATIAL_ANCHOR_CREATE_INFO_ANDROID -
nextmust beNULLor a valid pointer to the next structure in a structure chain -
geospatialTrackermust be a valid XrGeospatialTrackerANDROID handle -
geospatialPosemust be a valid XrGeospatialPoseANDROID structure
Surface Anchors
Surface anchors are anchors placed relative to a surface, such as terrain or rooftops.
The XrSurfaceAnchorTypeANDROID enumeration is defined as:
typedef enum XrSurfaceAnchorTypeANDROID {
XR_SURFACE_ANCHOR_TYPE_TERRAIN_ANDROID = 1,
XR_SURFACE_ANCHOR_TYPE_ROOFTOP_ANDROID = 2,
XR_SURFACE_ANCHOR_TYPE_MAX_ENUM_ANDROID = 0x7FFFFFFF
} XrSurfaceAnchorTypeANDROID;
The XrSurfaceAnchorTypeANDROID enumeration specifies the type of surface an anchor is relative to.
The enumerants have the following values:
Enum Description
XR_SURFACE_ANCHOR_TYPE_TERRAIN_ANDROID
Type of an anchor placed relative to the ground.
XR_SURFACE_ANCHOR_TYPE_ROOFTOP_ANDROID
Type of an anchor placed relative to the rooftop, or ground where there is no building.
The xrCreateSurfaceAnchorAsyncANDROID function is defined as:
XrResult xrCreateSurfaceAnchorAsyncANDROID(
XrSpatialContextEXT spatialContext,
const XrSurfaceAnchorCreateInfoANDROID* createInfo,
XrFutureEXT* future);
Parameter Descriptions
spatialContextis the XrSpatialContextEXT to create the anchor in.createInfois a pointer to XrSurfaceAnchorCreateInfoANDROID containing anchor creation parameters.futureis a pointer toXrFutureEXTthat will hold the result of the asynchronous operation.
The xrCreateSurfaceAnchorAsyncANDROID function begins an asynchronous operation to create a surface anchor. Unlike standard geospatial anchors, the runtime may fetch terrain data to determine the correct altitude. The runtime must return XR_ERROR_LIMIT_REACHED if the application attempts to create more than XrSystemGeospatialAnchorPropertiesANDROID :: maxSurfaceAnchorCount surface anchors at a time. If the XrGeospatialTrackerANDROID specified in XrSurfaceAnchorCreateInfoANDROID :: geospatialTracker is not in the XR_GEOSPATIAL_TRACKER_STATE_RUNNING_ANDROID state, the runtime must return XR_ERROR_GEOSPATIAL_TRACKER_NOT_RUNNING_ANDROID . The operation may fail asynchronously with result XR_ERROR_SURFACE_ANCHOR_LOCATION_UNSUPPORTED_ANDROID if there is no surface data for the given location. The runtime must return XR_ERROR_VALIDATION_FAILURE if XR_SPATIAL_CAPABILITY_ANCHOR_EXT was not configured for spatialContext .
Valid Usage (Implicit)
- The
XR_ANDROID_geospatial_anchorextension must be enabled prior to calling xrCreateSurfaceAnchorAsyncANDROID -
spatialContextmust be a valid XrSpatialContextEXT handle -
createInfomust be a pointer to a valid XrSurfaceAnchorCreateInfoANDROID structure -
futuremust be a pointer to anXrFutureEXTvalue
Return Codes
XR_SUCCESSXR_SESSION_LOSS_PENDING
XR_ERROR_FUNCTION_UNSUPPORTEDXR_ERROR_GEOSPATIAL_COORDINATES_INVALID_ANDROIDXR_ERROR_GEOSPATIAL_TRACKER_NOT_RUNNING_ANDROIDXR_ERROR_HANDLE_INVALIDXR_ERROR_INSTANCE_LOSTXR_ERROR_LIMIT_REACHEDXR_ERROR_OUT_OF_MEMORYXR_ERROR_RUNTIME_FAILUREXR_ERROR_SESSION_LOSTXR_ERROR_VALIDATION_FAILURE
The XrSurfaceAnchorCreateInfoANDROID structure is defined as:
typedef struct XrSurfaceAnchorCreateInfoANDROID {
XrStructureType type;
const void* next;
XrGeospatialTrackerANDROID geospatialTracker;
XrSurfaceAnchorTypeANDROID surfaceAnchorType;
XrQuaternionf eastUpSouthOrientation;
double latitude;
double longitude;
double altitudeRelativeToSurface;
} XrSurfaceAnchorCreateInfoANDROID;
Member Descriptions
typeis the XrStructureType of this structure.nextisNULLor a pointer to the next structure in a structure chain.geospatialTrackeris the XrGeospatialTrackerANDROID to use.surfaceAnchorTypeis the XrSurfaceAnchorTypeANDROID for the anchor.eastUpSouthOrientationis the orientation with respect to a coordinate system where +X=East, +Y=Up and +Z=South.latitudeis the latitude in degrees, between -89.9 and +89.9.longitudeis the longitude in degrees, between -180 and +180.altitudeRelativeToSurfaceis the altitude in meters relative to the surface specified bysurfaceAnchorType.
Valid Usage (Implicit)
- The
XR_ANDROID_geospatial_anchorextension must be enabled prior to using XrSurfaceAnchorCreateInfoANDROID -
typemust beXR_TYPE_SURFACE_ANCHOR_CREATE_INFO_ANDROID -
nextmust beNULLor a valid pointer to the next structure in a structure chain -
geospatialTrackermust be a valid XrGeospatialTrackerANDROID handle -
surfaceAnchorTypemust be a valid XrSurfaceAnchorTypeANDROID value -
latitudemust be a validdoublevalue -
longitudemust be a validdoublevalue -
altitudeRelativeToSurfacemust be a validdoublevalue
The xrCreateSurfaceAnchorCompleteANDROID function is defined as:
XrResult xrCreateSurfaceAnchorCompleteANDROID(
XrSpatialContextEXT spatialContext,
XrFutureEXT future,
XrSurfaceAnchorCreateCompletionANDROID* completion);
Parameter Descriptions
spatialContextis the XrSpatialContextEXT used for creation.futureis theXrFutureEXTreturned by xrCreateSurfaceAnchorAsyncANDROID .completionis a pointer to XrSurfaceAnchorCreateCompletionANDROID that receives the result.
Valid Usage (Implicit)
- The
XR_ANDROID_geospatial_anchorextension must be enabled prior to calling xrCreateSurfaceAnchorCompleteANDROID -
spatialContextmust be a valid XrSpatialContextEXT handle -
completionmust be a pointer to an XrSurfaceAnchorCreateCompletionANDROID structure
Return Codes
XR_SUCCESSXR_SESSION_LOSS_PENDING
XR_ERROR_FUNCTION_UNSUPPORTEDXR_ERROR_FUTURE_INVALID_EXTXR_ERROR_FUTURE_PENDING_EXTXR_ERROR_HANDLE_INVALIDXR_ERROR_INSTANCE_LOSTXR_ERROR_LIMIT_REACHEDXR_ERROR_OUT_OF_MEMORYXR_ERROR_RUNTIME_FAILUREXR_ERROR_SESSION_LOSTXR_ERROR_VALIDATION_FAILURE
The XrSurfaceAnchorCreateCompletionANDROID structure holds the result of an asynchronous surface anchor creation.
typedef struct XrSurfaceAnchorCreateCompletionANDROID {
XrStructureType type;
void* next;
XrResult futureResult;
XrSpatialEntityIdEXT anchorEntityId;
} XrSurfaceAnchorCreateCompletionANDROID;
Member Descriptions
typeis the XrStructureType of this structure.nextisNULLor a pointer to the next structure in a structure chain.futureResultis the XrResult of the creation operation. IffutureResultisXR_ERROR_GEOSPATIAL_CLOUD_AUTH_FAILED_ANDROID, a structure in thenextchain may provide more information about the failure.anchorEntityIdis theXrSpatialEntityIdEXTof the created anchor, or XR_NULL_SPATIAL_ENTITY_ID_EXT iffutureResultis notXR_SUCCESS.
Future Return Codes
futureResult values:
XR_SUCCESSXR_SESSION_LOSS_PENDING
XR_ERROR_RUNTIME_FAILUREXR_ERROR_INSTANCE_LOSTXR_ERROR_SESSION_LOSTXR_ERROR_OUT_OF_MEMORYXR_ERROR_LIMIT_REACHEDXR_ERROR_GEOSPATIAL_TRACKER_NOT_RUNNING_ANDROIDXR_ERROR_SURFACE_ANCHOR_LOCATION_UNSUPPORTED_ANDROIDXR_ERROR_GEOSPATIAL_CLOUD_AUTH_FAILED_ANDROID
Valid Usage (Implicit)
- The
XR_ANDROID_geospatial_anchorextension must be enabled prior to using XrSurfaceAnchorCreateCompletionANDROID -
typemust beXR_TYPE_SURFACE_ANCHOR_CREATE_COMPLETION_ANDROID -
nextmust beNULLor a valid pointer to the next structure in a structure chain -
futureResultmust be a valid XrResult value
Example
Create Terrain Anchor
PFN_xrCreateSpatialContextAsyncEXT xrCreateSpatialContextAsyncEXT;
PFN_xrCreateSpatialContextCompleteEXT xrCreateSpatialContextCompleteEXT;
PFN_xrCreateSurfaceAnchorAsyncANDROID xrCreateSurfaceAnchorAsyncANDROID;
PFN_xrPollFutureEXT xrPollFutureEXT;
PFN_xrCreateSurfaceAnchorCompleteANDROID xrCreateSurfaceAnchorCompleteANDROID;
XrInstance instance;
XrSession session;
XrGeospatialTrackerANDROID geospatialTracker;
// Create a spatial context
XrSpatialContextEXT spatialContext{};
{
std::vector<XrSpatialComponentTypeEXT> enabledComponents = {
XR_SPATIAL_COMPONENT_TYPE_ANCHOR_EXT,
};
XrSpatialCapabilityConfigurationAnchorEXT
anchorConfig{XR_TYPE_SPATIAL_CAPABILITY_CONFIGURATION_ANCHOR_EXT};
anchorConfig.capability = XR_SPATIAL_CAPABILITY_ANCHOR_EXT;
anchorConfig.enabledComponentCount = enabledComponents.size();
anchorConfig.enabledComponents = enabledComponents.data();
std::array<XrSpatialCapabilityConfigurationBaseHeaderEXT*, 1> capabilityConfigs = {
reinterpret_cast<XrSpatialCapabilityConfigurationBaseHeaderEXT*>(&anchorConfig),
};
XrSpatialContextCreateInfoEXT spatialContextCreateInfo{XR_TYPE_SPATIAL_CONTEXT_CREATE_INFO_EXT};
spatialContextCreateInfo.capabilityConfigCount = capabilityConfigs.size();
spatialContextCreateInfo.capabilityConfigs = capabilityConfigs.data();
XrFutureEXT createContextFuture;
CHK_XR(xrCreateSpatialContextAsyncEXT(session, &spatialContextCreateInfo, &createContextFuture));
// ... wait until future is ready ...
XrCreateSpatialContextCompletionEXT contextCompletion{XR_TYPE_CREATE_SPATIAL_CONTEXT_COMPLETION_EXT};
CHK_XR(xrCreateSpatialContextCompleteEXT(session, createContextFuture, &contextCompletion));
if (contextCompletion.futureResult != XR_SUCCESS) {
return;
}
spatialContext = contextCompletion.spatialContext;
}
XrSurfaceAnchorCreateInfoANDROID anchorCreateInfo{
XR_TYPE_SURFACE_ANCHOR_CREATE_INFO_ANDROID};
anchorCreateInfo.surfaceAnchorType = XR_SURFACE_ANCHOR_TYPE_TERRAIN_ANDROID;
anchorCreateInfo.eastUpSouthOrientation = {0, 0, 0, 1};
anchorCreateInfo.latitude = 37.7749;
anchorCreateInfo.longitude = -122.4194;
anchorCreateInfo.altitudeRelativeToSurface = 0;
anchorCreateInfo.geospatialTracker = geospatialTracker;
XrFutureEXT anchorFuture = XR_NULL_FUTURE_EXT;
CHK_XR(xrCreateSurfaceAnchorAsyncANDROID(spatialContext, &anchorCreateInfo, &anchorFuture));
XrFuturePollInfoEXT anchorPollInfo{XR_TYPE_FUTURE_POLL_INFO_EXT};
XrFuturePollResultEXT anchorPollResult{XR_TYPE_FUTURE_POLL_RESULT_EXT};
anchorPollInfo.future = anchorFuture;
anchorPollResult.state = XR_FUTURE_STATE_PENDING_EXT;
while (anchorPollResult.state == XR_FUTURE_STATE_PENDING_EXT) {
// Do in render loop/state loop.
CHK_XR(xrPollFutureEXT(instance, &anchorPollInfo, &anchorPollResult));
}
XrSurfaceAnchorCreateCompletionANDROID anchorCompletion{
XR_TYPE_SURFACE_ANCHOR_CREATE_COMPLETION_ANDROID};
CHK_XR(xrCreateSurfaceAnchorCompleteANDROID(spatialContext, anchorFuture, &anchorCompletion));
if (anchorCompletion.futureResult == XR_SUCCESS) {
// Use completion.anchorEntityId.
XrSpatialEntityIdEXT anchorId = anchorCompletion.anchorEntityId;
// Query in UpdateSnapshot.
}
New Commands
- xrCreateGeospatialAnchorANDROID
- xrCreateSurfaceAnchorAsyncANDROID
- xrCreateSurfaceAnchorCompleteANDROID
New Structures
- XrGeospatialAnchorCreateInfoANDROID
- XrSurfaceAnchorCreateCompletionANDROID
- XrSurfaceAnchorCreateInfoANDROID
Extending XrGeospatialTrackerCreateInfoANDROID :
Extending XrSystemProperties :
New Enums
New Enum Constants
XR_ANDROID_GEOSPATIAL_ANCHOR_EXTENSION_NAMEXR_ANDROID_geospatial_anchor_SPEC_VERSIONExtending XrResult :
XR_ERROR_SURFACE_ANCHOR_LOCATION_UNSUPPORTED_ANDROID
Extending XrStructureType :
XR_TYPE_GEOSPATIAL_ANCHOR_CREATE_INFO_ANDROIDXR_TYPE_GEOSPATIAL_TRACKER_ANCHOR_TRACKING_INFO_ANDROIDXR_TYPE_SURFACE_ANCHOR_CREATE_COMPLETION_ANDROIDXR_TYPE_SURFACE_ANCHOR_CREATE_INFO_ANDROIDXR_TYPE_SYSTEM_GEOSPATIAL_ANCHOR_PROPERTIES_ANDROID
Issues
Version History
Revision 1, 2025-10-30 (Ben King)
- Initial draft.