Earth

public class Earth

A Trackable implementation representing the Earth. Provides localization ability in Earth-relative coordinates.

To access Earth, configure the session with an appropriate Config.GeospatialMode and use Session.getEarth().

Not all devices support Config.GeospatialMode.ENABLED, use Session.isGeospatialModeSupported(Config.GeospatialMode) to check if the current device and selected camera support enabling this mode.

The Earth object should only be used when its TrackingState is TrackingState.TRACKING, and otherwise should not be used. Use getTrackingState() to obtain the current TrackingState. If the TrackingState does not become TrackingState.TRACKING, then getEarthState() may contain more information in a Earth.EarthState.

Use getCameraGeospatialPose() to obtain the Earth-relative virtual camera pose for the latest frame.

Use createAnchor(double, double, double, float, float, float, float) to attach anchors to Earth. Calling createAnchor(Pose) on Earth will fail to create a new anchor and will throw IllegalArgumentException.

Earth does not support hit testing and will never be a result from Frame.hitTest(MotionEvent). Because Earth is a type of Trackable, the singleton Earth instance may also be returned by Session.getAllTrackables(Class) when enabled.

Nested Classes

enum Earth.EarthState Describes the current state of Earth

Public Methods

Anchor
createAnchor(double latitude, double longitude, double altitude, float[] rotation)
Creates a new Anchor at the specified geospatial location and orientation relative to the Earth.
Anchor
Anchor
createAnchor(double latitude, double longitude, double altitude, float qx, float qy, float qz, float qw)
Creates a new Anchor at the specified geospatial location and orientation relative to the Earth.
boolean
equals(Object obj)
Indicates whether some other object is a Trackable referencing the same logical trackable as this one.
Collection<Anchor>
getAnchors()
Gets the Anchors attached to this trackable.
GeospatialPose
getCameraGeospatialPose()
Returns the GeospatialPose for the camera in the latest frame, describing the geospatial positioning of the device.
Earth.EarthState
getEarthState()
Gets the current Earth.EarthState of the Earth.
GeospatialPose
getGeospatialPose(Pose pose)
Converts the input pose to a GeospatialPose in the same position as the original Pose.
Pose
getPose(double latitude, double longitude, double altitude, float qx, float qy, float qz, float qw)
Converts the input geospatial location and orientation relative to the Earth to a Pose in the same position.
TrackingState
getTrackingState()
Gets the TrackingState of the Earth object as of the last frame.
int
hashCode()
Returns a hash code value for the object.
Anchor
resolveAnchorOnTerrain(double latitude, double longitude, double altitudeAboveTerrain, float qx, float qy, float qz, float qw)
Creates a new Anchor at a specified horizontal position and altitude relative to the horizontal position's terrain.

Inherited Methods

Public Methods

createAnchor

public Anchor createAnchor(
  double latitude,
  double longitude,
  double altitude,
  float[] rotation
)

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 the altitude value is defined by the elevation above the WGS84 ellipsoid in meters. To create an anchor using an altitude relative to the Earth's terrain instead of altitude above the WGS84 ellipsoid, use resolveAnchorOnTerrain(double, double, double, float, float, float, float).

The rotation quaternion provided is with respect to an east-up-south 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 south.

To create an anchor that has the +Z axis pointing in the same direction as heading contained in a GeospatialPose, use the following formula: {qx, qy, qz, qw} = {0, sin((pi - Math.toRadians(pose.getHeading())) / 2), 0, cos((pi - Math.toRadians(pose.getHeading())) / 2)}.

An anchor's tracking state will be TrackingState.PAUSED while Earth's getTrackingState() is TrackingState.PAUSED. Its tracking state will permanently become TrackingState.STOPPED if Session.configure(Config) sets the Geospatial mode to Config.GeospatialMode.DISABLED.

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 throw IllegalArgumentException.

