Download!Download Point responsive WP Theme for FREE!

How GPS Works (I Think)

One thing for which you may thank the nuclear arms race is GPS. Did you know that? Nuclear missiles to get the ball rolling, then later the Russians, who shot down a Korean passenger jet for joyriding into their airspace (oops), which prompted Ronald Reagan to make GPS available to civilians. Not republican or Russian? I got you covered bro, Bill Clinton ordered that the mechanism that degraded GPS accuracy for civilians be disabled, the first GPS optimization hack.

As you can already tell I just spent some time on Wikipedia, plowing through the entire fifty-paged article on GPS plus a dozen other articles along the way, which is for most people tl;dr, so let me try to dumb it way down for you in case you’re fascinated by how your phone is able to figure out where you are by listening closely to outer space and thinking really hard about timing (I’ll save time for another article, it’s actually pretty complicated if you think about it). This is just to give you the gist of it and note that I don’t really know what I’m talking about, I’m not a physicist, engineer or mathematician, I’m just a guy who’s into phones reading wikipedia to you out loud and sort of summarizing with a little of my signature panache sprinkled on, want to get you thinking. If something within this grabs your attention and you want to know what it is rather than my interpretation of what it might be, look it up on wikipedia (ephemeris, general relativity and trilateration for example). This is just for those of you who sort of wonder what the hell that lock is all about. Here we go buddy:

There are a bunch of satellites cruising around earth continuously firing down chunks of information. The chunk  includes the timestamp stamped by the satellite noting the very exact time the chunk was fired, the position of the satellite at that time and the satellite’s opinion on the orbits and positions of the other GPS satellites at that time.

Now your phone’s GPS receiver listens to these chunks flying down from all these satellites and, using what it knows to be the speed of light (the chunks’ velocity) and the current time to calculate the distance between itself and each one of those satellites, and with trilateration, it compares those distances and the positions of the satellites to reveal its own location by imagining spheres surrounding each satellite and overlapping each sphere at its determined distance from the satellite nucleus and wherever all of those spheres intersect (the more satellites and spheres the merrier), once your phone figures that out, voila, it has its position and can tell you all about it, all based on its position relative to each satellite relative to their positions over the earth.

Since we’re dealing with the real world which most consider to be three dimensional, you’d think three satellites would be enough to figure out the location. But the time, since we’re dealing with the speed of light and varying altitudes of GPS receivers, has to be super exact. For example, in order to produce its position within a thousand foot degree of accuracy, it has to nail the time right down to the microsecond (0.000001s) which it can do with less battery power using cell towers instead of satellites. So how does your phone know what time it is?

Once a fourth chunk-flinging satellite is in the mix, for a reason I cannot really dumb down any better than this, that’s enough satellites (and their overlapping, mutually-intersecting spheres, one of the two points of intersection being your phone) your phone needs to overhear arguing about what time it is in order to determine what time it really is down to ten nanoseconds, which is second only to the atomic clock in terms of our means to tell time.

And it is at that point that your phone gets its “lock.”

If this picture is funny to you, then you’re getting the gist of it (or already had the gist but read anyway):

To aid the identification of the point of intersection and to preserve that identification over time and change of distance between you and each individual satellite and their own change in distances relative to everything, and this is called GPS augmentation, if the GPS receiver already has a vague idea of its altitude, either because it’s a ship (and therefore at sea level) or because it’s getting tips by a barometer, that accelerates this process, which is why they put a barometer in some mobile devices including the Galaxy Nexus. A barometer is an instrument that measures atmospheric pressure. Though atmospheric pressure at a given altitude could be a lot stronger or weaker depending on entropy and the weather and whatever else, it does provide enough extra information to make a significant improvement in determining, and being able to continue determining, the time and location. You’ll probably have a barometer in your phone, like me, maybe a couple more phones down the line depending on how high a roller you are.

Other clues your phone has that help get these spheres lined up include cellular tower trilateration, same principles in play as with the satellites except with cell towers. The phone knows the position of the towers and the time they shoot their chunks. Because they are much much closer (I’m totally guessing here) to you than satellites in medium earth orbit, it takes a ridiculously extremely precise measurement of time on the towers and the phone in order to yield 500m accuracy.

What gives your phone a much better edge in determining its rough (say, 20m) location without the aid of the speed of light and spacetime is by being on the lookout for things whose location it can look up because companies like Google drove cars and flew cool airplanes around the world listening for home wifi access points, short-range and unique in what they are constantly transmitting. So Google already knows where the access point named “Newt’s not so bad I suppose” (my current one, I like to have fun with the names), and when your phone comes within range of my network, it asks Google where it is, Google says where it is, baddabing the phone knows where it is down to a practical level of accuracy for many applications without having to think that hard at all. And the less hard it thinks, the less battery juice it chugs. This helps your phone know its rough location all the time, and when you need to know your location down to a level of accuracy needed to know when to exit an actual superhighway, the information wifi location yields, plus the barometer if you’ve got one, gives your GPS receiver a big head start in getting a lock.

That is why collecting those wifi locations with the controversial Street View cars has been so damn valuable.

What about those satellites? Okay I’m going to do something that to my knowledge (probably because I use adblock) has never ever been done on MobilityDigest, I’m going to use an animated gif. Here’s what they sort of look like relative to the earth to try to help you conceptualize this:

Cool, right? My apologies if your little Windows Phone with its single core can’t handle the animated gif. 🙂

What about when you drive through a tunnel, how does your GPS device seem to sort of know where you are even though it can’t hear any satellites or goofily-named wifi access points? You Grateful Deadheads will appreciate this one (it’s my favorite Dead album), by means of dead reckoning. That’s when your phone takes its last known position relative to the previously-last known position to calculate speed and trajectory, then it just assumes (dead) that you’re still moving like that while in the tunnel, which you sort of are give or take most of the time. In addition to being able to offer you a vague location within the tunnel, it serves as yet another clue to figure out that spherical intersection once you exit the tunnel.

Another thing, mixed in with dead reckoning, that could theoretically help your phone navigate is your phone’s G-sensor, or its accelerometer, and either a compass, gyroscope or both which could provide what’s called an inertial navigation system that does not rely on anything other than sensing the change in speed and direction. That can be helpful to the military so that they are not reliant on being able to hear those satellites in enemy territory to determine their location, submarines, aircraft, missiles, subway cars, important things that aren’t bouncing up and down in your pocket all the time that need a redundant mechanism of navigation.

But keeping track of angular velocity at inertial reference frames all the time to yield an accurate relative location is just too damn hard for a phone flopping around, just like it is for you when you get kidnapped, blindfolded, tossed in a trunk and driven to a cave someplace (I hate that). A solid INS onboard, say, a sturdy big oil tanker gets confused by almost a mile and a degree per hour its orientation. So a phone INS, forget about it. German WWII rockets yes, a phone no. On the other hand, our phones do have these accelerometers for some reason, so I guess I’d call it a poor man’s INS as whatever it yields must be the most inaccurate of navigational clues.

I know from writing pseudo-academic articles before that some of you reading this are very super smart, so those among you who fall under that category, also to you decent bullshitters, maybe fill in some of the blanks I left related to navigation and correct all the crap I got wrong. Or hey, why don’t you just spin some total nonsense that sounds right but is completely false, see if you can fool everybody. It’s Saturday, what else are you gonna do. Now what the hell am I gonna use as my article picture…

Doug Simmons

13 Comments