Anchor

public class Anchor

Describes a fixed location and orientation in the real world. To stay at a fixed location in physical space, the numerical description of this position will update as ARCore's understanding of the space improves.

Use getPose() to get the current numerical location of this anchor. This location may change any time update() is called, but will never spontaneously change.

mathematically:
point_world = anchor.getPose().transformPoint(point_local);
point_world = anchor.getPose().toMatrix() * point_local;

anchor.getPose().toMatrix(...) provides a matrix appropriate for composing with the view and projection matrices when rendering an object at this anchor's location.

Anchors are hashable and may for example be used as keys in HashMaps.

Anchors incur ongoing processing overhead within ARCore. To release unneeded anchors use detach().

Nested Classes

enum Anchor.CloudAnchorState Enumeration of all Cloud Anchor States  

Protected Constructors

Anchor()
(FOR TESTING) Constructs a new instance for use as a mock.

Public Methods

void
detach()
Detaches this Anchor from its Trackable removes it from the Session.
boolean
equals(Object obj)
Indicates whether some other object is an Anchor referencing the same logical anchor as this one.
String
getCloudAnchorId()
Gets the current cloud anchor ID for this anchor.
Anchor.CloudAnchorState
getCloudAnchorState()
Gets the current cloud anchor state of this anchor.
Pose
getPose()
Returns the pose of the anchor in the world coordinate space.
TrackingState
getTrackingState()
Returns the current state of the pose of this anchor.
int
hashCode()
Returns a hash code value for the object.

Inherited Methods

Protected Constructors

protected Anchor ()

(FOR TESTING) Constructs a new instance for use as a mock. Calling any base method implementation on this instance (including even equals(Object) and hashCode()) may return unexpected results, throw an exception, or even crash.

To create an Anchor normally, use createAnchor(Pose) or createAnchor().

Public Methods

public void detach ()

Detaches this Anchor from its Trackable removes it from the Session. After calling, getTrackingState() will return STOPPED and ARCore will no longer update this Anchor's pose or return it from getAllAnchors().

public boolean equals (Object obj)

Indicates whether some other object is an Anchor referencing the same logical anchor as this one.

Parameters
obj the reference object with which to compare.
Returns
  • true if this object is the same as the obj argument; false otherwise.

public String getCloudAnchorId ()

Gets the current cloud anchor ID for this anchor. Returns an empty string if getCloudAnchorState() returns TASK_IN_PROGRESS or NONE.

public Anchor.CloudAnchorState getCloudAnchorState ()

Gets the current cloud anchor state of this anchor.

public Pose getPose ()

Returns the pose of the anchor in the world coordinate space. This pose may change each time update() is called. This pose should only be used for rendering if getTrackingState() returns TRACKING.

public TrackingState getTrackingState ()

Returns the current state of the pose of this anchor. If this state is anything other than TRACKING the pose should not be considered useful.

public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

Returns
  • a hash code value for this object.
See Also

Send feedback about...