diff --git a/docs/html/guide/topics/sensors/sensors_motion.jd b/docs/html/guide/topics/sensors/sensors_motion.jd index 289c63972c162..945f8a63d7bfe 100644 --- a/docs/html/guide/topics/sensors/sensors_motion.jd +++ b/docs/html/guide/topics/sensors/sensors_motion.jd @@ -1,5 +1,5 @@ page.title=Motion Sensors -page.tags="sensorevent","accelerometer","gyroscope","gravity","rotation" +page.tags="sensorevent","accelerometer","gyroscope","gravity","rotation","stepcounter" @jd:body
Motion sensors are useful for monitoring device movement, such as tilt, shake, rotation, or @@ -120,6 +123,32 @@ parameters. Table 1 summarizes the motion sensors that are available on the Andr
SensorEvent.values[2]SensorEvent.values[0]SensorEvent.values[1]SensorEvent.values[2]SensorEvent.values[3]SensorEvent.values[4]SensorEvent.values[5]SensorEvent.values[0]SensorEvent.values[3]SensorEvent.values[0]1 The scalar component is an optional value.
@@ -366,6 +414,36 @@ drift (bias). In practice, gyroscope noise and drift will introduce errors that compensated for. You usually determine the drift (bias) and noise by monitoring other sensors, such as the gravity sensor or accelerometer. +The uncalibrated gyroscope is similar to the gyroscope,
+except that no gyro-drift compensation is applied to the rate of rotation. Factory calibration
+and temperature compensation are still applied to the rate of rotation. The uncalibrated
+gyroscope is useful for post-processing and melding orientation data. In general,
+gyroscope_event.values[0] will be close to
+uncalibrated_gyroscope_event.values[0] - uncalibrated_gyroscope_event.values[3].
+That is,
calibrated_x ~= uncalibrated_x - bias_estimate_x
Note: Uncalibrated sensors provide more raw results and may +include some bias, but their measurements contain fewer jumps from corrections applied through +calibration. Some applications may prefer these uncalibrated results as smoother and more +reliable. For instance, if an application is attempting to conduct its own sensor fusion, +introducing calibrations can actually distort results.
+ +In addition to the rates of rotation, the uncalibrated gyroscope also provides the estimated +drift around each axis. The following code shows you how to get an instance of the default +uncalibrated gyroscope:
+ ++private SensorManager mSensorManager; +private Sensor mSensor; +... +mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); +mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE_UNCALIBRATED); ++
The linear acceleration sensor provides you with a three-dimensional vector representing @@ -450,4 +528,64 @@ North Pole.
The Android SDK provides a sample application that shows how to use the rotation vector sensor. The sample application is located in the API Demos code ( -OS - RotationVectorDemo).
\ No newline at end of file +OS - RotationVectorDemo). + + +The significant motion sensor triggers an event each time significant motion is detected and +then it disables itself. A significant motion is a motion that might lead to a change in the +user's location; for example walking, biking, or sitting in a moving car. The following code shows you +how to get an instance of the default significant motion sensor and how to register an event +listener:
+ +
+private SensorManager mSensorManager;
+private Sensor mSensor;
+private TriggerEventListener mTriggerEventListener;
+...
+mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
+mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION);
+
+mTriggerEventListener = new TriggerEventListener() {
+ @Override
+ public void onTrigger(TriggerEvent event) {
+ // Do work
+ }
+};
+
+mSensorManager.requestTriggerSensor(mTriggerEventListener, mSensor);
+
+
+For more information, see {@link android.hardware.TriggerEventListener}.
+ + +The step counter sensor provides the number of steps taken by the user since the last reboot +while the sensor was activated. The step counter has more latency (up to 10 seconds) but more +accuracy than the step detector sensor. The following code shows you how to get an instance of +the default step counter sensor:
+ ++private SensorManager mSensorManager; +private Sensor mSensor; +... +mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); +mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER); ++ + +
The step detector sensor triggers an event each time the user takes a step. The latency is +expected to be below 2 seconds. The following code shows you how to get an instance of the +default step detector sensor:
+ ++private SensorManager mSensorManager; +private Sensor mSensor; +... +mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); +mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR); +diff --git a/docs/html/guide/topics/sensors/sensors_overview.jd b/docs/html/guide/topics/sensors/sensors_overview.jd index a162ccfbfa8d5..0b3cb2b1cd488 100644 --- a/docs/html/guide/topics/sensors/sensors_overview.jd +++ b/docs/html/guide/topics/sensors/sensors_overview.jd @@ -710,7 +710,7 @@ have negative Z values. This coordinate system is used by the following sensors: href="{@docRoot}guide/topics/sensors/sensors_motion.html#sensors-motion-accel">Acceleration sensor
SensorEvent.values[0]SensorEvent.values[1]SensorEvent.values[2]SensorEvent.values[0]SensorEvent.values[1]SensorEvent.values[2]SensorEvent.values[0]SensorEvent.values[2]SensorEvent.values[0]SensorEvent.values[1]SensorEvent.values[2]SensorEvent.values[3]SensorEvent.values[4]SensorEvent.values[5]SensorEvent.values[0]2 Some proximity sensors provide only binary values representing near and far.
+ +The game rotation vector sensor is identical to the +Rotation +Vector Sensor, except it does not use the geomagnetic field. Therefore the Y axis does not +point north but instead to some other reference. That reference is allowed to drift by the +same order of magnitude as the gyroscope drifts around the Z axis.
+ +Because the game rotation vector sensor does not use the magnetic field, relative rotations +are more accurate, and not impacted by magnetic field changes. Use this sensor in a game if +you do not care about where north is, and the normal rotation vector does not fit your needs +because of its reliance on the magnetic field.
+ +The following code shows you how to get an instance of the default game rotation vector +sensor:
+ ++private SensorManager mSensorManager; +private Sensor mSensor; +... +mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); +mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR); ++ + +
The geomagnetic rotation vector sensor is similar to the +Rotation +Vector Sensor, but it uses a magnetometer instead of a gyroscope. The accuracy of this +sensor is lower than the normal rotation vector sensor, but the power consumption is reduced. +Only use this sensor if you want to collect some rotation information in the background without +draining too much battery. This sensor is most useful when used in conjunction with batching.
+ +The following code shows you how to get an instance of the default geomagnetic rotation +vector sensor:
+ ++private SensorManager mSensorManager; +private Sensor mSensor; +... +mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); +mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR); ++ +
The orientation sensor lets you monitor the position of a device relative to the earth's frame of reference (specifically, magnetic north). The following code shows you how to get an instance of the -default orientation sensor :
+default orientation sensor:
private SensorManager mSensorManager;
@@ -249,6 +352,35 @@ use these matrices with the {@link android.hardware.SensorManager#getOrientation
and {@link android.hardware.SensorManager#getInclination getInclination()} methods to obtain azimuth
and geomagnetic inclination data.
+Using the Uncalibrated Magnetometer
+
+The uncalibrated magnetometer is similar to the geomagnetic field
+sensor, except that no hard iron calibration is applied to the magnetic field. Factory calibration
+and temperature compensation are still applied to the magnetic field. The uncalibrated magnetometer
+is useful to handle bad hard iron estimations. In general, geomagneticsensor_event.values[0]
+will be close to uncalibrated_magnetometer_event.values[0] -
+uncalibrated_magnetometer_event.values[3]. That is,
+
+calibrated_x ~= uncalibrated_x - bias_estimate_x
+
+Note: Uncalibrated sensors provide more raw results and may
+include some bias, but their measurements contain fewer jumps from corrections applied through
+calibration. Some applications may prefer these uncalibrated results as smoother and more
+reliable. For instance, if an application is attempting to conduct its own sensor fusion,
+introducing calibrations can actually distort results.
+
+In addition to the magnetic field, the uncalibrated magnetometer also provides the
+estimated hard iron bias in each axis. The following code shows you how to get an instance of the
+default uncalibrated magnetometer:
+
+
+private SensorManager mSensorManager;
+private Sensor mSensor;
+...
+mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
+mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED);
+
+
Using the Proximity Sensor
The proximity sensor lets you determine how far away an object is from a device. The following
code shows you how to get an instance of the default proximity sensor:
@@ -313,4 +445,4 @@ public class SensorActivity extends Activity implements SensorEventListener {
"near" or "far." In this case, the sensor usually reports its maximum range value in the far state
and a lesser value in the near state. Typically, the far value is a value > 5 cm, but this can vary
from sensor to sensor. You can determine a sensor's maximum range by using the {@link
-android.hardware.Sensor#getMaximumRange} method.
\ No newline at end of file
+android.hardware.Sensor#getMaximumRange} method.