Android Question calculate speed?

Peter Simpson

Expert
Licensed User
PMSL :p
What do you care? Then it will be broken! :D
I once read this ;)
You need to integrate acceleration to get the velocity.
v(t)=∫tt=0a.dt

There are a number of ways of doing this numerically.
I assume that you get these readings regularly with a spacing of δt, for example δt=100ms or something like that.

About the simplest way to do it is
v(t)=v(0)+∑a×δt

Where v(t) is the velocity at time t. but there are more sophisticated ways of doing it.

The problem is complicated by velocity being three dimensional - so you need to integrate in each of the three dimensions x, y and z separated. It depends how the phone gives you the information about the acceleration, but if you get ax, ay and azat regular intervals then you can do the following.

vx += ax * dt;
vy += ay * dt;
vz += az * dt;

If you get accleration as a raw number and angle then you will have to convert from I guess polar coordinates to xyz components to be able to add them up.

Total speed, |v| is, of course, given by |v|=√vx+vy+vz.
 

ilan

Expert
Licensed User
PMSL :p


I once read this ;)
You need to integrate acceleration to get the velocity.
v(t)=∫tt=0a.dt

There are a number of ways of doing this numerically.
I assume that you get these readings regularly with a spacing of δt, for example δt=100ms or something like that.

About the simplest way to do it is
v(t)=v(0)+∑a×δt

Where v(t) is the velocity at time t. but there are more sophisticated ways of doing it.

The problem is complicated by velocity being three dimensional - so you need to integrate in each of the three dimensions x, y and z separated. It depends how the phone gives you the information about the acceleration, but if you get ax, ay and azat regular intervals then you can do the following.

vx += ax * dt;
vy += ay * dt;
vz += az * dt;

If you get accleration as a raw number and angle then you will have to convert from I guess polar coordinates to xyz components to be able to add them up.

Total speed, |v| is, of course, given by |v|=√vx+vy+vz.

不理解的事 :confused:

I understand that you know what you are talking about but can you explain again for a moron like me in simple English please

maybe start with the simplest way (I get the x,y,z) how do I get the velocity from them? and detect a hit on the ground, what I have done until now I calculate sqrt(x*x + y*y + z*z) and I check always the last and the new result if the difference is more then x I start alarm

that works for me but sometimes a shake will do it to (only sometimes) and I want to avoid that
 

derez

Expert
Licensed User
Klaus wrote:
Try to detect the accelerometer.
A choc will give much higher values than the shaking.
You'll need a few tests to determine the optimum threshold.
He is write. You should check the accelerometers. Usually one of them shows the inertial acceleration ( 1g which is 9.8 m/sec^2), the others show about 0, or a mix according to the phone position.
To not need to consider the position of the phone you can calculate the vector acceleration size sqrt(x^2+y^2+z^2).
Now when the phone starts falling this value should go to around zero and when the phone halts on the ground it will either show 1g again or not show anything...
So you need to prepare several phones before starting the tests.
 

ilan

Expert
Licensed User
thanx derex values(2) is the inertial acceleration that means the z axis is 9.8 when the phone is not moving

so what i need to check is calculate sqrt(x^2+y^2+z^2) of all axis that will give me about 0 when there was no shake and after a hit on the ground i need to ask for the last z value if it was 9.8 like this i can know that there was a free fall before the hit and start the alarm. thank you derez (and klaus and all other here) i think i got it now
 

derez

Expert
Licensed User
so what i need to check is calculate sqrt(x^2+y^2+z^2) of all axis that will give me about 0 when there was no shake and after a hit on the ground i need to ask for the last z value if it was 9.8 like this i can know that there was a free fall before the hit and start the alarm
You have got it wrong...
The total acceleration while the phone is not moving is 9.8, which is calculated by sqrt(values(0)^2+values(1)^2+values(2)^2)
When the phone falls it senses acceleration 0. When it hit the acceleration should grow again to 9.8 .
 

wonder

Expert
Licensed User
Well... you drop it on a mattress. If you're feeling lucky, drop it on a yoga mat. Any fall into hard surface above ~1,20 m will most likely damage your phone.

(...or just go skydiving with the phone in your pocket!)
 

ilan

Expert
Licensed User
the idea is not drop your phone is to fall with your phone ;)

let say old person has a phone in his pocket, he fall down and cannot move anymore, phone detect he fell down now start alarm if alarm is not shut off in 5 sec by the old person he send sms "i need help" to contacts that he entered before .... (bla bla bla)
 

DonManfred

Expert
Licensed User
let say old person
i dont know but maybe you should get any values cause the phone already work.

But maybe the "speed" can be irritating as it can be "slow" in some situations. starting hurting in breast (heart)... The person starting to bend down and in the last instance he then fell down. It is not a long way. and the speed may be really slow.

PS: I´ve already had multiple strokes as yet (5)
 

wonder

Expert
Licensed User
Try this app:
Accelerometer Monitor: https://play.google.com/store/apps/details?id=com.lul.accelerometer&hl=en

If I recall, it will save your accelerometer data into a csv text file.
Put the phone in your pocket, and record your falls. Take your time to analyze the generated data and see how could you play with such values.
I think this would be a good starting point before engaging in this new project of yours.
 

ilan

Expert
Licensed User
i dont know but maybe you should get any values cause the phone already work.

But maybe the "speed" can be irritating as it can be "slow" in some situations. starting hurting in breast (heart)... The person starting to bend down and in the last instance he then fell down. It is not a long way. and the speed may be really slow.

PS: I´ve already had multiple strokes as yet (5)
it must not be only on a heart attack, it could be whyle riding a bike, jogging..
 
Top