Note that there are some explanatory texts on larger screens.

plurals
  1. PODetect programmatically if iPhone is dropped using CoreMotion/Accelerometer
    primarykey
    data
    text
    <p>So I am writing a piece of code where I have to detect different movement gestures using Accelerometer and gyroscope in iOS 4.3 above.</p> <p><strong>Q1:</strong> Is there any existing opensource code which has achieved any movement/gesture detection?</p> <p>If not</p> <p><strong>Q2: For now I want to detect if the iPhone is dropped.</strong></p> <p><strong>What I have achieved so far:</strong> CoreMotion API gives <strong>userAcceleration</strong>, which (afaik) is <em>the acceleration that the user is giving to the device or the acceleration of device in some direction (x, y or z) with out considering the gravity</em> so what I can do is: store, let's say, previous 5-6 values of acceleration parameters and can check where any of them hits large negative value, which basically represents the sudden deceleration.</p> <p>But this solution is not very optimal, I think I need to somehow detect the freefall/downwards motion of the device too first. Any idea how to approach this problem?</p> <p><strong>UPDATE:</strong> Thanks Misch for sharing your approach. I was not at all thinking about total acceleration. I did exactly what you said:</p> <blockquote> <p>"You would however have to test yourself, what means "total acceleration corresponds approximately to earth acceleration" and "for some time" in your case."</p> </blockquote> <p>The acceleration value is actually in G's so I tested the "total acceleration" values with in range of 0.9 - 1.1. And I checked them over some time, initially I checked four consecutive values when updateInterval is set to 1/20.0. For now I have relaxed the condition of consecutiveness a little. </p> <p>Here's a sample output:</p> <p>Acceleration = 0.090868<br> Acceleration = 0.074473<br> Acceleration = 0.159797<br> Acceleration = 1.157513<br> Acceleration = 1.224588<br> <strong>Acceleration = 1.036272</strong><br> <strong>Acceleration = 0.914698</strong><br> <strong>Acceleration = 0.904093</strong><br> <strong>Acceleration = 0.941516</strong><br> Acceleration = 0.046362<br> Acceleration = 0.045109<br> Acceleration = 0.060045</p> <p>I think, I still have to keep on testing and adjusting values. If you have any optimization in mind kindly do share, I know in order to help you'd need to see the many samples of freefall acceleration values. For now I am thinking to:</p> <ol> <li>round off the values of acceleration to 3 decimal places and play with the acceleration range I am using.</li> <li>May be check if, after the freefall condition is met, total acceleration value suddenly goes down.</li> <li>Do you think the acceleration values I have quoted are a bit noisy? </li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload