Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect height of iPhone (for use in augmented reality game)?

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...

like image 501
Jeffrey Berthiaume Avatar asked Sep 04 '09 16:09

Jeffrey Berthiaume


2 Answers

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

like image 183
Josh E Avatar answered Nov 12 '22 04:11

Josh E


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.

like image 23
h4xxr Avatar answered Nov 12 '22 05:11

h4xxr