views:

617

answers:

3

I'm working on locating an iPhone device in 3D space.

I can use lat/long to detect physical location, I can use the magnetometer to figure out the direction they're facing, and I might be able to use the accelerometer to figure out how their device is oriented, but I can't figure out a way to get height of the device off the floor.

Specifically, I need to know if the user is squatting down, or raising their hand toward the ceiling (a different of about 2 meters/6 feet).

I posted a more detailed description of what I'm trying to do on my blog: http://pushplay.net/blog_detail.php?id=36

I would love any suggestions as to how to even fake this sort of info. I really want the sort of interactivity and movement that would require ducking and bobbing, versus just letting someone sit back and angle the phone -- kind of the way people can "cheat" playing with a Wii...

+6  A: 

The closest I could see you getting to what you're looking for is using the accelerometer/magnetometer as an inertial tracker. You'd have to calibrate the user's initial position on startup to a "base" position, then continuously sample the sensors on a background thread to build a movement model. This post talks about boosting the default sample rate of the accelerometer functions so that you can get a pretty fine-grained picture of the user's movements.

I'm not sure this will solve your concern about people simply angling the device to produce the desired action, but you will have to strike a balance between being too strict in interpreting movements and allowing for differences in movement

Josh E
That's where I'm leaning right now, unless I can find a better (okay, okay, easier) solution... :-) I also wasn't sure if this would conflict with how I was going to be measuring the angle of the phone...lot of variables to keep track of!
Jeffrey Berthiaume
ha ha yeah I hear ya. It shouldn't conflict with your angle measurements since you're measuring (delta)x, (delta)y, and (delta)z to build your movement map. For example, if the user needs to draw an analemma (infinity sign), the map is built from comparing points sampled over time to a logical "starting" point and time.
Josh E
A: 

I am not intimately familiar with the iphone. But it might require a hardware add-on. (which you probably don't want to do). After thinking on this the only way I know how is through light or more specific laser. You shoot out a laser on the floor and record the time it takes to get back. It's actually not a lot to put this hardware together and I am sure the iphone has connections for peripherals. Unless osmeone can trump me, I say ther eis no way to do that with an image.

Jonathan Kaufman
+1  A: 

The CoreLocation stuff gives you elevation aswell as lat/long, so you could potentially use that although there are some significant problems with this:

  • Won't work well indoors (not a problem for Sat Nav, is a problem for games)
  • Your users would have to "calibrate" (probably by placing the phone on the floor) each location they use!
  • In fact, you'd need to start keeping a list of "previously calibrated locations"... which could vary hugely just in one house (eg multiple rooms and floors). Could get in the way of the game.
  • Can't be used on moving transport (tranes, planes, automobiles... even walking) because elevation changing so frequently.

Therefore I'd have thought that using the accelerometer as a proxy for height is a substantially more preferable route than determining absolute elevation.

h4xxr