Details
Parameters
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.
rotation EUS (east-up-south) rotation quaternion in the order {x, y, z, w}.
Returns the anchor if successful; otherwise throws an exception.
Throws
IllegalStateException if Earth is TrackingState.STOPPED due to Config.GeospatialMode.DISABLED configured on the Session. Reacquire Earth if geospatial mode was reenabled.
IllegalArgumentException if latitude is outside the allowable range.
NotTrackingException when localisation is not yet available.

createAnchor

public Anchor createAnchor(
  Pose pose
)

This method was deprecated.
use createAnchor(double, double, double, float, float, float, float) instead.

Earth does not support creating an Anchor using a Pose. Use createAnchor(double, double, double, float, float, float, float) instead.

Details
Parameters
pose

createAnchor

public Anchor createAnchor(
  double latitude,
  double longitude,
  double altitude,
  float qx,
  float qy,
  float qz,
  float qw
)

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 the altitude value is defined by the elevation above the WGS84 ellipsoid in meters. To create an anchor using an altitude relative to the Earth's terrain instead of altitude above the WGS84 ellipsoid, use resolveAnchorOnTerrain(double, double, double, float, float, float, float).

The rotation quaternion provided is with respect to an east-up-south 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 south.

To create an anchor that has the +Z axis pointing in the same direction as heading contained in a GeospatialPose, use the following formula: {qx, qy, qz, qw} = {0, sin((pi - Math.toRadians(pose.getHeading())) / 2), 0, cos((pi - Math.toRadians(pose.getHeading())) / 2)}.

An anchor's TrackingState will be TrackingState.PAUSED while getTrackingState() is TrackingState.PAUSED. Its tracking state will permanently become TrackingState.STOPPED if Session.configure(Config) sets the Geospatial mode to Config.GeospatialMode.DISABLED.

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 throw IllegalArgumentException.

Details
Parameters
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, in meters.
qx The x component of the EUS (east-up-south) rotation quaternion.
qy The y component of the EUS (east-up-south) rotation quaternion.
qz The z component of the EUS (east-up-south) rotation quaternion.
qw The w component of the EUS (east-up-south) rotation quaternion.
Returns the anchor if successful; otherwise throws an exception.
Throws
IllegalStateException if Earth is TrackingState.STOPPED due to Config.GeospatialMode.DISABLED configured on the Session. Reacquire Earth if geospatial mode was reenabled.
IllegalArgumentException if latitude is outside the allowable range.

equals

public boolean equals(
  Object obj
)

Indicates whether some other object is a Trackable referencing the same logical trackable as this one.

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

getAnchors

public Collection<Anchor> getAnchors()

Gets the Anchors attached to this trackable.

getCameraGeospatialPose

public GeospatialPose getCameraGeospatialPose()

Returns the GeospatialPose for the camera in the latest frame, describing the geospatial positioning of the device.

The heading of the returned GeospatialPose approximates the direction the user is facing, specifically:

  • When the display is perpendicular to the ground, the back of the device points in the heading direction.
  • When the display is parallel to the ground and facing upward, heading is along the logical display's up direction, taking into account display rotation.
  • When the display is parallel to the ground and facing downward, heading is along the logical display's down direction.
  • In intermediate positions, the heading blends smoothly between the above behaviors.

Note: This pose is only valid when getTrackingState() returns TrackingState.TRACKING, otherwise, the resulting GeospatialPose will contain invalid values.

Details
Throws
IllegalStateException when Session.getConfig() does not have Config.GeospatialMode.ENABLED set.
NotTrackingException when localisation is not yet available.

getEarthState

public Earth.EarthState getEarthState()

Gets the current Earth.EarthState of the Earth.

This state is guaranteed not to change until Session.update() is called.

getGeospatialPose

public GeospatialPose getGeospatialPose(
  Pose pose
)

Converts the input pose to a GeospatialPose in the same position as the original Pose.

Earth's current tracking state must be TrackingState.TRACKING in order to obtain a value from this function Otherwise, a NotTrackingException may be thrown.

