Question

What would be the best way tell the user is shaking the Sphero?

I need to differentiate when the user tilts the Sphero left/right/up/down and when they shake it rapidly a few times in any direction.

Is there a sample project that would be good to look at?

Was it helpful?

Solution

If you're collecting the accelerometer filtered values, and also the "IMU" values, the accelerometer values would be best for detecting shaking, while the IMU values (roll, pitch, yaw) are best for detecting tilt.

If you don't care on which axis it is shaken, then normalize the axis' by getting a square of the sum of their squares: sqrt(x^2 + y^2 + z^2) > 2000. This will give you a magnitude of the acceleration vector. It's a good value for "general acceleration-ness", and it's great for detecting shaking.

If you want to isolate on which axis it is being shaken, then for each axis, evaluate whether its absolute value of acceleration is above a threshold: abs(x) > 2000, since the positive or negative value of an axis is its own vector magnitude.

Then, just use the IMU data's roll, pitch and yaw values to determine the tilt of the Sphero.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top