I want to calculate spped of android device using accelerometers sensor only not with GPS? - accelerometer

I need to create an app that Calculates the moving car velocity/speed, with x/y/z speed.
My idea is using device's accelerometer.
I am using Sensor.TYPE_ACCELEROMETER and getting ax,ay,az (acceleration in x,y,z direction). how to get sped of device. Lots of physics formulas suggested by people to get speed but any one of then not giving correct speed compared to GPS. Please tell me code or good link which solve my problem.

That would be very difficult. To calculate the speed of the device, you need to calculate the integral of the acceleration. But to do so, you need to very accurately know for very dense points in time both the device's rotation and its acceleration. Assuming you do have those things, you simply need to take the device's initial speed, and for each point in time add to it (rotation matrix * acceleration vector * time to next measurement). That's probably the most accurate thing you can that is simple enough.

Related

Get position from accelerometer

I am working in a monocular 3D Mapping project, and I need every time both position and rotation (angle).
To filter Gyroscope Data, I decided to use the "compass" and set 0 value to the angle if it's north.
But to get the position, I will need to double integrate the accelerometer value with a small sampling step (1ms) and 7 values mean filter.
I think this will make position more accurate. But does someone have an idea about the error range ? for example, in 10 meters, How much the error will be.
And does anyone have a better idea?
The sensors are from STM32F3 Discovery Board
Thanks
The STM32F3 has two sensors you'd be using:
LSM303DLHC accelerometer and magnetometer
L3GD20 3-axis digital gyroscope.
The sensor accuracy should appear somewhere in the datasheet. Since you'll be using several sensors, you'll have to calculate the total error over the time your measuring. Note, the error won't be a single number like 10 meters because it will accumulate over time. If you had a GPS or some other way of determining your position you'd be able to limit your accumulated error.
What you're doing sounds like an Inertial Measurement Unit. If you haven't already, I'd recommend reading up on that and also Dead Reckoning.

Finding distance using accelerometer in iPhone

Please suggest some beginning point in this process of finding distance displaced by an iPhone. The requirement of accuracy in current system is in cm, and displacement can be in 3D.
What I have already done is
1. Tried using sound to calculated distance between between 2 iPhones, but I need distance calculation with one iPhone only, i.e need displacement.
2. Tried CMMotionManager and its accelerometer data, but values received is helpless.
I think I need a good filter to get useful data out of that junk. I already used Kalman Filter and gone through link
iphone accelerometer speed and distance,
How to calculate distance using accelerometer using iphone sdk?,
How do I measure the distance traveled by an iPhone using the accelerometer?,
Basic calculus behind this problem is in the expression
Tried DCT-II algorithm and Multidimensional DCTs to filter data.
I dont know what did I miss, or where should I go from here, as it is hard to believe that no one has used accelerometer for such an accuracy, because there are so many practical examples of it being used for greater accuracy.
Please provide me some pointer that suggest some way out of current situation.
You can't achieve cm accuracy. The reason is, surprisingly, the orientation error.
The above link contains some tips what you can do if you need displacement.
An even better alternative is to use orientation in you application, if you can.

How can i handle distance through accelerometer?

My object starts from zero. When the time goes..It covers some distance, so how can I measure this?
Oh, it's simple. All you have to do is implement an Inertial Measurement Unit and then an Inertial Navigation System. It's going to be hard to do without rotation sensors, it would probably require a Kalman Filter for accuracy, and typically it is done with ring laser gyros or fiber optic gyros, which are "solid state" devices that work by measuring relativistic effects and sell for rather higher prices than the silicon micromachined sensors in the iPhone, but you might get it to work.
Or, you could just use the GPS.
Other than just being alerted that the device did move, the accelerometer will not be much use. You will not get a reading of "device moved 10cm" or something similar, as far as I know you'll just get a value for how much acceleration occurred.
If you need to track your device's movement in the physical world you'll need to use the Location APIs.
You can figure this out, but it won't be that accurate, mainly due to sample rate and the inaccuracy of the accelerometer.
First figure out direction and force of the movement. If the user moves the iphone at +0.1G along the X axis and 0G along the Y and Z axis, then our force is +0.1G on the X axis. 1G is 9.8m/s, so the phone has move 0.9m if it has been traveling for 1 second.

Detect the iPhone rotation spin?

