,

Improving Sensor Accuracy with the Motion Sensor

The Motion class provides access to a virtual sensor. There is no dedicated motion sensor per se, rather the motion API combines the readings of the accelerometer, compass, and gyroscope to provide an enhanced API that overcomes the shortcomings of the individual sensors. The motion sensor provides the greatest accuracy of all the sensors, eliminating possible sensor inaccuracy issues that occur when relying on a single hardware sensor. For this reason, it is recommended that the motion sensor is used when available.

As mentioned in the previous section, the gyroscope is subject to drift. The motion API alleviates the drifting of the gyroscope by combing its readings with the compass and accelerometer readings.

Accelerometer readings include the force of gravity applied to the device as well as the force resulting from the motion of the device. The motion API separates the gravity vector from the device acceleration and provides you with the device’s attitude, consisting of yaw, pitch, and roll.

The Motion API can use two different sensor modes: normal and enhanced. Normal mode uses the compass and the accelerometer sensor and is less accurate than enhanced mode, which uses the compass, the accelerometer, and the gyroscope (see Table 16.2).

TABLE 16.2. Motion Sensor Availability

Image

If your app requires the accuracy of enhanced mode, you should verify that the device supports the gyroscope sensor. If the gyroscope is supported, enhanced mode is used automatically.


Note

Determining whether a device supports all the sensors required by your app happens before the app is deployed to the device. When a user views an app on Windows Phone Marketplace, a warning is issued if the user’s device does not support a sensor that is used by the app.

The Marketplace uses the compass sensor to determine whether the motion API is supported on a device. If a user views an app that uses the motion API and her device lacks a compass, a warning is displayed stating that the application requires a compass sensor.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.38.142