1

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?

Slomojamma
  • 95
  • 7

1 Answers1

2

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.

ColdSnickersBar
  • 297
  • 1
  • 5
  • Also, if you want to evaluate if it's shaken a number of times, simply evaluate whether these values go above this value, and then below another value a number of times. – ColdSnickersBar Apr 26 '13 at 15:33
  • Thanks! That was a lot easier then the way I was trying. I ended up using `sqrt(x^2 + y^2 + z^2) > 2` to detect a normal shake. Trying to get 2000 and my arm almost fell off – Slomojamma Apr 28 '13 at 02:11