0

My goal is to have a simple stroke rate detector displayed on my Android Watch (Sony Smartwatch), for this I need to detect when the watch changes from moving forwards to moving backwards.

I have code working that will get the event values (x,y,z) as detected in the onSensorChanged event (and display them on the watch), but I am struggling to make sense of these.

I understand the values report acceleration in the given axis, and I understand that z reports gravity. But if these values are reporting just acceleration, I am not clear how to know when there is a change of direction. I presume a positive number indicates acceleration, a number of 0 is a constant speed and a negative number is deceleration...is that correct? And if so, how can I detect when the Watch has changed direction from going forwards to going backwards?

Thanks in advance.

1 Answers1

0

Android Wear is no different than "conventional" Android when it comes to detecting motion. Basically, you need to consider exactly what the accelerometers are recording: raw acceleration (with a lot of noise). To determine motion from that, you need to look at trends over time, and probably integrate the smoothed accelerometer data. It's not trivial.

You'll probably want to use the TYPE_LINEAR_ACCELERATION sensor, because it filters out gravity (which isn't relevant to your use case). And because the watch will probably experience some rotation during a rowing stroke (which you want to factor out), you may need to combine TYPE_ROTATION_VECTOR with the acceleration vector to accurately determine direction changes.

A couple of other SO questions which may help point you in the right direction:

I've not attempted this specific problem, of course, but I've done enough other work with Android motion sensors to know that you have a good programming challenge ahead of you. Enjoy it!

Community
  • 1
  • 1
Sterling
  • 6,365
  • 2
  • 32
  • 40