How to get ground acceleration with compass&& acceleration sensor in android? - android

I want to get the acceleration of three direction(North,South,Sky) with the data from TYPE_ACCELEROMETER and TYPE_ORIENTATION(or Compass). What should I do to calculate?

You can not get acceleration in World coordinate with TYPE_ACCELEROMETER and TYPE_ORIENTATION. You need TYPE_ACCELEROMETER and one of TYPE_GRAVITY or TYPE_MAGNETIC_FIELD or TYPE_ROTATION_VECTOR. I am pretty sure that the depreciated TYPE_ORIENTATION also use one of the three above.

Related

Which Android sensors are redundant?

I'm recording the following sensor values from my tablet (given as constants of the Sensor class):
TYPE_ACCELEROMETER
TYPE_GRAVITY
TYPE_GYROSCOPE
TYPE_LIGHT
TYPE_LINEAR_ACCELERATION
TYPE_MAGNETIC_FIELD
TYPE_ROTATION_VECTOR
The problem is that I'm producing too much data. That's why I want to use less sensors. I think some sensors are redundant, i.e. can be computed from other sensor values. For example I think linear acceleration and gravity will give accelerometer and perhaps the rotation vector can be computed from linear acceleration and gyroscope (how?).
Which sensors are redundant? I'm guessing that accelerometer (or linear acceleration) as well as the rotation vector are redundant. Moreover, can the magnetic field be used for the computation of other measures (like the rotation vector)? I don't need the magnetic field value on its own, so perhaps I can also throw it out.
Edit: I think it holds that accelerometer = gravity + linear acceleration. Does this mean that gravity and linear acceleration correlates with the accelerometer? Correlated features would be useless as input to my machine learning pipeline.
I guess that rotation vector is computed with the help of the magnetic field but my magnetic field sensor has low accuracy (reported by Android), so I could drop magnetic field as well as rotation vector.

What is the difference between "gravity" and "acceleration" sensors in Android?

What is the difference between gravity and acceleration sensors in Android? From my point of view the physical value is the same in both cases.
Which one measures the force acting on unit mass inside the device?
ADDITION
The question is: what physical quantity is measured by these sensors? According to equivalence principle the acceleration and gravity are indistinguishable and the only way to measure both is by usual (but 3d) spring balance.
Acceleration sensor gives you back the sum of all forces applied to your device, while Gravity sensor returns only the influence of gravity. If you want to exclude the gravity from acceleration, you may use a high-pass filter or just subtract the gravity sensor values from acceleration sensor values -- not sure which method gives better precision.
Another method could be using Sensor.TYPE_LINEAR_ACCELERATION, which gives exactly (acceleration - gravity), however you should check if it's available on the device. I've found a few devices, which have ACCELERATION sensor working, but no response from GRAVITY or LINEAR_ACCELERATION sensors.
This link might be helpful: http://www.sensorplatforms.com/which-sensors-in-android-gets-direct-input-what-are-virtual-sensors
The following excerpt summarize the answer for your question:
"The list... includes both physical sensors and sensor types with values derived from physical sensors, sometimes these are called virtual sensors... The virtual sensors types (gravity, linear acceleration, and rotation vector) provide values derived by combining the results from physical sensors intelligently... The rotation vector is a combination of the accelerometer, the magnetometer, and sometimes the gyroscope to determine the three-dimensional angle along which the Android device lays with respect to the Earth frame coordinates. By knowing the rotation vector of a device, accelerometer data can be separated into gravity and linear acceleration."
This link https://stackoverflow.com/a/8238389/604964 also says that the gravity values are computed using a Butterworth filter.

SensorManager.getRotationMatrix gravity parameter or accelerometer parameter values in android?

In Android Documentation is specified the third parameter as
float[] gravity
then is specifies
[0 0 g] = R * gravity (g = magnitude of gravity)
Now, in most of the examples online I can see everyone sending accelerometer values to getRotationMatrix, but, Isn't suppose that I should send only gravity values?
For example, if the mobile phone has the gravity sensor,
Should I send it raw output to getRotationMatrix?
If it hasn't one, Should I send accelerometer values? Should I extract non gravity components first? (as accelerometer values are Acceleration minus G).
Will the use of gravity sensor values be more reliable than using accelerometer values in mobile phones that have that sensor?
Thanks in advance! Guillermo.
I think the reason you only see examples using the accelerometer values is because the gravity sensor was only launched in API 9 and also because most phones might not give this values separated from the accelerometer values, or dont have the sensor, etc, etc..
Another reason would be because in most of the cases the result tend to be the same, since what the accelerometer sensor outputs is the device linear acceleration plus gravity, but most of the time the phone will be standing still or even moving at a constant velocity, thus the device acceleration will be zero.
From the setRotationMatrix Android Docs:
The matrices returned by this function are meaningful only when the device is not free-falling and it is not close to the magnetic north. If the device is accelerating, or placed into a strong magnetic field, the returned matrices may be inaccurate.
Now, you're asking if the gravity data would me more reliable? Well, there is nothing like testing, but I suppose it wouldn't make much difference and it really depends on which application you want. Also, obtaining the simple gravity values is not trivial and it requires filtering, so you could end up with noisy results.

Difference Between Orientation Sensor and Accelerometer Sensor

I want to know about the values of X,Y and Z axis for any position/movement of device so I can use these values for my further work. As I searched there are two methods, Orientation Sensor(gives value in degree,as azimuth,pitch and roll) and Accelerometer(gives values between 1 to 10 for x,y and z).
As per my understanding both are same for my requirement. I can't find difference between them. Please can any one clear me about them in detail w.r.t my aim. which sensor should I use?
There are differences between both:
Accelerometer detects acceleration in space. The reason why it will always detect an acceleration of 9.8m/s^2 downwards is because gravity is equivalent to acceleration in space.
Orientation detects if your device's axis are rotated from the real-world; it detects tilts and and degrees from the magnetic North. Please note that this sensor is deprecated and Google recommends you use the accelerometer and magnetometer to calculate orientation.
You'll need the accelerometer to detect movement. So you should use this one, since your aim is to know this movement.
The orientation sensor gives information about its position compared to a reference plane. So you could use this to see of the device is tilted, upside down or something like that.

Regarding BMA-150 Acceleration sensor

At present i am working on hal part of sensors in android sdk, we are using 3- Axis BMA-150 Accelerometer sensor to get acceleration values with respect to X,y,Z Axis, I want to know whether this sensor will give o/p directly in SI units by using some calibration techniques or what ? , and i noticed that in sensor.c file they mentioned
720.0 LSG = 1G(9.8 m/s2), what is the relation between LSG and acceleration due to gravity?
what is meant by LSG
why they are multiplying the o/p of accelerometer x,y,z valuse with 9.8/720.0f . please help on this part .
Thanks
Vinay
Without knowing anything about the device, 9.8 meters per square second is the value of gravitational acceleration at Earth surface. The equation you quote seems to be definition of "LSG" and the only thing that makes sense to define in the context is the unit in which output is provided. So the device will probably give output '720.0' on the axis that is vertical. By multiplying with 9.8/720.0 you renormalize the value to SI unit (m/s^2)
(Average gravitational acceleration, denoted G (that explains the 1G), is 9.80665 m/s^2, but varies by a few percent between equator and poles and the device is probably unable to give more than two significant digits precision anyway)

Categories

Resources