Data Fields
sensors_vec_t Struct Reference

Definition of the axis

More...

Data Fields

union {
   struct {
      float   x
 
      float   y
 
      float   z
 
   } 
 
   struct {
      float   azimuth
 
      float   pitch
 
      float   roll
 
   } 
 
   float   v [3]
 
}; 
 
uint8_t reserved [3]
 
int8_t status
 

Detailed Description

Definition of the axis

This API is relative to the screen of the device in its default orientation, that is, if the device can be used in portrait or landscape, this API is only relative to the NATURAL orientation of the screen. In other words, the axis are not swapped when the device's screen orientation changes. Higher level services /may/ perform this transformation.

x<0 x>0 ^ | +--------—+–> y>0

| | / z<0 | | / | | / O--------—+/ |[] [ ] []/ +-------—/+ y<0 / / |/ z>0 (toward the sky)

O: Origin (x=0,y=0,z=0)

SENSOR_TYPE_ORIENTATION

All values are angles in degrees.

Orientation sensors return sensor events for all 3 axes at a constant rate defined by setDelay().

azimuth: angle between the magnetic north direction and the Y axis, around the Z axis (0<=azimuth<360). 0=North, 90=East, 180=South, 270=West

pitch: Rotation around X axis (-180<=pitch<=180), with positive values when the z-axis moves toward the y-axis.

roll: Rotation around Y axis (-90<=roll<=90), with positive values when the x-axis moves towards the z-axis.

Note: For historical reasons the roll angle is positive in the clockwise direction (mathematically speaking, it should be positive in the counter-clockwise direction):

          Z
          ^

(+roll) .–> | / | | | roll: rotation around Y axis X <----—(.) Y note that +Y == -roll

Note: This definition is different from yaw, pitch and roll used in aviation where the X axis is along the long side of the plane (tail to nose).

SENSOR_TYPE_ACCELEROMETER

All values are in SI units (m/s^2) and measure the acceleration of the device minus the force of gravity.

Acceleration sensors return sensor events for all 3 axes at a constant rate defined by setDelay().

x: Acceleration minus Gx on the x-axis y: Acceleration minus Gy on the y-axis z: Acceleration minus Gz on the z-axis

Examples: When the device lies flat on a table and is pushed on its left side toward the right, the x acceleration value is positive.

When the device lies flat on a table, the acceleration value is +9.81, which correspond to the acceleration of the device (0 m/s^2) minus the force of gravity (-9.81 m/s^2).

When the device lies flat on a table and is pushed toward the sky, the acceleration value is greater than +9.81, which correspond to the acceleration of the device (+A m/s^2) minus the force of gravity (-9.81 m/s^2).

SENSOR_TYPE_MAGNETIC_FIELD

All values are in micro-Tesla (uT) and measure the ambient magnetic field in the X, Y and Z axis.

Magnetic Field sensors return sensor events for all 3 axes at a constant rate defined by setDelay().

SENSOR_TYPE_GYROSCOPE

All values are in radians/second and measure the rate of rotation around the X, Y and Z axis. The coordinate system is the same as is used for the acceleration sensor. Rotation is positive in the counter-clockwise direction (right-hand rule). That is, an observer looking from some positive location on the x, y or z axis at a device positioned on the origin would report positive rotation if the device appeared to be rotating counter clockwise. Note that this is the standard mathematical definition of positive rotation and does not agree with the definition of roll given earlier. The range should at least be 17.45 rad/s (ie: ~1000 deg/s).

SENSOR_TYPE_PROXIMITY

The distance value is measured in centimeters. Note that some proximity sensors only support a binary "close" or "far" measurement. In this case, the sensor should report its maxRange value in the "far" state and a value less than maxRange in the "near" state.

Proximity sensors report a value only when it changes and each time the sensor is enabled.

SENSOR_TYPE_LIGHT

The light sensor value is returned in SI lux units.

Light sensors report a value only when it changes and each time the sensor is enabled.

SENSOR_TYPE_PRESSURE

The pressure sensor return the athmospheric pressure in hectopascal (hPa)

Pressure sensors report events at a constant rate defined by setDelay().

SENSOR_TYPE_GRAVITY

A gravity output indicates the direction of and magnitude of gravity in the devices's coordinates. On Earth, the magnitude is 9.8 m/s^2. Units are m/s^2. The coordinate system is the same as is used for the acceleration sensor. When the device is at rest, the output of the gravity sensor should be identical to that of the accelerometer.

SENSOR_TYPE_LINEAR_ACCELERATION

Indicates the linear acceleration of the device in device coordinates, not including gravity. This output is essentially Acceleration - Gravity. Units are m/s^2. The coordinate system is the same as is used for the acceleration sensor.

SENSOR_TYPE_ROTATION_VECTOR

A rotation vector represents the orientation of the device as a combination of an angle and an axis, in which the device has rotated through an angle theta around an axis <x, y, z>. The three elements of the rotation vector are <x*sin(theta/2), y*sin(theta/2), z*sin(theta/2)>, such that the magnitude of the rotation vector is equal to sin(theta/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(theta/2), x*sin(theta/2), y*sin(theta/2), z*sin(theta/2)>. Elements of the rotation vector are unitless. The x, y, and z axis are defined in the same was as for the acceleration sensor.

The reference coordinate system is defined as a direct orthonormal basis, where:

The rotation-vector is stored as:

sensors_event_t.data[0] = x*sin(theta/2) sensors_event_t.data[1] = y*sin(theta/2) sensors_event_t.data[2] = z*sin(theta/2) sensors_event_t.data[3] = cos(theta/2)

SENSOR_TYPE_RELATIVE_HUMIDITY

A relative humidity sensor measures relative ambient air humidity and returns a value in percent.

Relative humidity sensors report a value only when it changes and each time the sensor is enabled.

SENSOR_TYPE_AMBIENT_TEMPERATURE

The ambient (room) temperature in degree Celsius.

Temperature sensors report a value only when it changes and each time the sensor is enabled.

Definition at line 306 of file sensors.h.

Field Documentation

union { ... }
float sensors_vec_t::azimuth

Definition at line 315 of file sensors.h.

float sensors_vec_t::pitch

Definition at line 316 of file sensors.h.

uint8_t sensors_vec_t::reserved[3]

Definition at line 321 of file sensors.h.

float sensors_vec_t::roll

Definition at line 317 of file sensors.h.

int8_t sensors_vec_t::status

Definition at line 320 of file sensors.h.

float sensors_vec_t::v[3]

Definition at line 308 of file sensors.h.

float sensors_vec_t::x

Definition at line 310 of file sensors.h.

float sensors_vec_t::y

Definition at line 311 of file sensors.h.

float sensors_vec_t::z

Definition at line 312 of file sensors.h.