I want to create an application could detect the number of spin when user rotates the iPhone device. Currently, I am using the Compass API to get the angle and try many ways to detect spin. Below is the list of solutions that I've tried:
1/ Create 2 angle traps (piece on the full round) on the full round to detect whether the angle we get from compass passed them or not.
2/ Sum all angle distance between times that the compass is updated (in updateHeading function). Let try to divide the sum angle to 360 => we could get the spin number
The problem is: when the phone is rotated too fast, the compass cannot catch up with the speed of the phone, and it returns to us the angle with latest time (not continuously as in the real rotation).
We also try to use accelerometer to detect spin. However, this way cannot work when you rotate the phone on a flat plane.
If you have any solution or experience on this issue, please help me.
Thanks so much.
The iPhone4 contains a MEMS gyrocompass, so that's the most direct route.
As you've noticed, the magnetometer has sluggish response. This can be reduced by using an anticipatory algorithm that uses the sluggishness to make an educated guess about what the current direction really is.
First, you need to determine the actual performance of the sensor. To do this, you need to rotate it at a precise rate at each of several rotational speeds, and record the compass behavior. The rotational platform should have a way to read the instantaneous position.
At slower speeds, you will see a varying degree of fixed lag. As the speed increases, the lag will grow until it approaches 180 degrees, at which point the compass will suddenly flip. At higher speeds, all you will see is flipping, though it may appear to not flip when the flips repeat at the same value. At some of these higher speeds, the compass may appear to rotate backwards, opposite to the direction of rotation.
Getting a rotational table can be a hassle, and ensuring it doesn't affect the local magnetic field (making the compass useless) is a challenge. The ideal table will be made of aluminum, and if you need to use a steel table (most common), you will need to mount the phone on a non-magnetic platform to get it as far away from the steel as possible.
A local machine shop will be a good place to start: CNC machines are easily capable of doing what is needed.
Once you get the compass performance data, you will need to build a model of the observed readings vs. the actual orientation and rotational rate. Invert the model and apply it to the readings to obtain a guess of the actual readings.
A simple algorithm implementation will be to keep a history of the readings, and keep a list of the difference between sequential readings. Since we know there is compass lag, when a difference value is non-zero, we will know the current value has some degree of inaccuracy due to lag.
The next step is to create a list of 'corrected' readings, where the know lag of the prior actual values is used to generate an updated value that is used to create an updated value that is added to the last value in the 'corrected' list, and is stored as the newest value.
When the cumulative correction (the difference between the latest values in the actual and corrected list exceed 360 degrees, that means we basically don't know where the compass is pointing. Hopefully, that point won't be reached, since most rotational motion should generally be for a fairly short duration.
However, since your goal is only to count rotations, you will be off by less than a full rotation until the accumulated error reaches a substantially higher value. I'm not sure what this value will be, since it depends on both the actual compass lag and the actual rate of rotation. But if you care only about a small number of rotations (5 or so), you should be able to obtain usable results.
You could use the velocity of the acceleration to determine how fast the phone is spinning and use that to fill in the blanks until the phone has stopped, at which point you could query the compass again.
If you're using an iPhone 4, the problem has been solved and you can use Core Motion to get rotational data.
For earlier devices, I think an interesting approach would be to try to detect wobbling as the device rotates, using UIAccelerometer on a very fine reporting interval. You might be able to get some reasonable patterns detected from the motion at right angles to the plane of rotation.

Determining speed of shake

Is it possible to determine the speed at which someone is shaking their iPhone? This would be the time they start moving to the ending point where they are now going back to the origin. Basically it is one swipe that I'd like to measure the speed of. This discussion comments on initial speed: http://discussions.apple.com/message.jspa?messageID=8297689#8297689. It seems that the important component of distance is lacking in the iPhone to get a good measure of speed.
Sure, it sounds like all you'd need to do would be to numerically integrate the acceleration twice to get the distance traveled. For instance, look at
Calculate the position of an accelerating body after a certain time
Note that you'll have to subtract gravity from the measured acceleration to get the kinetic acceleration, which is what you should integrate. As for how to do that, re: GoatRider's comment: I might try storing the last measured acceleration whose magnitude was equal to gravity (I think that's 1 in iPhone units?). Then for each acceleration measurement you make whose magnitude is greater than 1, subtract the last known acceleration of gravity - this will need to be a vector subtraction - and use that as the kinetic acceleration. Of course, this assumes that the user keeps the phone in the same orientation throughout the swipe, which I think would be approximately true.
Unfortunately, there's no technique you can use to distinguish between gravitational acceleration and kinetic acceleration in general - that is, a determined user could always find a way to fool whatever algorithm you might come up with. (Trivia: that's called the equivalence principle, and it's the foundation of Einstein's theory of general relativity)
You'll have to do the calculations yourself. Each acceleration event you receive will tell you the relative G-forces registering on the accelerometer and the time at which the event was recorded. You'll have to sample over several events and interpolate. Here's more info on the acceleration event itself:
UIAcceleration Class Reference