GNSS Series — Part 1 of 3 · All parts · Next: Chronicle 2: what would it be?

Chronicle 1: How Does a Phone Know Where It Is? 

Positioning basics, coordinate frames, distances, and clock bias


This GNSS journey starts with a real journey, one of our Christmas trips when we drove from the Netherlands to Italy. While planning the routes and stops our engineer curiosity kicked in. How does our phone know where we are? Why is the location on Android sometimes different from the one from iPhone? 

Yes, we’re a perfect Android-iPhone team…if by perfect you mean we each think the other made the wrong choice. 🙂

That was enough to get our engineering brains buzzing. Could we turn a 12-hour drive into a GNSS experiment? …Of course we could. 

So let’s start with the big question: how does our phone know where we are? 

The answer lies in something you might already know, GPS. But GPS is just one member of a much bigger family called GNSS, or Global Navigation Satellite System. GNSS includes several systems developed by different countries, the main ones being GPS (USA), Galileo (Europe), Glonass (Russia), BeiDou (China) and Navic (India). Most GNSS satellites orbit in Medium Earth Orbit (MEO), about 20 000 km above us, circling the Earth in 12 to 14 hours. 

In contrast, Low Earth Orbit (LEO) satellites move much faster, which means you need a much denser constellation to maintain coverage, since each satellite is visible for only a short time. Another type of satellites are Geostationary Earth orbit satellites, that are much farther away from Earth. These satellites circle above the Equator at a speed that matches the Earth’s rotation, so from the ground they appear to stay in the same spot. 

With this in mind, we started looking into what we could do for our trip and see whether we could set up a GNSS experiment. Our available lab? Two Android phones and one iPhone. Each phone computes the position internally and uses it to “guide” us. But could we get more than just the position? Could we actually play with the measurements?

Time to put our curiosity to the test. But there was a small problem: Unfortunately, iPhones restrict access to raw GNSS data. Instead, you only get the processed position (we will learn the differences soon). Android, on the other hand, gives access to all the measurements. To start logging them, all you need is an app like GNSSLogger App. You can find more details about this app and the measurements it can record on the Android developer site.

So we installed it, grabbed a phone stabilizer, basically a holder to keep the phone steady, and declared our mobile lab ready for action. For a more professional setup, we would recommend fixing it to the window or have a more solid holder, but for a first experiment, this would do just fine.

We planned the route using Google Maps as navigator and tried to stay as much as possible on the suggested route.

During our trip, we logged several tracks, pausing the recording whenever we made a stop. 

Tip: If you want to upload the file to e.g. Google Drive, you might need internet access. In our case, as we crossed several countries switching providers, we sometimes had issues with the connection and the file uploading.

Visualizing the results

Once we arrived at our destination, and after a well-earned rest, we finally dove into our datasets to see what we had captured. 

For the analysis, we used GNSS Analysis. This app works directly with the logs from GNSSLogger and provides positioning results; it processes the raw measurements and provides the position points (and some additional parameters). You can learn more about the app and download it for Linux, Windows, or macOS from here.

Now it was time to see what data we collected. Can we use it to trace our path?  We noticed some strange things along the way and we were curious to see what the data was going to reveal us.

We can keep it simple for now, without getting (yet) into details of how the position is computed. GNSS Analysis loads the file, computes the position, and outputs not only measurements but also the calculated position. A nice feature of GNSS Analysis is that it also outputs KML files, which can be easily importable into Google Earth. These KML files contain the positions calculated by the app.

What we did was use Google Earth to look at two things: 1) the route suggested by Google Maps, and 2) the route computed by the phone, as stored in the KML file. In the screenshot below from Google Earth, the green line shows the Google Maps route, and the blue line shows the actual locations computed with the measurements from the phone. Picture 1 shows a pretty good match. But picture 2? … we definitely did not drive across that field, we stayed on the highway!

To understand what happened, we need to dig into how our position is calculated and how GNSS works.

Understanding GNSS

As mentioned above, all the systems rely on a constellation of satellites that are orbiting in MEO. Why MEO? It is a trade-off: the higher we go, the fewer satellites we need for global coverage, but go too high and the signals get weaker.   

At its core, GNSS positioning uses trilateration, similar to triangulation, but based on distances and extended into 3D.

To figure out our position, GNSS needs a coordinate frame, basically a 3D map where every point has unique coordinates. Once we have that frame, and each point has its coordinates, it all comes down to geometry. In 2D, the distance between two points in Euclidean space:

A graph of a line

AI-generated content may be incorrect.

d=\sqrt{\smash[b]{(a_1 - b_1)^2 +(a_2-b_2)^2 }}

In GNSS, we work in 3D, so we need to add one more term:

d=\sqrt{\smash[b]{(a_1 - b_1)^2 +(a_2-b_2)^2 +(a_3-b_3)^2}}

Now, given that we know where the satellites are, we can estimate the distance to them and determine our own position within a 3D coordinate system. We do this by solving the system of three equations:

Distances users to satellite

d_1=\sqrt{\smash[b]{(x - x_1)^2 +(y-y_1)^2 +(z-z_1)^2}} \\ \\
\\
d_2=\sqrt{\smash[b]{(x - x_2)^2 +(y-y_2)^2 +(z-z_2)^2}} \\ \\
\\
d_3=\sqrt{\smash[b]{(x - x_3)^2 +(y-y_3)^2 +(z-z_3)^2}}\\

Simple in theory… but the challenge is getting the coordinates and time with very high accuracy.

🧪 Curiosity Challenge


What you need



Steps

  • Install GNSS Logger and enable Raw Measurements.
  • Start a drive on a known route.
  • Save the log file (.txt).
  • Convert to .KML with GNSS Analysis.
  • Open the .KML in Google Earth to visualize.
  • Add the path generate by Google Earth.
  • Check if you observe path deviations or sudden detours.