I'm trying to write an android code that uses the device sensors to detect freefall scenario.
I searched the web a lot for a solution to this problem but I was unable to find anything useful.
I did see that there are several apps that does exactly this so it is possible, but i didn't find any code sample or tutorial on how to do that.
Can anyone please help me with a code snippet or even with a mathematical calculation using the sensors data?
Thanks in advance
The device is in free fall if the length of the vector given by TYPE_ACCELEROMETER is approximately zero. In theory, it should be exactly zero, in practice, it well be only near zero. So you need to come up with some threshold by trial and error and declare that the device is in free fall if the length of that vector is below this threshold.
Check out the API here SensorEvent Values and the math behind FreeFall here Wikipedia.
You are trying to detect speed in some direction. Look at the motion equations on wikipedia. You are detecting acceleration over time that is normalized for the gyroscopic rotation of the device.
Also see: How to approach Fall Detection Algorithm
From what I've read, the accelerometer normally measures gravity. Thus, if you're in freefall and the device is not being moved laterally, all accelerometer readings should be zero. (Disclaimer: I have not written any accelerometer code.)
Google the iFall project by a group at Florida State University. The have published a paper describiing the approach they took for their Android iFall application, which gives a host of references for further/extended study. They also have an API available and explain how to use it, if you want a fast shortcut approach. (To use their API, I believe you just need to download and install their iFall app form the Playstore)
Related
I've been doing a bit of research on a problem we are trying to solve. I think this is the best approach but please add in your opinions
We are trying to calculate reaction times in a real world driving scenario and would like to use a mobile phone as the data collection device. What we are trying to accomplish is how much acceleration and more importantly deceleration a driver exerts when exposed to certain prompts.
I found this paper that has allot of useful information Accelerometer physics
The problem is that we most likely will not have a calibration time to start at zero.. however it is assumed that the driver is starting at 0. We will use GPS positioning to locate the vehicle, tracking the time stamped location data we should calculate the time when the prompt took place then using the time stamped accelerometer data we should be able to calculate their reaction to the prompt.
This is the best way I have found to solve the problem however I'm not sure if the accelerometer data will be rendered useless because of not being able to calibrate it and also the noise seen from vibrations may be too great to use the data... Has anyone tried or used these types of methods before?
Interesting application.
You are missing an important point. You either have to implement the so-called sensor fusion yourself or use the sensor fusion provided on the platform you are using. Both Android and iPhone have one.
The TYPE_LINEAR_ACCELERATION (Android, SensorManager) or userAcceleration (iPhone) should be sufficient for you.
As for the linked PDF, don't try integrating the acceleration, you will get very poor results. Even though that answer is about position, the velocity will already be inaccurate. I would try the GPS instead.
I know it's very old question but since I am recently working on a similar project let me share what we did in our company. We simply used OBD-II dongle to get velocity of car. There are many API's that return information about vehicle.
PID010D returns speed of vehicle. I'm using this PID to calculate distance between points A and B since there is no PID to return Odometer :(
There are few libraries on github that you can find easily by search. This mine. This is not library but after run on your device you can see how it works.
I am a newbee in android and I have a question.
I surfed a lot in order to find out how to calculate the no of stairs climbed.
Now I came across accelerometer and few applications which ask us to input certain values like tread, raise and so on.
GPS was another option. But to my knowledge GPS does not work indoors.
I just wanted to know is there any way else to find the no of stairs climbed apart from this.
Thanks in advance.
You will need to use accelerometer. There is no other way to do it.
See how to count step using accelerometer in android for possible answers. To avoid asking for tread depth and step height, you could assume one step per step, if you see what I mean :)
I would try to develop a pedometer algorithm specifically for this task, see reference to the general pedometer algorithms at Android accelerometer accuracy (Inertial navigation), under indoor positioning.
Developing a pedometer requires lots of experiments and tweaking, and there will always be a way to fool your application.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to Count the Number of Steps Using the Accelerometer
Are there any well known algorithms to count steps based on the accelerometer?
Hi i have developed android application. In one module I have to create a pedometer. Now at this stage I have to count the steps user walked by using accelormeter. I have search on internet and found different methods but none of that working. I have tried this
Does anyone have an idea how to achieve my goal? Any help is appreciated.
The simplest solution would be to have a time-window and a number of thresholds. The signal gets a form of a double wave, and you can split a step into several parts. You may need to have several windows and corresponding threshold values to recognise one step. But keep in mind that this signal will change if someone is walking upstairs/downstairs or running or just walking with different pace. You will get great variability if you actually going to try it with several participants.
Threshold values will differ greatly between devices. Frequency of measurements will also have an impact. Standard frequency that allows one to detect walking with normal pace is about 10Hz, some devices use 20Hz, if you go over this you will get lots of data and little information. Manufacturers do use different versions of accelerometers, so if your software works on one phone, there is no guarantee it will work on the other device even of the same model.
I would start from plotting your signal first. Also don't forget that the phone can be in different positions in a pocket (unless you fix it somehow) so the threshold values will float. All clinical pedometers are usually affixed to the leg in a certain position.
Consider using mono-axial accelerometry instead of 3-axial, the signal analysis gets much more easier to begin with. Also take a look at the Fourier transformations and wavelet analyses.
See the image below to get a basic idea of how walking looks with a 3-axial accelerometer. I made it when was doing similar task (walking is the noisy bit).
And this is how walking looks with a mono-axial accelerometer (again noisy bits)
This seems to be pretty reasonable and accurate:
Enhancing the Performance of Pedometers Using a Single Accelerometer
Anyhow, I am also interested in finding a good algorithm.
I've been doing a bit of research on a problem we are trying to solve. I think this is the best approach but please add in your opinions
We are trying to calculate reaction times in a real world driving scenario and would like to use a mobile phone as the data collection device. What we are trying to accomplish is how much acceleration and more importantly deceleration a driver exerts when exposed to certain prompts.
I found this paper that has allot of useful information Accelerometer physics
The problem is that we most likely will not have a calibration time to start at zero.. however it is assumed that the driver is starting at 0. We will use GPS positioning to locate the vehicle, tracking the time stamped location data we should calculate the time when the prompt took place then using the time stamped accelerometer data we should be able to calculate their reaction to the prompt.
This is the best way I have found to solve the problem however I'm not sure if the accelerometer data will be rendered useless because of not being able to calibrate it and also the noise seen from vibrations may be too great to use the data... Has anyone tried or used these types of methods before?
Interesting application.
You are missing an important point. You either have to implement the so-called sensor fusion yourself or use the sensor fusion provided on the platform you are using. Both Android and iPhone have one.
The TYPE_LINEAR_ACCELERATION (Android, SensorManager) or userAcceleration (iPhone) should be sufficient for you.
As for the linked PDF, don't try integrating the acceleration, you will get very poor results. Even though that answer is about position, the velocity will already be inaccurate. I would try the GPS instead.
I know it's very old question but since I am recently working on a similar project let me share what we did in our company. We simply used OBD-II dongle to get velocity of car. There are many API's that return information about vehicle.
PID010D returns speed of vehicle. I'm using this PID to calculate distance between points A and B since there is no PID to return Odometer :(
There are few libraries on github that you can find easily by search. This mine. This is not library but after run on your device you can see how it works.
I'm making an application that works as a compass..
I'm using the accelerometer and the magnetic field sensors to compute the azimuth angle through, sensor.getOrientation().
I'm searching for something that can improve the magnetic field sensor accuracy, since I'm getting it state of accuracy as UNRELIABLE!
Any one knows anything about this?I'm looking for something that can be either hardcoded or for instance just physically moving the phone until it gets calibrated!
This is not a final answer (I don't know anything for sure), but my understanding from online posts is that waving the phone around in a figure of 8 a few times while the compass is in use is supposed to trigger automatic recalibration. This is what the google maps app suggests, for example. I don't know whether this is dependent on application functionality (something in maps that detects the waving by accelerometer and triggers a recalibration), or something in the android stack, or something specific to per-phone implementations. Try it and see!
Eg discussion: http://androidforums.com/epic-4g-support-troubleshooting/217317-cant-get-compass-calibrate.html
This reference appears to suggest this per-axis / figure-8 rotation process is built-in functionality: http://m.eclipsim.com/gpsstatus/
And here another article that claims this is built-in functionality, and that you don't even need to be running a compass-consuming app for the recalibration to work: http://www.ichimusai.org/2009/06/20/how-to-calibrate-the-htc-magic-compass/
Just a few points
The figure 8 motion works sometimes and not others, I have no idea why, they really need to have some kind of code based way to check if the 8 motion worked (Assuming that the physical motion is actually required)
They also need a way to detect that calibration is required, I looked at the code for the accuracy output (the unreliable constant) and once they send it to you they will not send it again, so for instance if you calibrate but then come within a strong magnetic field it will not resend (not sure why they did that)
One not completely reliable way to detect ongoing issues is that you can also use the magnetic sensor output and do something like field=sqrt(x*x+y*y+z*z) and check that field falls between say 25 and 65 and then ask the user to calibrate if it does not.
The bottom line after testing 18 phones is that I would never depend on a Android based compass with the current crop of phones, accuracy would always be in question.
I have also found even if you are lucky and have a fairly reliable phone you can never be sure that it's calibrated without checking it against a real compass, which kind of defeats the purpose.
NOTE: On a lot of the mis-behaving phones we have found that the sensor writes a calibration file and a tmp file with the same name. If you delete those files and re-boot the phones the calibration file is recreated with zero'd values and the cold start and general calibration problems resolve themselves.
The bad news is that they are stored in /data/misc and require root privileges to get at (thanks Google & Sensor mfg!) so even though I suspect this would solve a lot of problems for a lot of developers it just is not viable from a marketplace app perspective.
I am developing for Android. I'm using Titanium Alloy as development tool with the Titanium Geolocation module.
I have only tested 2 devices [Galaxy Note and S4] against a commercial magnetic compass. Following a calibration process [tilt along the 3 axis] and using 2 different compass apps and the app I'm working on, the Android compass seems accurate enough for basic use ... correlation was good enough for my purpose anyway. I also found the device compass reading to be very sensitive to other magnetic and electrical field interference ... initial mistake I made was to use the compass feature whilst device was in a device protector with a magnetic closure facility [quite common on tabs] ... this interference is particularly strong. I thus need to suggest to users of my app to remove device protectors, keep device free of other electronics and then do standard calibration before initializing the app.
Another option is:
Go To sensors menu: #*0#*
Then if you see a red line in Magnetic Sensor section and a Need for Calibration you should recalibrate your compass.
How;
According those guys;
Turn the Samsung Galaxy Mini S5 around all of its axes until the red
line in the black circle changes color from red to blue. You can also
run through a motion that follows the shape of an 8. It may be that
several attempts are needed to calibrate the compass...