Detect device moving distance - android

What is the best way to detect user device moving? For now I'm using network/GPS location determining best coordinates on small interval. But it would be great to improve accuracy user movement information up to meters. Geolocation strongly depends on network connection quality or weather.. Is there a way to find very accurate info about device moving? May be accelerometer can help?

Accelerometers tend to be a poor way to measure distance moved, as the slightest error in the measurement of acceleration or orientation rapidly integrates to a substantial position error. That's even more true with low-accuracy components used in a consumer device - inertial navigation systems used in aircraft/spacecraft are not cheap, and even those might not be accurate enough for your needs.
If you want positioning accuracy, especially over any duration of time, you need to measure in relation to the outside world, as GPS does. There are various beacon systems available using things like ultrasonics, or even adding pretend satellites to the GPS system which you could look into, but it's not going to be simple.

Related

How to obtain the speed that the user of an Android device is moving? Is Location.getSpeed reliable?

I am trying to get the user's speed from their Android device, but which is the most reliable way to do it?
There is the location.getSpeed() function that uses GPS; is this a reliable way to obtain the speed? Should I instead calculate speed manually using GPS coordinates obtained? Or is there another way that I'm missing to accomplish this?
IMO, best current approach on Android is to use Location.getSpeed() along with the Google Services Location API and the fused location provider. Then, reality-check this value against Google Play Services Activity Recognition.
The fused location provider integrates some other on-board sensors to tweak location data, which is better than GPS alone. Then, check the ActivityRecognition.getMostProbableActivity() method. If the DetectedActivity is type STILL, your true speed is probably equal to 0. If its ON_FOOT, it's probably a low speed (e.g., 1 m/s). If its ON_BICYCLE or IN_VEHICLE, you're probably fine relying on the speed output obtained directly from Location.getSpeed(). You'll also want to check the DetectedActivity.getConfidence() value too, and set your own threshold for a confidence level you feed "confident" with :) when relying on these values.
I'd also definitely suggest that you do NOT simply average sequential positions to get an average speed between two position (if you do this, it needs to be an average over a large number of positions). In my benchmarking on mobile devices (see my dissertation here, pages 105-106, and 137-138 especially), I've found instantaneous speed calculated by the GPS subsystem (which is typically based off of the Doppler shift of GPS carrier signals) to be far more accurate than the positions derived from GPS. 95th percentile of speed observed while stationary indoors (using assisted GPS only, no sensor fusion) was 1 m/s on a Sanyo Pro 200 I tested. I was able to filter out a significant number of position outliers using speed data (see page 137-138) in some intelligent energy management techniques I was evaluating. With sensor fusion, and activity recognition to help filter outliers, accuracy should be better than this on a similar device.
Finally, and I can't emphasis this enough, do you own testing on real devices, as many as you can get a hold off, and preferably the most popular models out there. Android has a variety of OEMs putting out devices, which will all have their eccentricities. Your best bet it to create a solution that targets the most popular models, acknowledging that it's unrealistic to get a solution working perfectly on all models.
It seems that the getSpeed() method is not always reliable, especially at low speed and when gps coverage is not optimal.
You can have a look at this question and this one which are both about alternatives for getSpeed().
The android developper page however says that you'll get better performance by using the Google Location API.
So it appears that the choice is depending on the usage of your app: if you target slow displacement in area with poor gps coverage (walking in the wood), use your own implementation. Fast in area with good GPS coverage, use the Google Location API.
The best way for devices that are moving faster than walking speed, is to use directly the location.getSpeed().
For pedestrian, or other slow speed situations, this is not quite easy, maybe it is simply impossible to have a valid slow speed that is valid at the moment.
Some try to evaluate the history and do an averaging, or threshold based approach, this will improve for a specific application / usage.
But the simplest is to design your App to ignore low speeds.
Some links related to speed:
GPS position correction
Smooth GPS data

How to measure the speed of car by phone with accelerometer and gyroscope?

