How to isolate gravity in the accelerometer

Asked

Viewed 240 times

3

I’m developing an app in which the user needs to shake their phone to all directions and the smartphone needs to maintain stable guidance in the meantime. The problem is that all ways to achieve spatial orientation like TYPE_ROTATION_VECTOR, TYPE_GEOMAGNETIC_ROTATION_VECTOR, and even the getRotationMatrix() use the accelerometer together, and the moment the user moves the cell the direction of gravity changes due to lateral forces.

Is there some kind of filter to isolate gravity? That is to isolate the user’s movements, so that the sensor returns only the direction of gravity to improve orientation.

There are several posts on how to remove gravity, but there is nothing about isolating it.

2 answers

1

You can use the function getInclination( float[] I ), it gives the inclination only, at an angle (radians). That is, it gives the inclination in relation to the force of gravity.

float inclinacao = SensorManager.getInclination(inclinationMatrix);

So you can adjust the rotation of the screen according to the angle.

0

I’m not sure I understand the question.

The accelerometer does not measure gravity, it measures accelerations, including gravity. When you move the cell, gravity does not "change", the resulting vector changes.

If you can remove gravity, you can isolate the vector from the user’s movements (which will be the total minus gravity). If you can isolate this vector, just subtract from the total you get gravity.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.