Skip to main content
Version: 20 Mar 2024

Anchor

Public Methods

MLResult Create

Creates a new anchor based on a given pose that can expire after a predefined amount of time. The anchor is only valid when MLResult.Code.Ok is returned.

public static MLResult Create(
Pose pose,
long expirationSeconds,
out Anchor anchor
)

Parameters

TypeNameDescription
PoseposePose to base the anchor on.
longexpirationSecondsLength of time before anchor expires. Can be a range from 0 to DateTime.MaxValue - DateTime.UtcNow. Passing a value of 0 creates an indefinite duration.
out AnchoranchorAnchor being created.

Returns: MLResult.Result will be MLResult.Code.Ok if successful. MLResult.Result will be MLResult.Code.InvalidParam if a parameter is invalid. MLResult.Result will be MLResult.Code.AnchorsInsufficientMapping if the space has not been sufficiently mapped to allow this operation. MLResult.Result will be MLResult.Code.AnchorsInvalidExpirationTimestamp if the provided expiration suggestion was not valid. MLResult.Result will be MLResult.Code.AnchorsMaxAnchorLimitReached if the maximum number of anchors for the current space has been reached. MLResult.Result will be MLResult.Code.AnchorsMinDistanceThresholdExceeded if the minimum distance between anchors was not met.


MLResult Delete

public MLResult Delete()

MLResult DeleteAnchorWithId

public static MLResult DeleteAnchorWithId(
string anchorId
)

Parameters

TypeNameDescription
stringanchorId

override bool Equals

public override bool Equals(
object obj
)

Parameters

TypeNameDescription
objectobj

override int GetHashCode

public override int GetHashCode()

MLResult Publish

public MLResult Publish()

override string ToString

public override string ToString()

MLResult Update

public MLResult Update(
long newExpirationTimeStamp
)

Parameters

TypeNameDescription
longnewExpirationTimeStamp

bool operator!=

public static bool operator!=(
Anchor one,
Anchor two
)

Parameters

TypeNameDescription
Anchorone
Anchortwo

bool operator==

public static bool operator==(
Anchor one,
Anchor two
)

Parameters

TypeNameDescription
Anchorone
Anchortwo

Public Attributes

ExpirationTimeStamp

The suggested expiration time for this anchor represented in seconds since the Unix epoch. This is implemented as an expiration timestamp in the future after which the associated anchor should be considered no longer valid and may be removed by the Spatial Anchor system.


public readonly ulong ExpirationTimeStamp;


Id

The anchor's unique ID. This is a unique identifier for a single Spatial Anchor that is generated and managed by the Spatial Anchor system. The ID is created when MLSpatialAnchorCreate is called.


public string Id => this.id.ToString();


IsPersisted

Indicates whether or not the anchor has been persisted via a call to #MLSpatialAnchorPublish.


public readonly bool IsPersisted;


Pose

Pose.


public readonly Pose Pose;


Quality

The quality of the local space that this anchor occupies. This value may change over time.


public string Quality => this.quality.ToString();


SpaceId

The ID of the space that this anchor belongs to. This is only relevant if IsPersisted is true.


public string SpaceId => this.spaceId.ToString();