The returned GeospatialPose does not contain a valid heading value. See GeospatialPose.getEastUpSouthQuaternion() to obtain an orientation in 3D space.

Details
Parameters
pose the Pose to be converted into a GeospatialPose.
Returns the GeospatialPose in the same position.
Throws
NotTrackingException when Earth's current tracking state is not TrackingState.TRACKING.

getPose

public Pose getPose(
  double latitude,
  double longitude,
  double altitude,
  float qx,
  float qy,
  float qz,
  float qw
)

Converts the input geospatial location and orientation relative to the Earth to a Pose in the same position.

Earth's current tracking state must be TrackingState.TRACKING in order to obtain a value from this function. Otherwise, a NotTrackingException may be thrown.

Position 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 throw IllegalArgumentException.

Details
Parameters
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, in meters.
qx The x component of the EUS (east-up-south) rotation quaternion.
qy The y component of the EUS (east-up-south) rotation quaternion.
qz The z component of the EUS (east-up-south) rotation quaternion.
qw The w component of the EUS (east-up-south) rotation quaternion.
Returns the Pose in the same position in gl world coordinate.
Throws
NotTrackingException when Earth's current tracking state is not TrackingState.TRACKING.
IllegalArgumentException if latitude is outside the allowable range.

getTrackingState

public TrackingState getTrackingState()

Gets the TrackingState of the Earth object as of the last frame.

hashCode

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.

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

resolveAnchorOnTerrain

public Anchor resolveAnchorOnTerrain(
  double latitude,
  double longitude,
  double altitudeAboveTerrain,
  float qx,
  float qy,
  float qz,
  float qw
)

Creates a new Anchor at a specified horizontal position and altitude relative to the horizontal position's terrain. Terrain means the ground or ground floor inside a building with VPS coverage. If the altitude relative to the WGS84 ellipsoid is known, use createAnchor(Pose) 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 Anchor 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. Attempting to resolve more than 100 Terrain Anchors will throw ResourceExhaustedException.

The returned Anchor will have its Anchor.TerrainAnchorState set to Anchor.TerrainAnchorState.TASK_IN_PROGRESS, and its TrackingState will be TrackingState.PAUSED. 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 TrackingState will be permanently set to TrackingState.STOPPED, and Anchor.getTerrainAnchorState() will contain a Anchor.TerrainAnchorState detailing error information.

Creating a Terrain anchor requires an active Earth which is Earth.EarthState.ENABLED. If it is not, then this function throws IllegalStateException. 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.

A Terrain anchor's tracking state will be TrackingState.PAUSED while Earth's getTrackingState() is TrackingState.PAUSED. Its tracking state will permanently become TrackingState.STOPPED if Session.configure(Config) is used to set Config.GeospatialMode.DISABLED.

Latitude and longitude are defined by the WGS84 specification.

The rotation quaternion provided is with respect to an east-up-south 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 south.

To create an anchor that has the +Z axis pointing in the same direction as heading contained in a GeospatialPose, use the following formula: {qx, qy, qz, qw} = {0, sin((pi - Math.toRadians(pose.getHeading())) / 2), 0, cos((pi - Math.toRadians(pose.getHeading())) / 2)}.

Details
Parameters
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).
qx The x component of the EUS (east-up-south) rotation quaternion.
qy The y component of the EUS (east-up-south) rotation quaternion.
qz The z component of the EUS (east-up-south) rotation quaternion.
qw The w component of the EUS (east-up-south) rotation quaternion.
Returns the anchor if successful; otherwise throws an exception.
Throws
IllegalStateException if Earth is TrackingState.STOPPED due to Config.GeospatialMode.DISABLED configured on the Session. Reacquire Earth if geospatial mode was reenabled.
IllegalArgumentException if latitude is outside the allowable range.
NotTrackingException when localisation is not yet available.
ResourceExhaustedException if too many terrain anchors have already been held.