Base sensors and trigger modes基础传感器及其触发模式

来源:互联网 发布:linux cat 分页 编辑:程序博客网 时间:2024/05/16 19:52


原文:http://source.android.com/devices/sensors/base_triggers.html


Base sensors and trigger modes基础传感器及其触发模式

Trigger modes触发模式


Sensors can report events in different ways called trigger modes; each sensor type has one and only one trigger mode associated to it. Four trigger modes exist:

传感器可以通过不同的触发模式报告事件;每个传感器有且仅有一个触发模式与之对应。一共有四种触发模式:Continuous,On-change,One-shot,Special。

Continuous轮询模式

Events are reported at a constant rate defined by setDelay(). Example sensors using the continuous trigger mode are accelerometers and gyroscopes.

事件由setDelay()所设置的固定频率上报。典型的使用Continuous触发方式的传感器有加速度传感器和陀螺仪。(yasin:其实这就是轮询模式)

On-change中断模式

Events are reported only if the sensor's value has changed. setDelay() is used to set a lower limit to the reporting period, meaning the minimum time between consecutive events. Activating the sensor also triggers an event. The HAL must return an event immediately when an on-change sensor is activated. Example sensors using the on-change trigger mode are the step counter and proximity sensor types.

只有当sensor的数据发生改变时才上报事件。setDelay()用于设置上报周期的下限,即两次事件的最小间隔时间。激活传感器也会触发一个事件。当一个采用On-change触发方式的传感器被激活时,HAL层必须立刻返回(上报)一个事件。典型的使用On-change触发方式的传感器有计步器和接近传感器。

One-shot单次模式

Upon detection of an event, the sensor deactivates itself and then sends a single event. Order matters to avoid race conditions. No other event is sent until the sensor is reactivated. setDelay() is ignored. Significant motion is an example of this kind of sensor.

在检测到一个事件后,传感器便发出这个事件,于此同时该传感器便自行失效。为避免竞态发生,在该传感器被再次激活之前不会再有事件产生。这种模式下setDelay()被忽略。这种触发模式的典型例子是“场景检测”。(yasin:Significant motion, 我觉得这个可以翻译成“场景检测”,也就是每次只有当场景发上变化时这个传感器才会被激活,并同时发出一个事件,然后该传感器又变为失效。这些所谓的场景就是stop、walking、running、biking、in a moving car、in a moving train等等。很显然这个传感器是基于加速度传感器(或其他)的虚拟传感器)

Special特殊模式

See the individual sensor type descriptions for details.

这种所谓的特殊触发模式有专门的章节介绍,请移步。。。

Categories类别


Sensors fall into four primary categories:传感器归类为4个主要类别:

Base - records core measurements from which all other sensors are derived

基础类:记录核心测量数据,其他派生出来的传感器(虚拟传感器)皆基于此数据

Activity - detects user or device movement

动作类:检测用户和设备运动

Attitude - measures the orientation of the device

姿势类:测量设备方向

Uncalibrated - is identical to the corresponding base sensor except the dynamic calibration is reported separately rather than applied to the results

未校准类:除了动态校准被分开上报而没有包含在结果中之外,等同于相应的基础传感器。(yasin:这种传感器上报原始数据,校准数据被分开上报)

Base sensors基础传感器


These sensor types are listed first because they are the fundamental sensors upon which all other sensor types are based.

首先列出这些传感器类型是因为它们是最基础的传感器,是其它衍生传感器之根本。

Accelerometer加速度传感器

Trigger-mode: Continuous触发模式:轮询模式
Wake-up sensor: No可唤醒系统:不可以

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

所有的值都采用国际单位(m/s^2)并且测量的是已经减去重力的加速度值

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

加速度传感器以setDelay()指定的固定频率返回3个方向的加速度值

  • x: Acceleration on the x-axis
  • y: Acceleration on the y-axis
  • z: Acceleration on the z-axis

Note the readings from the accelerometer include the acceleration due to gravity (which is opposite the direction of the gravity vector).

需要注意从加速度传感器读到的值包含重力引起的加速度(它和重力的的方向是相反的) (yasin:这里想表达的是从加速度传感器读到的值已经加了一个反向的重力加速度,也就是该读值是已经抵消了重力加速度的值)

Here are examples:示例:

  • The norm of (x, y, z) should be close to 0 when in free fall.当做自由落体运动时矩阵向量(x, y, z)的值应该接近0 (yasin:这说明该读值确实是已经减去了重力加速度的,否则做自由落体时也不会全0啊)
  • When the device lies flat on a table and is pushed on its left side toward the right, the x acceleration value is positive.当设备水平放到桌面上,由左侧向右推动时,x方向上的加速度值为正。
  • When the device lies flat on a table, the acceleration value is +9.81, which corresponds to the acceleration of the device (0 m/s^2) minus the force of gravity (-9.81 m/s^2).当设备水平放到桌面上,读到的加速度值为+9.81,这相当于设备的当前加速度(0 m/s^2)减去重力引起的加速度 (-9.81 m/s^2) (yasin:0-(-9.81 m/s^2), 所以读值是+9.81)
  • When the device lies flat on a table and is pushed toward the sky, the acceleration value is greater than +9.81, which corresponds to the acceleration of the device (+A m/s^2) minus the force of gravity (-9.81 m/s^2).当设备水平放到桌面上然后向上抬起时,加速度值将会大于+9.81,这相当于设备当前的加速度(+A m/s^2)减去重力引起的加速度 (-9.81 m/s^2) (yasin:A-(-9.81 m/s^2), 所以读值大于+9.81)

