Android sensor-motion sensor (1)

Source: Internet
Author: User
Tags scalar

This article translated from: http://developer.android.com/guide/topics/sensors/sensors_motion.html

The Android platform provides several sensors that can monitor the movement of devices. Two of them are hardware-based (accelerometer and gyroscope). Three sensors can be hardware-based, it can also be software-based (Gravity Sensors, linear acceleration sensors, and rotating vector sensors ). For example, some software sensor-based devices extract their data from the accelerometer and the magnetic sensor, but on other devices, they can also use gyroscope to extract data. Most Android devices have accelerometer and gyroscope. The effectiveness of software-based sensors is variable because they depend on one or more hardware sensors to extract the corresponding data.

Motion sensors are used to monitor the movement of a device, such as tilting, vibrating, rotating, or swinging. Mobile is usually a reflection of direct user input (for example, a user operates a car in a game or controls a ball), but it can also reflect the physical environment of the device (for example, position when driving the car ). In the first scenario, you need to monitor the movement of devices relative to the device's or application's frame of reference. In the second scenario, you need to monitor the movement of devices relative to the global frame.

Generally, Mobile sensors are not used to monitor device locations, but they can be used with other sensors, for example, use a Geomagnetic sensor to determine the location of a device relative to a global reference system (for more information, see location sensor ).

Each sensorevent of all mobile sensors returns a multidimensional array of sensor values. For example, a sensor event of an accelerometer will return the acceleration force in the direction of three axes, and the gyroscope will return the rotation rate in the direction of the three axes. The data is returned in the form of a float array along with the sensorevent parameter. Table 1 describes the available mobile sensors on the Android platform.

Table 1. Mobile sensors supported by the Android platform

Sensor

Sensor Data

Description

Measurement Unit

TYPE_ACCELEROMETER

Sensorevent. Values [0]

Acceleration force in the X axis direction (including gravity)

M/s2

Sensorevent. Values [1]

Acceleration force in the Y axis (including gravity)

Sensorevent. Values [2]

Acceleration force in the Z axis (including gravity)

TYPE_GRAVITY

Sensorevent. Values [0]

X-axis gravity

M/s2

Sensorevent. Values [1]

Gravity in the Y axis

Sensorevent. Values [2]

Gravity in the Z axis

TYPE_GYROSCOPE

Sensorevent. Values [0]

Rotation Rate around the X axis

Rad/s

Sensorevent. Values [1]

Rotation Rate around Y axis

Sensorevent. Values [2]

Rotation Rate around the Z axis

TYPE_LINEAR_ACCELERATION

Sensorevent. Values [0]

Acceleration in the X axis direction (excluding gravity

M/s2

Sensorevent. Values [1]

Acceleration in the Y axis (excluding gravity)

Sensorevent. Values [2]

Acceleration force in the Z axis (excluding gravity

TYPE_ROTATION_VECTOR

Sensorevent. Values [0]

The rotation vector along the X axis (x * sin (θ/2 )).

No unit

Sensorevent. Values [1]

The rotation vector along the Y axis (y * sin (θ/2 )).

Sensorevent. Values [2]

Rotation Vector along the Z axis (z * sin (θ/2 )).

Sensorevent. Values [3]

The scalar part of the Rotated Vector (COS (θ/2). 1

1. the scalar part is an optional value.

For mobile detection and monitoring, rotating vector sensors and Gravity Sensors are the most frequently used sensors. The rotating vector sensor is particularly flexible and can be widely used in mobile-related tasks, such as detecting gestures, monitoring angle changes, and monitoring relative direction changes. For example, if you are developing an application that uses a 2-dimensional or 3-dimensional drive to enhance the sense of presence or stability of your camera, rotating vector sensor is ideal. In most scenarios, it is better to use these sensors than to use acceleration sensors, geomagnetic sensors, or direction sensors.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.