search

No GPS required: our app can now locate underground trains

Bad service in the subway? Our offline motion detection shows where you are between stations, and reminds you when your stop’s up next

October 31, 2024

En français svp

In the twisting vaults of a subway, metro, or U-Bahn, there’s often no reliable cell service, wifi, or GPS. 

Which means you had no good way of keeping track of your stops or ETA when underground.

GIF: representation of a vehicle location not being updated when there is no GPS

You had to look out the window for signs on the platform, listen for station announcements, or tilt your neck 90° to read one of those digital screens. How perfectly quaint!

Here’s the bad news: we don’t have a hundred billion dollars to build ground-penetrating GPS satellites. The good news: we have Étienne, Ayser, Jonathan and Luc!

Thanks to our clever engineering, we can now predict your location in a subway tunnel using your phone’s vibration signature. Simply:

1. Start a trip with GO

You can start a GO trip directly from the line details screen or from a trip you planned

2. Ta-da! We’ll show your predicted location on the map, count down the stations, and update your ETA

Yes. Even without knowing your GPS coordinates.

Now, for a peek behind our magic curtain…

Step 1: basic motion classification

Once you enter a train tunnel with bad GPS, the magic begins. First, we have to figure out where you are between stations. For that, we need to confirm that you’re on a moving train!

To get our bearings, let’s look at some accelerometer data from Stephen, the fastest-walking Transit employee, which he recorded on his phone during his commute to our Montreal office:

Fast but also meticulous, Stephen labeled the different parts of his trip, like:

With inspiration from one of our favourite French mathematicians, we can clean up Stephen’s acceleration data and turn it into frequency data, which can start to give us an idea about what’s happening on a moving train vs. elsewhere.

Spectrogram showing frequencies in hertz (Hz) during a trip in the subway, with the vertical axis indicating frequencies (0 to 12 Hz) and the horizontal axis showing the elapsed time in seconds. Colors vary to represent the intensity of frequencies at different moments."

There’s a few clues. For one, when Stephen’s train is moving his phone vibrates at ~5 Hz, versus ~2 Hz when he’s walking. But the pattern isn’t clear-cut, with lots of random noise and harmonic frequencies (those fainter pink lines cascading above the more vivid red ones) muddying up the picture.

To definitively say “this is a moving train” vs. “this is not” we need to train a machine to classify motion types — a task which requires A LOT of training data.


Step 2: gathering ground truth

We asked Stephen and his valiant colleagues to repeat the exercise: but now labeling data for hundreds of trips across dozens of cities, so that we could build a generalized model to say “yes! moving train!” regardless of the type of train or tracks being used.

Our trusty emissaries Étienne and Elijah were sent down from Montreal to collect vibration data on our app’s most popular underground system: the New York City subway.

 Étienne and Elijah taking the bus and subway in NYC
Étienne and Elijah on a hunt for truth. (The under-ground truth™)

Armed with iPhones, Androids, and MetroCards, they spent a week riding the MTA’s buses and trains, labeling each step of every trip:

Phone used during the "Ground Truth" quest with app tool to provide info

We’d rely on their data for clues to distinguish between on-a-train vibrations vs. other vibrations in a train station.

Which meant Elijah and Étienne had to ride the escalators and elevators up and down for hours at a time, vigilantly annotating each time they stopped to catch their breath.

They eventually rode every subway line in New York, from the Bronx to Brighton Beach, across the Queensboro, Manhattan, and Williamsburg Bridges (where there is cell service) back through the rickety Canarsie Tunnel (where there is not).


Step 3: training our motion classifier

After cleaning and processing our data, we could begin training our motion classifier to distinguish “moving train!” from “not moving train!”.

We start by feeding the model our unlabelled sensor data and asking it to randomly guess whether the phone is on a moving train, a stopped train, walking, going up an escalator, et cetera. We verify these guesses against our manual annotations (the “ground truth”) and add logic to guide our model to more accurate predictions.

After a great deal of tinkering, our model can now confidently predict if someone is on a moving train – or if their phone is just vibin’.

Now that we know when a rider is moving underground, the next step is to make that information useful: where, precisely, is their train?


Step 4: making a location prediction

It was time to add one last model to the mix, aptly named The Mixer.

We trained this model to weigh…

  1. the motion type prediction (aka “is this a moving train?”) 
  2. the last-known location of the user
  3. whether the last-known location came recently or a long time ago
  4. the train schedule

…to predict the user’s current location.

It now makes the right location prediction 90% of the time.

A list of cellular pings during an RER trip in Paris — you can see the underground part of this west-to-east ride (on the left) gets a few sporadic location updates via GPS and Bluetooth/wifi scanning. With these location updates, we can calibrate our underground location predictions in the areas without coverage. When the user pops above ground to areas with cell service (on the right)? We go back to using standard GPS locations.

This is the holy grail of underground detection: since you can predict where a rider is, you can show them where they are on a map, update their ETA, and tell them when to get off at the right station.

It’s a step up from the status quo method of detecting your location underground. No more relying on spotty GPS — or bobbing and weaving between incomprehensibly tall humans to read those digital screens!

What’s even more wonderful? Our station counting works completely offline. Both of our models (the motion classifier, and the mixer) have been compressed into tiny files that run on your phone, without sending any data to Transit’s servers.

No tracking. No cookies. Your vibration data is your own damn business!


Want to try out our underground detection for yourself?

Easy: just find yourself an underground train, open Transit, start a trip with GO, and watch the stations tick down, one-by-one! We’ve helped riders detect 1.5 million underground stations across ~400,000 trips during our initial tests.

GO’s step-by-step navigation was already being used by millions of aboveground riders in 600+ cities — including folks propelled by bikes, since our launch of GO Bike last month.

Now, their subterranean train-riding counterparts can rely on it more confidently in areas with bad service, so Transit can be their guiding light from end-to-end in every tunnel.

Try it in the app

Recent articles
Our mission:
make cars obsolete.
Get Transit