Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Detect Device Movement (Input) Bouncing/Shaking AGK Tier 1

Author
Message
BuccaneerBob
AGK Developer
14
Years of Service
User Offline
Joined: 18th Aug 2010
Location: Canada
Posted: 1st Jun 2015 06:12
Evenin' fellow AppGameKit Developers!

I have a Tier 1 Question for you all and it may be beyond the scope of what AppGameKit Tier 1 can handle.

I'm looking to detect a 'bounce' of a physical device, for example, a pedometer to track users steps.

I don't think it's something the accelerometer can handle, as it's not dependant on the rotation of the device. Thoughts?

Robert Janes (Samu Games)
http://www.samugames.com/artifact
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Jun 2015 11:13
Unless there's a document out there already, you might have to gather some data and do some experimenting. You have all the sensors that everybody else has that is making apps like this.

I imagine it involves gathering data about the orientation (GetOrientation), the position (GetRawRotationVector*), and Acceleration (GetRawAccel*). You might even be able to fine tune it with the gyro (GetRawGyroVelocity*) if you were measuring a moving body part, such as a thigh or upper arm.

On a very simplistic level I suppose you might get away with the pendulum-like readings from acceleration as you walk. But you'd still need some reference data to work out what the limits are on the readings for the kind of activity you are measuring.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 1st Jun 2015 11:28
Here's my really poor attempt at some sensor-fusion control. It doesn't do what I intended (yet), but it does show you how to monitor sensors and use the data to display an oscilloscope. All you would need to do to create a pedometer is analyse the graph data for peak changes that would signify a bounce, or step. You could set a predetermined sensitivity, or you could get creative and make the sensitivity dynamic, adjusting automatically to the level of motion being experienced.

If I remember correctly, the Android NDK does have some built in step sensing functions, but they are not (yet) exposed in AGK.

Anyway, here's the code - it's ugly and doesn't do what it was intended to do, but should give you an idea on how to move forward with your own code.



V2 T1 (Mostly)
Uzmadesign
BuccaneerBob
AGK Developer
14
Years of Service
User Offline
Joined: 18th Aug 2010
Location: Canada
Posted: 4th Jun 2015 21:55
So I've managed to detect steps after fine tuning specific Accelerometer readings, and it's working as desired right now, however one flaw I've realized is that the app will not count steps when it's pushed to the background. I've been scouring the documentation to see if there's a way to work around this, I've come across things like GetResumed() but that's only effective when the app comes to the foreground. Anyone know if there's a way to keep the application processing in the background or while the device's display is turned off?

Robert Janes (Samu Games)
http://www.samugames.com/artifact

Login to post a reply

Server time is: 2024-11-25 22:34:31
Your offset time is: 2024-11-25 22:34:31