Ambient temperature环境温度传感器

Trigger-mode: On-change触发模式:中断模式
Wake-up sensor: No可唤醒系统:不可以

This sensor provides the ambient (room) temperature in degrees Celsius.该传感器提供环境(室内)温度值,单位为摄氏度。

Geomagnetic field地磁传感器

Trigger-mode: Continuous触发模式:轮询模式
Wake-up sensor: No可唤醒系统:不可以

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

测量X,Y,Z三个方向上的地磁场强度,单位为微特(uT).

Returned values include calibration mechanisms so the vector is aligned with the magnetic declination and heading of the earth's geomagnetic field.

返回值包含校准机制,因此该向量是和磁偏角对齐的并指向地球磁场。

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

地磁传感器以setDelay()指定的固定频率返回3个方向的地磁场强度。

Gyroscope陀螺仪

Trigger-mode: Continuous触发模式:轮询模式
Wake-up sensor: No可唤醒系统:不可以

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).

陀螺仪的返回值为用"弧度每秒"来度量的角速度值,它反映的是绕X、Y、Z三个轴的旋转速度。该坐标系同上述的加速度传感器的坐标系。逆时针方向旋转时角速度值为正(根据物理学右手定律) (yasin:角速度可参考:http://zh.wikipedia.org/wiki/%E8%A7%92%E9%80%9F%E5%BA%A6 右手定律可参考:http://zh.wikipedia.org/wiki/%E5%8F%B3%E6%89%8B%E5%AE%9A%E5%89%87,物理学好时你会理解到,这个定律(角速度的矢量方向规定)只是为了方便理解和描述,以及为了方便矢量计算而做的一种约定而已。)

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 elsewhere.

也就是说,当观察者从原点向X、Y、Z三者之一的正方向看过去,如果此时设备做逆时针旋转,则此方向上的角速度读值为正。注意这个是标准的数学上的对于正向旋转的定义,不等同于其它地方对于滚动的定义!(yasin:解释:假如观察者从原点沿着Z轴正方向看过去,如果此时设备绕Z轴做逆时针旋转,则此刻Z轴的读值为正,若设备沿着Z轴做顺时针旋转,则Z轴读值为负。)

The range should at least be 17.45 rad/s (ie: ~1000 deg/s).

角速度测量的最小范围为17.45弧度每秒(即:~ 1000度/秒)

Automatic gyro-drift compensation is required.

必须有陀螺仪的漂移补偿。

Light光线强度传感器

Trigger-mode: On-change触发模式:中断模式
Wake-up sensor: No可唤醒系统:不可以

The light sensor value is returned in SI lux units.光线传感器采用国际单位lux (勒克斯)

Proximity接近传感器

Trigger-mode: On-change触发模式:中断模式
Wake-up sensor: Yes可唤醒系统:可以

Measures the distance from the sensor to the closest visible surface. As this is a wake-up sensor, it should wake up the SoC when it is running and detects a change in proximity. The distance value is measured in centimeters. Note that some proximity sensors only support a binary "near" 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.

测量从传感器到最靠近传感器的可见物体表面的距离。这是一个可唤醒系统的传感器,它应当在检测到接近程度改变时唤醒SoC。其测量距离的单位为厘米。注意有些接近传感器只提供"接近"和"远离"这两个测量值。这种情况下,该传感器在检测到“远离”时应当上报它测量的最大范围值,而在检测到“接近”时报告一个小于该最大范围的值即可。

To ensure the applications have the time to receive the event before the application processor goes back to sleep, the driver must hold a "timeout wake lock" for 200 milliseconds for every wake-up sensor. That is, the application processor should not be allowed to go back to sleep in the 200 milliseconds following a wake-up interrupt.

为了确保应用程序在AP再次休眠之前能有足够的时间收到事件,这种具有唤醒功能的传感器对应的驱动必须拿到一个至少200毫秒的超时锁(timeout wake lock)。也就是说,AP被该类传感器通过中断唤醒后至少要保持200毫秒不会休眠!!!

Pressure大气压传感器

Trigger-mode: Continuous触发模式:轮询模式
Wake-up sensor: No可唤醒系统:不可以

The pressure sensor uses a barometer to return the atmospheric pressure in hectopascal (hPa).

该传感器通过一个气压计测量大气压力,单位采用"百帕"

Relative humidity相对湿度传感器

Trigger-mode: On-change触发模式:中断模式
Wake-up sensor: No可唤醒系统:不可以

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

相对湿度传感器用于测量环境空气湿度,返回值是一个百分比


0 0
原创粉丝点击