30% off your first 3 months

Get the deal

How GPS works and why robots need more than GPS

by DuckyHelperNov 12, 20264 min read
Robotics

TL;DR:

  • A GPS receiver measures its distance to several satellites and finds the one point that fits all of them.

  • Four satellites are needed because the receiver's own clock is also unknown.

  • Indoors, in canyons and between tall buildings, the signal is blocked or bounced, so robots add other sensors.

Your phone knows where you are to within a few meters, using nothing but radio signals from satellites. A robot that drives itself outdoors can use the same trick. It works through one idea: if you know how far you are from several known points, there is only one place you can be.

Distance from time

Each GPS satellite broadcasts its position and the time the signal was sent. Radio waves travel at the speed of light, about 299,792 km/s. The receiver notes when the signal arrives. The delay tells it the distance: distance = speed of light × travel time.

The satellites orbit about 20,200 km above the Earth. For a satellite straight overhead, the signal takes about 20,200 ÷ 299,792 ≈ 0.067 s, or 67 ms. So the timing needs to be extremely precise: light travels about 0.3 m in one nanosecond.

Worked example: position from four satellites

Start with a two-dimensional version so that you can do the sums by hand. Three beacons are at known points (0, 0), (10, 0) and (0, 10). You measure distances of 5, √65 ≈ 8.062 and √45 ≈ 6.708 to them.

  1. From the first beacon: x² + y² = 25.

  2. From the second: (x − 10)² + y² = 65. Expand: x² − 20x + 100 + y² = 65.

  3. Subtract the first equation: −20x + 100 = 40, so x = 3.

  4. Put back into the first: 9 + y² = 25, so y = 4 (taking the positive solution).

  5. Check with the third beacon: 3² + (4 − 10)² = 9 + 36 = 45. Distance √45 matches.

The position is (3, 4). Each distance alone gives a circle of possible positions. Two circles meet at two points, and the third circle picks the right one. This idea is trilateration.

In three dimensions each distance gives a sphere, so you need three satellites to find a point. In practice GPS uses at least four, for a reason that comes from timing.

Why the fourth satellite

The satellites have atomic clocks. Your receiver has a cheap clock that is off by a tiny, unknown amount. A clock error of just 1 microsecond is a distance error of about 299,792,458 m/s × 0.000001 s ≈ 300 m. So the receiver has four unknowns: its position x, y, z and its clock error. Four satellites give four equations, which determine all four unknowns. The clock error drops out as a by-product, and the receiver gets an accurate time as well as a position.

How accurate is it

In open sky, a typical consumer receiver is accurate to a few meters, though it varies with the receiver, satellites in view and conditions. The main sources of error are:

  • Atmosphere. The signal slows slightly as it passes through the ionosphere and troposphere.

  • Clock and orbit errors. Small errors in the satellite data.

  • Satellite geometry. If the visible satellites are bunched in one part of the sky, the position is less certain.

  • Multipath. The signal bounces off buildings and arrives late, so the distance looks longer.

Some systems correct for these using extra reference stations or a second frequency, and can reach much better accuracy, but they cost more and need set-up.

Why robots need more than GPS

  • Indoors. The signals are weak and mostly blocked by roofs and walls, so GPS often fails altogether inside.

  • Urban canyons. Between tall buildings, the sky is partly hidden and reflections cause large errors.

  • Under trees or bridges. Leaves and structures weaken the signal.

  • Slow updates. A typical receiver gives a few updates per second, which is too slow for fast control.

  • Not enough accuracy. A few meters is fine for driving directions, but a robot lawnmower or a delivery robot needs to stay on a path or avoid a kerb, which takes much finer control.

GPS also says nothing about what is around the robot. It does not know where the people, curbs or walls are. For that, the robot needs cameras, LiDAR or other sensors.

How robots combine sensors

A typical outdoor robot fuses GPS with wheel encoders, an IMU and sometimes cameras or LiDAR. The encoders and IMU fill the gaps between GPS fixes and during brief signal loss. GPS in turn removes the slow drift that builds up in the encoders and IMU. The result is better than any one sensor alone, which is the same idea as in the article on gyroscope drift.

Note: This article describes the general principle of satellite navigation. Different systems differ in detail, and exact accuracy depends on the receiver and conditions, so check the data sheet of your own module.

Common mistakes

  • Trusting a position fix with few satellites and a poor sky view.

  • Testing near a building and assuming the results apply in an open field.

  • Confusing latitude and longitude order in code.

  • Using GPS speed as a replacement for wheel speed at low speeds.

Your plan for this week

If you have a GPS module, log its position outdoors for ten minutes while it sits still, and then repeat next to a tall building. Note how far the positions wander. If you want to redo the trilateration example with a different set of beacon distances, DuckyHelper can work it out with you on a blackboard.

Frequently asked questions

Why does GPS take longer to start up in a new place?

The receiver has to find and download satellite data before it can calculate a position. A recent fix makes this faster.

Is GPS the same as satellite navigation?

GPS is one system. Others run by different countries work the same way, and many receivers use more than one.

Get started

DuckyHelper can
do more

It sees your screen and works in any app you use. Try it for 10 minutes, no card.

Get it for Mac, Windows or Linux

Share

Questions and jobs

Do anything

Ask it a question or hand it a job, in any app.

Doing jobs for you is in early access on Mac. Asking works on Mac, Windows and Linux.