Android
The rotation sensor measures the orientation of the device as a combination of an angle and an axis, in which the device has rotated through an angle θ around an axis (x, y, or z). The rotational vector sensor is particularly versatile and can be used for a wide range of motion-related tasks, such as detecting gestures, monitoring angular change, and monitoring relative orientation changes. For example, the rotational vector sensor is ideal if you are developing a game, an augmented reality application, a 2-dimensional or 3-dimensional compass, or a camera stabilization app.
Three elements of the rotation vector are expressed as follows:
- x*sin(θ/2)
- y*sin(θ/2)
- z*sin(θ/2)
Where 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 of the rotation vector 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. The x, y, and z axes are defined in the same way as the acceleration sensor. The reference coordinate system is defined as a direct orthonormal basis, seen above.
This coordinate system has the following characteristics:
- X is defined as the vector product Y x Z. It is tangential to the ground at the device’s current location and points approximately East;
- Y is tangential to the ground at the device’s current location and points toward the geomagnetic North Pole;
- Z points toward the sky and is perpendicular to the ground plane.
For more information, check the official Android’s Sensor Coordinate System documentation.
Public functions
- Rotation.getFrequency( Context context ): returns the sampling rate in Hz.
Settings
- Aware_Preferences.STATUS_ROTATION: true or false to activate or deactivate sensor.
- Aware_Preferences.FREQUENCY_ROTATION: non-deterministic frequency in microseconds (dependent of the hardware sensor capabilities and resources), e.g., 200000 (normal), 60000 (UI), 20000 (game), 0 (fastest).
- Rotation.ACTION_AWARE_ROTATION: broadcasted when new data exists in Context Provider.
- Rotation.EXTRA_DATA: the inserted data, as ContentValues.
- Rotation.ACTION_AWARE_ROTATION_LABEL: assign label to the recorded data.
- Rotation.EXTRA_LABEL: the desired label.
Rotation Sensor
Contains the hardware sensor capabilities in the mobile device.
Rotation_Sensor.CONTENT_URI
content://com.aware.provider.rotation/sensor_rotation
Table field | Field type | Description |
---|---|---|
_id | INTEGER | primary key, auto incremented |
timestamp | REAL | unixtime milliseconds since 1970 |
device_id | TEXT | AWARE device UUID |
double_sensor_maximum_range | REAL | Maximum sensor value possible |
double_sensor_minimum_delay | REAL | Minimum sampling delay in microseconds |
sensor_name | TEXT | Sensor’s name |
double_sensor_power_ma | REAL | Sensor’s power drain in mA |
double_sensor_resolution | REAL | Sensor’s resolution in sensor’s units |
sensor_type | TEXT | Sensor’s type |
sensor_vendor | TEXT | Sensor’s manufacturer |
sensor_version | TEXT | Sensor’s version number |
Rotation Data
Rotation_Data.CONTENT_URI
content://com.aware.provider.rotation/rotation
Table field | Field type | Description |
---|---|---|
_id | INTEGER | primary key, auto incremented |
timestamp | REAL | unixtime milliseconds since 1970 |
device_id | TEXT | AWARE device UUID |
double_values_0 | REAL | the rotation vector component along the x axis, x*sin(θ/2) |
double_values_1 | REAL | the rotation vector component along the y axis, y*sin(θ/2) |
double_values_2 | REAL | the rotation vector component along the z axis, z*sin(θ/2) |
double_values_3 | REAL | cos(θ/2) (optional, manufacturer dependent) |
accuracy | INTEGER | Sensor’s accuracy level (see SensorManager) |
label | TEXT | Customizable label. Useful for data calibration or traceability |