Android Question calculate speed?

Discussion in 'Android Questions' started by ilan, May 21, 2015.

  1. ilan

    ilan Expert Licensed User

    If i drop my phone can i calculate the speed of the fall until my phone hits the ground? With the motion sensor type_acclerometer
     
    ural likes this.
  2. LucaMs

    LucaMs Expert Licensed User

    What do you care? Then it will be broken! :D

    (I think you can not know the start position - distance from ground - of your phone)
     
  3. ilan

    ilan Expert Licensed User

    But can i detect a drop after a free fall? And not a shake event. This is what i need to detect a drop of the phone and start alarm but on shaking not
     
  4. LucaMs

    LucaMs Expert Licensed User

    The only method, I think, would be the GPS, if it had a precision of cm, but it has accuracy of tens of meters.
     
  5. klaus

    klaus Expert Licensed User

    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.
     
  6. Peter Simpson

    Peter Simpson 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.
     
    thedesolatesoul likes this.
  7. ilan

    ilan Expert Licensed User


    不理解的事 :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
     
  8. derez

    derez Expert Licensed User

    Klaus wrote:
    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.
     
    thedesolatesoul likes this.
  9. ilan

    ilan Expert Licensed User

    thank you derez, but can you tell me how i get inertial acceleration (value 9.8 m/sec?)
     
  10. derez

    derez Expert Licensed User

    thedesolatesoul likes this.
  11. ilan

    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
     
  12. derez

    derez Expert Licensed User

    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 .
     
    thedesolatesoul likes this.
  13. DonManfred

    DonManfred Expert Licensed User

    After the free fall the device is damaged and most probably dont work anymore. I dont think you can read any parameters now :D
    But to calculate the speed you just need to use google

    Here:

    [​IMG]

    :D
     
  14. wonder

    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!)
     
  15. ilan

    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)
     
  16. DonManfred

    DonManfred 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)
     
  17. wonder

    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.
     
  18. ilan

    ilan Expert Licensed User

    it must not be only on a heart attack, it could be whyle riding a bike, jogging..
     
  19. DonManfred

    DonManfred Expert Licensed User

    Yes. Sure.
    I just wanted to explain that there are situations where you will get "no (or a minimal) acceleration". too less to "start an Alert"
     
  20. ilan

    ilan Expert Licensed User

    yes, thats correct.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice