Measuring distance between two iOS Devices - iphone

Yeah, I'm currently wondering about this.
In my use case the devices will be 50cm to 10m apart and I'd like it to be accurate to at least 10 cm. (Therefore GPS is not an option)
2 Ways spring to mind:
Sound: I asked about this in the dev forums and I'm in contact with laanlabs, about the code of their sonar ruler.
Picture on one device + Camera on the other: Seems easier to set up, since my user case involves the user facing one device at 90 degrees anyway. But it would be more work for the user to face the camero into the direction and it would not react to a change in distance.
Now the question: Is anyone aware of any code that does something like this already? Possibly a non-iPhone general c-Project?

Method with camera: we already know size for each device. You take a picture of device, calculate it's height/width to determine type of device (iPhone/iPod or iPad), than calculate a distance.
For example - if device is iPhone you know, that its size is 115x58 mm. On picture it NxM pixels. Now you can calculate the distance. (If N & M smaller hence distance is larger)

If you were to use the sound method one approach would be to have device A emit a sound, device B would then be listening for this at all times and on detection echo back a secondary sound. This would give you a round-trip time from which you could calculate distance - don't forget to compensate for latency between detection re-emission as well.

I am not sure about but this is what i found from one of the answers in this previous SO question How to measure distance between two iphone devices using bluetooth?
Using bluetooth for localization is a very well known research field . The short answer is: you can't. Signal strength isn't a good indicator of distance between two connected bluetooth devices, because it is too much subject to environment condition (is there a person between the devices? How is the owner holding his/her device? Is there a wall? Are there any RF reflecting surfaces?). Using bluetooth you can at best obtain a distance resolution of few meters, but you can't calculate the direction, not even roughly.
You may obtain better results by using multiple bluetooth devices and triangulating the various signal strength, but even in this case it's hard to be more accurate than few meters in your estimates.

Related

Changes in accelerometer / gyroscope limitations for iPhone 5 / 5th Gen iPod Touch?

Back when the iPhone 4 and 4th Generation iPod Touch came out, I was toying around with Apple's Core Motion sensor fusion algorithms to see if I could get any interesting results for very local dead reckoning (over the range of a few inches or feet). I didn’t expect anything spectacular, given the relatively low specs of the MEMS sensors. And although Apple’s CMDeviceMotion gravity property uses a decent (though opaque) sensor fusion algorithm, the complementary userAcceleration property isn’t exactly targeted at dead reckoning. Still, I thought there might be enough there to have a bit of fun.
The iPhone 4, iPhone 5, 4th Gen iPod Touch, and 5th Gen iPod Touch all apparently use the STMicroelectronics LIS331DLH accelerometer and L3G4200D gyroscope. (Actually, I haven’t seen the part number for the iTouch-5 gyro yet, so it could be different.)
Teardowns: iPhone-4, iTouch-4, iPhone-5, iTouch-5
The ST specs show that accelerometer could sample at 1000 Hz up to ±8g. And that gyroscope could sample at 800 Hz up to ±2000 dps.
Specs: LIS331DLH, L3G4200D
But, playing with my 4th Gen iPod Touch (both iOS 5 and iOS 6), I can only crank the sampling rates up to 100 Hz. If I set CMMotionManager deviceMotionUpdateInterval any lower than 0.01, it automatically resets to 0.01. Same for accelerometerUpdateInterval and gyroUpdateInterval.
Further, the accelerometer output always seems to be capped at about ±2g.
I've seen others remark on similar bounds for the iPhone 4.
Both these bounds severely limit the local acceleration calculations I can squeeze out the device (experimenting with my 4th Generation iPod touch). I presume Apple has set these bounds low to reduce power consumption. Though I don’t know if they’re set in the hardware, or in iOS somewhere.
Has anyone played with these accelerometer and gyroscope bounds on the iPhone 5 or 5th Generation iPod Touch? (Or any iPads for that matter?) Any sampling rates higher than 100 Hz? Any accelerometer measurements outside the bounds of ±2g?
Of the reading I have done you usually have 2-3 choices when determining what min/max readings an accelerometer will read. 2G is an extremely common choice for accelerometers because the next step (8G) is usually to coarse a reading to get the fine measurements needed when working with a hand movement. If you were dropping it off a building to measure the force of hitting the ground you would want to use the 8G (or 16G as some offer).
It looks like the Hz is intentionally capped at 100Hz according to the folks at Corona Labs. It is to keep from abusing the battery apparently. I had read that the accelerometer is the least power hungry sensor but I guess it's all relative or there is a sharp increase in power use at some point around 100Hz.
I was testing techBASIC on an iPhone 5 and noticed an anomaly that led me to this discussion. Apparently the accelerometer in the iPhone 5 is set to the 8G range! While I can't find any references to confirm it, techBASIC's accelerometer demo showed this when I shook the iPhone 5 up and down:
That's pretty exciting for physics applications. I used a SensorTag to measure the acceleration in a model rocket because it has an optional 8G range, and the iPhone did not--you can now dispense with the SensorTag and just use the iPhone.
http://www.youtube.com/watch?v=8YNjwcNXOK4iPhone Rocket
To help answer the other half of your question, I am using an iPad Mini and when I use Warren Whipple's suggestion, I find that the accelerometerUpdateInterval and gyroUpdateInterval would be reset to 0.01 immediately if I set them to any lesser value.
However, when I run diagnostic tests on the device I find that the real rate at which the accelerometer or gyro data is updated is closer to 0.02 s, i.e. if I set the accelerometerUpdateInterval to 0.01 s and query accelerometer data at 0.01 s, I get a unique reading on every other fetch, but if I set it to 0.02 s (or query at 0.02 s) then I get unique reading on every fetch.

