androidaccelerometersamplinggyroscopesensor-fusion

Setting sensor reporting mode as continuous in android for constant sampling rate


I want data from multiple android sensors (TYPE_ROTATION_VECTOR and TYPE_LINEAR_ACCELERATION) at a constant sampling period of 20 ms. Also I want both of the sensors values to have exact correspondence in values w.r.t time axis.

This documentation shows that a constant sampling rate can be set using the int REPORTING_MODE_CONTINUOUS and then passing the sampling rate inside registerListener() function.

But I don't understand how to you set the reporting mode as continuous.

How do I use the int REPORTING_MODE_CONTINUOUS to set reporting mode of sensors as continuous so that I get constant sampling rate for multiple sensor readings?


Solution

  • In https://source.android.com/devices/sensors/report-modes.html , you can find that

    each sensor type has one and only one reporting mode associated with it.

    The reporting mode for each type of sensor can be found at https://source.android.com/devices/sensors/sensor-types.html.

    Fortunately, accelerometer and gyroscope are sensors with continuous reporting mode, so you can use the registerListener() function and start getting your listener called.