Class Sensor¶
- java.lang.Object
-
- com.iristick.smartglass.core.Sensor
public abstract class Sensor extends Object
This class represents a single logical sensor on the headset.
The type constants are compatible with the types defined in Android's
Sensor
class.
Coordinate system used by the Sensor API
The coordinate system is defined relative to the glasses when put on a head. The X axis points to the right ear. The Y axis points in the direction the user is looking. The Z axis points upwards from the top of the head.
Field Summary¶
Modifier and Type | Field and Description |
---|---|
static int |
TYPE_ACCELEROMETER
Sensor type measuring the total acceleration, including gravity, applied on
the headset.
|
static int |
TYPE_ALL
A constant describing all sensor types.
|
static int |
TYPE_GYROSCOPE
Sensor type measuring the rate of rotation around the headset's local
X, Y and Z axes.
|
static int |
TYPE_HEAD_MOTION_DETECT
Sensor type detecting head motion.
|
static int |
TYPE_MAGNETIC_FIELD
Sensor type measuring the ambient magnetic field.
|
static int |
TYPE_ROTATION_VECTOR
Sensor type measuring the absolute orientation of the headset.
|
Constructor Summary¶
Constructor and Description |
---|
Sensor() |
Method Summary¶
Modifier and Type | Method and Description |
---|---|
abstract int |
getType()
Gets the type of this sensor.
|
abstract boolean |
registerListener(SensorEventListener listener,
int rateUs,
Handler handler)
Registers a listener for this sensor.
|
String |
toString() |
abstract void |
unregisterListener(SensorEventListener listener)
Unregisters a listener for this sensor.
|
Methods inherited from class java.lang.Object¶
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail¶
TYPE_ACCELEROMETER¶
public static final int TYPE_ACCELEROMETER
Sensor type measuring the total acceleration, including gravity, applied on the headset.
Values
are in SI units (m/s²).
values[0]
: Acceleration on the X-axis.values[1]
: Acceleration on the Y-axis.values[2]
: Acceleration on the Z-axis.
TYPE_MAGNETIC_FIELD¶
public static final int TYPE_MAGNETIC_FIELD
Sensor type measuring the ambient magnetic field.
Values
are in micro-Tesla (µT).
values[0]
: Magnetic field in the X-axis.values[1]
: Magnetic field in the Y-axis.values[2]
: Magnetic field in the Z-axis.
TYPE_GYROSCOPE¶
public static final int TYPE_GYROSCOPE
Sensor type measuring the rate of rotation around the headset's local X, Y and Z axes.
Values
are in radians per second.
values[0]
: Rotation rate around the X-axis.values[1]
: Rotation rate around the Y-axis.values[2]
: Rotation rate around the Z-axis.
TYPE_ROTATION_VECTOR¶
public static final int TYPE_ROTATION_VECTOR
Sensor type measuring the absolute orientation of the headset.
The reference coordinate system is defined as a direct orthonormal basis, where
- X is defined as the vector product Y.Z (It is tangential to the ground at the headset's current location and roughly points East).
- Y is tangential to the ground at the headset's current location and points towards magnetic north.
- Z points towards the sky and is perpendicular to the ground.
The rotation vector represents the orientation of the headset as a combination of an angle and an axis, in which the headset has rotated through an angle θ around an axis <x, y, z>. The three elements of the rotation vector are <x*sin(θ/2), y*sin(θ/2), z*sin(θ/2)>, such that the magnitude of the rotation vector is equal to sin(θ/2), and the direction of the rotation vector is equal to the direction of the axis of rotation. The three elements are equal to the last three components of a unit quaternion <cos(θ/2), x*sin(θ/2), y*sin(θ/2), z*sin(θ/2)>. Elements of the rotation vector are unitless.
values[0]
: x*sin(θ/2)values[1]
: y*sin(θ/2)values[2]
: z*sin(θ/2)values[3]
: cos(θ/2)
TYPE_HEAD_MOTION_DETECT¶
public static final int TYPE_HEAD_MOTION_DETECT
Sensor type detecting head motion.
values[0]
: 1.0 if the head is moving, 0.0 if the head stands still
TYPE_ALL¶
public static final int TYPE_ALL
Constructor Detail¶
Sensor¶
public Sensor()
Method Detail¶
getType¶
@CheckResult public abstract int getType()
Gets the type of this sensor.
- Returns:
- The type of this sensor.
registerListener¶
public abstract boolean registerListener(@NonNull SensorEventListener listener, int rateUs, @Nullable Handler handler)
Registers a listener for this sensor. Events are delivered in continuous mode as soon as they are available.
- Parameters:
listener
- The listener.rateUs
- The rate sensor events are delivered at. This is only a hint to the system. Events may be received faster or slower than the specified rate. Usually, events are received faster. The rate is specified in microseconds.handler
- The handler on which the listener should be invoked, ornull
to use the current thread'slooper
.- Returns:
true
if the sensor has been successfully enabled.
unregisterListener¶
public abstract void unregisterListener(@NonNull SensorEventListener listener)
Unregisters a listener for this sensor.
- Parameters:
listener
- The listener to unregister.
toString¶
@NonNull public String toString()