I want to know current speed of car and make a passed path. I have an Android phone with accelerometer and gyroscope which sent me data. This is the data in phone system of coordinate that probably wouldn't the same as coordiante system of car.
How I can transform this accelerations and rotations to car system of coordinate?
The generic answer for your generic question is no. The acceleration measures the changes in the speed, so the best you could get from acceleration, is the speed variation.
To get the absolute speed you would have to have the initial speed and add it to the speed change:
v(t) = v0 + a*t
So, if you would have a car moving along a straight line, and your device was fixed to the car, you could get easly the speed changes (although measurements errors will add up and quickly lead to discrepancies)
In practice you will face many issues trying to implement it, namely:
You need the initial speed to be determinate based on the same referential as the acceleration. This would require some measurements and a lot of trignometry, as you would get both values from different sensores at different rates.
The car will not move in a straight line, so your acceleration referential will be constantly moving (a lot more of trignometry and calculus).
If the device is in the user hand, the device movements in relation to the car will increase even more the calculations (and accumulated errors).
Regards.
You need some sort of external reference (e.g. GPS is such a thing): If you just integrate the acceleration, the error will go indefinitely.
Because these sensors are not accurate enough. the error will quickly get out of control. (The linked answer is about position but the same holds for the velocity.)
In case of a car, you are better off with the GPS. If want to do something fancy, you could enforce the environmental constraints deduced from a map, that is, assume that the car goes on a road and not through buildings, etc. You will find more details on this in Chapter 5 of the PhD thesis entitled Pedestrian Localisation for Indoor Environments.
It looks like it's possible to do. I don't have an Android specific example but this forum has quite a lot of chat about it: http://www.edaboard.com/thread119232.html
It would be a lot easier if you used the Android Location class though. Specifically the getSpeed() method should give you what you need: http://developer.android.com/reference/android/location/Location.html
The Location class relies on a location provider though so your app will require appropriate permissions.
Both dont deliver anything if the car travels at the same constant speed for some time. The only way would be GPS which has a calculated speed with every location it provides.

A "speedometer" that doesn't use GPS

