Is it possible to use the accelerometer to detect height? For instance, if I'm holding the phone on my hand and then detect the height after raising my arm?
Thanks
Assuming you mean you want to detect the height the phone was raised from its staring point, yes. The android accelerometer measures force, more info on how to use it can be found here. Keep in mind that the accelerometer isn't a perfect device, and so your results will be approximations of how much the phone was really moved.
The inaccuracy of the accelerometer will be insignificant when compared to the error caused by an unstable accelerometer. What I mean by this is the fact that as you move your phone you will not be able to keep the accelerometer orientated perfectly i.e. you will 'naturally' rotate it about its longitudinal,lateral and azimuth axes. This means that a vertical acceleration will partly be felt in all the above axes and result in an error if you were to just integrate twice the vertical acceleration measurement.
There are ways to eliminate this error which involve gyroscopes but that requires some complicated mathematics and gyros to be fitted in your phone as well.
In theory you can integrate an accelerometer's output but in a real-world device there are practical issues you must overcome.
You get position by integrating the linear acceleration twice but the error is horrible. It is useless in practice.
Here is an explanation why (Google Tech Talk) at 23:20. I highly recommend this video.
Similar questions:
track small movements of iphone with no GPS
What is the real world accuracy of phone accelerometers when used for positioning?
how to calculate phone's movement in the vertical direction from rest?
iOS: Movement Precision in 3D Space
How to use Accelerometer to measure distance for Android Application Development
How can I find distance traveled with a gyroscope and accelerometer?
Distance moved by Accelerometer
Yes, bt you need to integrate the output twice and add in the two integration constants - initial velocity and displacement.
Rgds,
Martin
First of all you measure Linear acceleration and gravity together (also some noise)
So it means when you are using accelerometer you will get
Accelerometer Readings = Linear Acc. + Gravity + Noise
Here you just only need Linear Acc. but the Accelerometer reads all the values
Related
My goal is to have a simple stroke rate detector displayed on my Android Watch (Sony Smartwatch), for this I need to detect when the watch changes from moving forwards to moving backwards.
I have code working that will get the event values (x,y,z) as detected in the onSensorChanged event (and display them on the watch), but I am struggling to make sense of these.
I understand the values report acceleration in the given axis, and I understand that z reports gravity. But if these values are reporting just acceleration, I am not clear how to know when there is a change of direction. I presume a positive number indicates acceleration, a number of 0 is a constant speed and a negative number is deceleration...is that correct? And if so, how can I detect when the Watch has changed direction from going forwards to going backwards?
Thanks in advance.
Android Wear is no different than "conventional" Android when it comes to detecting motion. Basically, you need to consider exactly what the accelerometers are recording: raw acceleration (with a lot of noise). To determine motion from that, you need to look at trends over time, and probably integrate the smoothed accelerometer data. It's not trivial.
You'll probably want to use the TYPE_LINEAR_ACCELERATION sensor, because it filters out gravity (which isn't relevant to your use case). And because the watch will probably experience some rotation during a rowing stroke (which you want to factor out), you may need to combine TYPE_ROTATION_VECTOR with the acceleration vector to accurately determine direction changes.
A couple of other SO questions which may help point you in the right direction:
how to calculate phone's movement in the vertical direction from rest?
How can I get the direction of movement using an accelerometer?
I've not attempted this specific problem, of course, but I've done enough other work with Android motion sensors to know that you have a good programming challenge ahead of you. Enjoy it!
Is there any method of calculating linear distance using accelerometer and gyroscope sensor data as double integral on acceleration seems to give lot of drift.
Note : Image processing techniques using the camera / GPS seem to be a heavy duty on battery.
Since you wish to calculate linear distance, you should not read from raw Accelerometer data. In API 9. android introduced Sensor.TYPE_LINEAR_ACCELERATION, which is nothing but the gravity component deducted from raw accelerometer values.
The drift can build up much quickly if there is even a single degree error in your own calculations for finding linear component in raw data. Check out an experiences from Google: SensorFusion.
The question is very similar to Calculating distance using Linear acceleration android
I'm trying to write a small android game where the phone is placed on the table.
On the screen there is a ball, which the user control its movement by moving the phone.
Along all the game the user won't lift the phone from the table.
At the beginning the ball will placed in the middle of the screen:
Pushing the phone from the user:
should move the ball toward the top of the smartphone screen:
And from the current position of the ball, moving the phone back to the user, and to the right:
will move the ball accordingly:
I read the Android Motion Sensors Guide carefully but I didn't even realize what Sensor \ Sensors should I use.
I would love to get any directions.
First of all TYPE_LINEAR_ACCELERATION, TYPE_ROTATION_VECTOR, TYPE_GRAVITY are not physical sensors but made from sensor fusion.
Secondly from Android 4+ these fused sensors make use of device Gyroscope, so they WON'T work if the mobile device doesn't has a gyroscope.
So if you want to make a generic app for all phones prefer using only Accelerometer (TYPE_ACCELEROMETER).
Now for your case since user won't lift the mobile from table, and if you want you can easily subtract the Gravity component from accelerometer. See http://developer.android.com/reference/android/hardware/SensorEvent.html
under section Sensor.TYPE_ACCELEROMETER. (Code is given too).
Now you can see How can I find distance traveled with a gyroscope and accelerometer? to find the linear displacement & the 1st answer states their is NO use of Gyroscope. (Or you can just google for finding the displacement/Linear velocity from acceleromter readings)
Hope this all would give you quite lot an idea.
It's really difficult to do this type of linear position sensing using the types of sensors that smartphones have. Acceleration is the second derivative of position with respect to time. So in theory, you could use the accelerometer data, integrating twice in time to achieve the absolute position. In practice, noise makes that calculation inaccurate.
On the other hand, if you're really talking about putting the camera facedown on the table, maybe you can come up with some clever way of using OpenCV's optical flow features to detect motion using the camera, almost like an optical mouse. I don't know how you would light the surface (the flash would probably burn through the battery) but it might be possible to work something out.
I am just a beginner in the application development industry. I know the accelerometer can be used to return the current acceleration along three axis in meters per second squared (m/s2). But I have come to know that an accelerometer can also be use as speedometer.
I want to know how I can use accelerometer to determine distance traveled by Android device between points of interest. If it is possible, then how can I implement it? I have seen a similar question "how do I measure the distance traveled by an Iphone using accelerometer" How do I measure the distance traveled by an iPhone using the accelerometer?. But I didn't come to a point.
Thank You,
Arslan
You get position by integrating the linear acceleration twice but the error is horrible. It is useless in practice.
Here is an explanation why (Google Tech Talk) at 23:20. I highly recommend this video.
Similar questions:
track small movements of iphone with no GPS
What is the real world accuracy of phone accelerometers when used for positioning?
how to calculate phone's movement in the vertical direction from rest?
iOS: Movement Precision in 3D Space
You can combine it with GPS positioning, and filter data with Kalman filter.
GPS give rough but stable position, while accelerometer give more accerate but drifting position.
I am just a beginner in the application development industry. I know the accelerometer can be used to return the current acceleration along three axis in meters per second squared (m/s2). But I have come to know that an accelerometer can also be use as speedometer.
I want to know how I can use accelerometer to determine distance traveled by Android device between points of interest. If it is possible, then how can I implement it? I have seen a similar question "how do I measure the distance traveled by an Iphone using accelerometer" How do I measure the distance traveled by an iPhone using the accelerometer?. But I didn't come to a point.
Thank You,
Arslan
You get position by integrating the linear acceleration twice but the error is horrible. It is useless in practice.
Here is an explanation why (Google Tech Talk) at 23:20. I highly recommend this video.
Similar questions:
track small movements of iphone with no GPS
What is the real world accuracy of phone accelerometers when used for positioning?
how to calculate phone's movement in the vertical direction from rest?
iOS: Movement Precision in 3D Space
You can combine it with GPS positioning, and filter data with Kalman filter.
GPS give rough but stable position, while accelerometer give more accerate but drifting position.