What should I do if compass lies

What should I do if the compass on two or more different devices give me different headings? I tried to calibrate the compass on devices but anyway sometimes they show me differents headings.
Since the iPhone compass "works just like a magnetic-needle compass":
The accuracy of digital compass headings can be affected by magnetic or other environmental interference, including interference caused by proximity to the magnets contained in the iPhone earbuds. The compass may need to be calibrated from time to time (Apple: iPhone and iPad: Calibrating Compass).
You have several options for fixing the compass:
Follow the directions! Move the device in a figure eight motion. However, this looks like it isn't working for you.
"[d]isregard the message to calibrate". Some areas have more magnetic interference than others, like in a car because of its dashboard. You can just leave it alone because "[t]he device will eventually recalibrate after several turns. Note that it may need to periodically recalibrate while you are driving, depending on the level of magnetic interference present."
Reboot (Not the "Slide to Power Off" reboot). Hold the power button and home button until the Apple logo appears.
I'm pretty sure those are your options. There may be more, so I'll do more research.
If you just want to see which compass is wrong, get a real compass and compare it to the headings on the two iPhones. Which ever one it matches up with, the other phone is wrong. If you don't have a real compass, you can follow this tutorial to make a homemade one (which is more fun)!
Hope this helps!
Well, if 2 iOS devices give you 2 different readings then at least one of them has uncalibrated hardware. So is this a hardware question? I don't think there is much to do in terms of the program, especially if you have no idea what the exact skew is.

iphone gps location

What is the distance between the closest gps positions?
If I have multiple devices and I want to get their locations, these devices being within a 20 meter radius, how accurate will the coordinates be?
e.g how close do players need to be before the coordinates are the same?
Thanks
When you query a location via CoreLocation, you get the accuracy in the CLLocation instances. See the horizontalAccuracy and verticalAccuracy.
The accuracy of GPS depends on a number of factors like signal quality (for example, signal quality drops if it's cloudy). Also, the iDevices differ in their GPS receiver's accuracy. I found the iPhone 4 to be more accurate than the iPhone 3G, for example (the iPhone 4 also seems to have a better antenna as I often get a signal with iPhone 4 where the iPhone 3G is having a hard time).

GPS on iPhone and Android...is there any way to get the EXACT location of the phone (not approximate)?

I know that it's mostly "approximate".
But, I must know the EXACT location of the phone, regardless of battery life or whatever.
I need the exact location of the phone! Is it possible?
It depends on what you mean by exact!
Any location technology will have a level of accuracy and much of this depends on the hardware your using. Mil spec GPS will cost a lot more than the chipset in your iPhone and use a lot more power too.
The best I've managed to get using the browser with iPhone 3GS GPS in wide open space is +/-17m
Usually its best to design you application around this for example most turn by turn sat-nav assumes you must be on a road and correct the location for this.
Uncertainty principle says no.
Define 'exact' and then we'll tell you. If it doesn't move and you've got a month, then better than a millimeter is probably possible (they track earthquake faults this way). But if it's moving, or doesn't have a good view of the sky, then it's not going to work nearly so well. And the math to do long-term averaging is pretty heavy going.
From the point of view of fundamental physics this question is meaningless. No physical measurement can ever be EXACT. There is ALWAYS a tolerance. Even if you went back to your national datum point and surveyed your position back to the point in question there will be errors in the measurements taken that will result in a non exact position.
If you then put your device on the ground - where on the device are you measuring to - the top left corner, the intersection of the diagonals across the device, the antenna position...?
"Regardless of battery life" - are you implying that the position measurement must occur in the absence of power?
Look into fine GPS location in the location API's(on Android)...that's the most "exact" you're gonna get. If you get a good GPS lock it'll probably be <10 meters. I just tested while in my house and got <5 meters.

Motion detection using iPhone

I saw at least 6 apps in AppStore that take photos when detect motion (i.e. a kind of Spy stuff). Does anybody know what is a general way to do such thing using iPhone SDK?
I guess their apps take photos each X seconds and compare current image with previous to determine if there any difference (read "motion"). Any better ideas?
Thank you!
You could probably also use the microphone to detect noise. That's actually how many security system motion detectors work - but they listen in on ultrasonic sound waves. The success of this greatly depends on the iPhone's mic sensitivity and what sort of API access you have to the signal. If the mic's not sensitive enough, listening for regular human-hearing-range noise might be good enough for your needs (although this isn't "true" motion-detection).
As for images - look into using some sort of string-edit-distance algorithm, but for images. Something that takes a picture every X amount of time, and compares it to the previous image taken. If the images are too different (edit distance too big), then the alarm sounds. This will account for slow changes in daylight, and will probably work better than taking a single reference image at the beginning of the surveillance period and then comparing all other images to that.
If you combine these two methods (image and sound), it may get you what you need.
You could have the phone detect light changes meaning using the sensor at the top front of the phone. I just don't know how you would access that part of the phone
I think you've about got it figured out- the phone probably keeps images where the delta between image B and image A is over some predefined threshold.
You'd have to find an image library written in Objective-C in order to do the analysis.
I have this application. I wrote a library for Delphi 10 years ago but the analysis is the same.
The point is to make a matrix from whole the screen, e.g. 25x25, and then make an average color for each cell. After that, compare the R,G,B,H,S,V of average color from one picture to another and, if the difference is more than set, you have motion.
In my application I use fragment shader to show motion in real time. Any question, feel free to ask ;)