How to calculate speed without requiring GPS? I have heard of something called "sensor technology" but am not sure what that means. I am asking because I want to make an app, but I don't think it is battery efficient to use GPS, plus it is for a long-term project so I want the app to continuously run without having to manually turn it on or turn on GPS.
GPS is by far the most accurate way to do this.
You can get access to the accelerometers, but they are not remotely accurate enough for this type of application.
The only other way I can think of would be to get one of those bluetooth adapters that you plug into your car's diagnostic port, and get the speedometer input from there. Then, you're wasting power on bluetooth as well.
Just buy a power adapter for your phone to run on the vehicle.
I tried to measure the speed using Android's accelerometer sensor for an indoor-navigation project but that failed miserably. I intented to derive the current speed from the acceleration/deceleration over time and so in the end calculate movements along the X, Y and Z-axis, but that didn't work out at all. The accelerometer sensors of common Android devices are way too inaccurate for that kind of usage.
So, you will have to use GPS. To reduce battery drain, you can increase the intervals (time and/or distance) in which the LocationManager notifies your App. See the minTime and minDistance parameters of it's requestLocationUpdates() method.
Android allows you to use cellular phone antennas and wi-fi access point antennas as reference points to determine your current location without using the GPS (see: locationManager.NETWORK_PROVIDER).
Once determined your position in two different moments/points you can easily calculate your speed in your code.
I don't think one can calculate speed without the assistance of GPS. Speed depends on distance and time. I am not sure if we can calculate distance just like that.
Anyway look at http://developer.android.com/reference/android/hardware/Sensor.html
There we have different sensor types. Perhaps you can make use of one of those.
I think what you are referring to would be considered "dead reckoning" (http://en.wikipedia.org/wiki/Dead_reckoning) and is possible, but will lead to drift and incorrect speed information, especially if the user of your app doesn't have the device mounted securely to whatever is moving.
Would it be a valid use case for your app to go to sleep and turn off the GPS? You might be able to devise a way to turn the GPS back on when you bring the app out of suspension. If you need the location always, then GPS is your best bet. People understand that GPS based apps require power and will come up with a way to plug it in to use it long term.
Perhaps you should think about the use cases for your app and ask if people are willing to drain their battery power for whatever functionality you will offer.
Using acceleration and time you can calculate change in velocity but you don't necessarily know the starting velocity. Plus the accelerometer in an iPhone probably isn't accurate enough for this anyway, but it's not a bad shout.

GPS V.S. accelerometer to calculate distance

I am trying to implement a fitness app that can keep track of the running speed and running distance in Android.
It looks like I can either use GPS or Accelerometer to calculate these information.
Since a runner may put his phone in hand, on the shoulder or in his pocket, my first intuition is to use GPS to get locations and calculate running speed and running distance. But recently someone telled me that I can also use Accelerometer also does that.
My question is: In Android, which approach is better to calculate running speed and running distance, GPS or Accelerometer?
I suspect that pedometers are based on accelerometers because accelerometers are cheaper than GPS to use. in fact I think a lot of pedometers don't even try to measure distance. just acceleration jolts which equal steps. and then if they give you a distance measurement, it's by multiplying detected steps by a guessed or average step size.
GPS (if you are in an area where it works!) will do a very good measurement of distance. Even with a very cheap GPS receiver. All being basically OK, you should expect start and end positions to within 10m, and so for a 1km travel, you have 20m of uncertianty, which is 2% total distance uncertianty. This uncertianty goes down linearly with distance travelled (ie a 2km run will have 1% uncertianty, 4 km run will have 0.5% uncertianty, etc) the issues here will be with your realtime displays (GPS position jumps from satellite switching giving massive speed values, or immediate loss of signal giving a loss of all immediately displayable data)
I think that with a good accelerometer, starting from stopped you can continually integrate the signal to get speed, and continually integrate that result to get distance... I am just unsure what kind of accelerometer quality you get in any given phone? you may need to filter for noise or even garbage data.. And you also need to consider what accuracy it has. 20% accuracy in your sensor would make for a very bad distance tracker. So you might have to work with step counting and step size guesstimates.
perhaps a combination of both could work?
I'd be tempted to use the accelerometer data (either integrating or step counting depending on what will always work) to track speed and distance in short timeframe, then with much longer timeframe, generalised GPS data could be used to correct or scale that data from the accelerometer. Especially if you filtered/blocked GPS data based on uncertianty measurement at any given time.
Adding to what Julian said ... Normally GPS doesn't work under the roofs therefore for indoor gyms it will not work. Theoretically GPS signals are not bothered by clouds but when I was working on my GPS application, I had experience of unavailability of GPS signals in really bad weather (this might not be your case as no one will go on jogging in thunder storm :D)
Agreeing with Julian, you should use both GPS and accelerometer to build a reliable app for every condition.
The best results are obtained by using both of them, through sensor fusion. See:
Android accelerometer accuracy (Inertial navigation)
You will have accuracy problems if you just use either the GPS or a pedometer algorithm.
All pedometers I know are based on accelerometers. I guess, GPS is not precise enough for this stuff. It may say "no motion" while you did some steps, it's also dependent on the area you are trying to use it.

Can detect the distance (with x, y and z coordinates) from a fixed point in space on Android?

I would like to find the position of an Android device with respect to a fixed point in space.
I need a precision close to one or two meters.
My goal is to determine the position of the android device user inside a building (a museum), to detect the floor and the room she is in, and - if possible - even a more precise position in the room (to know which painting she is close to).
I did already excluded to use GPS, since it is not so precise (expecially with respect to elevation), it only reliably works outdoors, it quickly consumes battery power, and it doesn't return the location quickly.
I did already excluded to use Network Location Provider too, since it is even less accurate.
In Android you have three possibilities to detect the location of a Android phone:
1) GPS
2) Network
3) Triangulation
But none of these three possibilities is suited for you're problem. The GPS is the most accurate one, but as you already noticed it is not working in buildings, and it won't be able to differentiate between different floors. The problem is that the accuracy of GPS is at best 3 or 4 meters. The other two possibilities are far less accurate. That's why there isn't a real solution for your problem.
One thing that might be a possibility is the motion sensor. If you know where the user starts, you maybe can use the motion sensor to calculate how many meters the user moves. But I don't think that this is accurate enough.

Categories

Resources