Photo: credits to Yanidel

Underground location tracking

Putting new pressure on your old barometer

Joseph Dureau
Snips Blog
Published in
7 min readMar 22, 2016

--

There is more to location tracking than triggering avalanches of advertising when you walk by a store. Location is a key element to a specific field of artificial intelligence called context awareness. It can be used to determine where you are, where you’re heading to, and your current needs. For example, it is only natural that one expects a person to behave differently in a church and in a disco. Context awareness is about giving devices enough intelligence to tell the difference between a sacrament and a party, and adjust accordingly.

Traditional activity detection

Traditional activity detection with mobile phones relies on location and accelerometer data. Location estimates can be computed in reference to nearby radio towers, wifi signals, or directly through GPS. Beyond location, the accelerometer can be used to understand what a person is doing. Periodic movements at given frequencies are specific of certain activities: walking, running, biking, etc. When a person goes for a jog, her phone can reconstruct her trajectory and identify when she runs or walks based on the peaks of the accelerometer signal in the frequency domain.

Traditional activity tracking using GPS and accelerometer. As shown on the map, location estimates are collected as the user runs. In the right panels, we show a sample of accelerometer data in the time (top) and frequency (bottom) domains. (photo: credits to Hernán Piñera).

The problem of inferring a user’s activity from location and accelerometer data has been thoroughly studied. As mentioned, it is easy to identify when a user is walking, running or biking. When it comes to detecting automotive transportation, like driving a car, or taking a train or a bus, the accelerometer is of little use. You would think that the accelerations of the vehicle would be significant enough to leave a trace in your phone’s accelerometer data, but in reality the signal is very weak. In this case, location can take over and be used to compute features like average speed, maximal speed, frequency and location of stops. The latter can then be contrasted to nearby roads, junctions, rails or bus stops. Here again, very good performances can be reached.

A blind spot of traditional activity detection

All of this is pretty cool and straightforward, but leaves out an important blind spot: what happens when you’re underground? You may want your phone to understand which route you’ve taken, to warn you of any perturbation in real time, or to let you know when to get off the metro. In this perspective, both your location and accelerometer sensors are worthless.

Traditional trackers are worthless when underground (photo: credits to Yanidel).

When you’re taking the metro, unless specific infrastructure has been put in place to provide connectivity for your phone, you get very poor to no location data. It is the case in the vast majority of Parisian metro lines, for example. As mentioned for the other automotive transportation modes, your accelerometer doesn’t bring much information about what’s happening down there. Tough luck. But wait, more and more phones are equipped with a sensor that is often overlooked: the barometer.

Experimenting with the barometer

Barometers measure ambient pressure. Typically, they are used to detect local changes of weather, or changes in altitude. When we heard that some academics had looked at estimating transportation modes based on pressure data (see here, here or here), we started experimenting with our phones’ barometers. Have a look at the figure below, that shows pressure measured over time with three different Android phones. Over the period plotted on this figure, we had gone through four metro stations. Each trip between a station and the next one generates a downwards peak in pressure. Pretty clear signal, right?

Pressure measured over time, with three different Android phones. Over this period, we went from Châtelet to Concorde metro stations, which corresponds to 4 stations. Each trip from a station to another is clearly characterised by a downwards peak in pressure. This peaks can be located with > 90% accuracy with an off-the-shelf peak detection algorithm (black dots).

It just happens that strong accelerations of a vehicle in a closed tunnel creates something called the Venturi effect, that explains how variations in speed can induce variations in pressure. By looking at the pressure measured by your phone, you see that it systematically drops when the metro accelerates, and comes back to its original level when the metro slows down.

Counting stations

After we realised the signal was clean, we decided to take the experiment a step further. We decided to explore the possibility of using pressure to count the stations, in order to warn the user who is dozing off during his daily commute that it is time to get off the train. By using a peak detection library, we managed to get over 90% accuracy in counting stations over time. See the black dots on the previous figure, for reference.

Probabilistic location tracking: your underground GPS

Counting stations is a helpful feature for your daily commute, or when you know where your user is going. This is probably the method that Citymapper uses to tell you when to get off the metro. But we wanted to go a step further, and use the barometer to detect which metro line the user has taken, and which direction he’s heading to. In other words, once we’ve been able to detect when the metro starts and stops, we wanted to know if it was possible to use the duration of each trip to identify the stations through which a user is going. We went to the closest metro station, Bourse, and tried it out. We made a series of round trips to Opéra, and back to Réaumur Sébastopol. Again and again, collecting data along the way.

When the user takes the metro at Bourse, can you tell which way he’s going by just measuring the duration of each trip segment? By using a simple Bayesian approach, it turns out that you can, after only two stops, with over 90% accuracy.

With that data, we reconstructed the distribution of trips’ durations, for each of the trip segments. Based on that, we built a Bayesian model that determines the probability that the user went into one direction or the other, based on the observed trip durations. By following this simple model, you get the answer right in over 90% of the cases, after only two stations.

Of course, you can bring this figure higher, or support more uncertainty in the data measurement process, if you accept to wait a few more stations to take a decision. In addition, this model is able to tell you when it doesn’t know. For example, here, the first trip segments in both directions typically last the same amount of time (43 to 52 seconds versus 45 to 53 seconds). In that case the probabilities will be very close, suggesting to the AI to wait another station to make up its mind.

There is more value in our data than you might think

To sum things up, your phone’s barometer will probably be key to bringing context awareness underground. You can now start expecting from your favorite apps to help you relax during metro rides, letting you know when to get off. You can expect your phone to identify your favorite routes, and keep you informed of potential perturbations. You can even expect navigation systems to guide you through an unknown metro network. Kind of an underground GPS, in a way. That’s yet another step towards the vision of ubiquitous computing!

What this story also tells us is that there is more value in your data than you might think. Two things to think about when a mobile application asks you for the right to access a new source of data:

  • What type of information does my data contain?
  • Can I trust the app with the information found in my data?

The example of your phone’s barometer shows that it can be very hard to perceive what information is contained in a given source of data. Thus, the best solution is to be very careful with the applications you entrust your data to. On that note, we are going to leave you with this last one thought: there is no reason to compromise on your privacy to get intelligence from your phone. At Snips, we are working on building advanced artificial intelligence systems while fully respecting privacy. For example, your barometer data would be processed directly on device, so that no one ever has access to it. Not even us.

That’s all, folks. Enjoy the wonders of context awareness, and remember: privacy-aware artificial intelligence is the future. Do not compromise, and enjoy the ride!

To hear more about Context Awareness, and Artificial Intelligence in general, follow us on Twitter at @jodureau and @snips.

To try out our app, sign in for the Beta.

And by the way, if you care about creating products that will change the way we use our devices in our daily lives, take a look at our jobs page!

Lastly, many thanks to Francis and my brother Sylvain, who took more than their fair share of metro rides for these experiments!

--

--