motion — Motion Sensor Data on iOS#

The motion module allows you to access your iOS device’s motion sensor data (accelerometer, gyroscope, magnetometer).

Functions in the motion module:

motion.start_updates()#

Start monitoring the device’s motion sensors. You should balance this with a stop_updates() call to improve battery life. All the get… functions require that you call start_updates() first, otherwise, no meaningful data will be returned.

motion.stop_updates()#

Stop monitoring the device’s motion sensors.

motion.get_gravity()#

Return the gravity vector (x, y, z).

motion.get_user_acceleration()#

Return the acceleration the user is giving to the device. The total acceleration is equal to the gravity vector returned from get_gravity() plus the user acceleration.

motion.get_attitude()#

Return the attitude of the device (roll, pitch, yaw).

motion.get_magnetic_field()#

Return the magnetic field vector with respect to the device (x, y, z, accuracy).