# andykamath/Trifi

Confined location tracking via trilateration of wifi beacons
Latest commit 05c5b6e Sep 10, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
client Sep 10, 2017
server Sep 10, 2017
viewer Sep 10, 2017
.eslintrc.json Sep 10, 2017
.gitignore Sep 10, 2017
demo.png Sep 10, 2017
demo2.png Sep 10, 2017
distance.png Sep 10, 2017
graph.png Sep 10, 2017
graphs.xlsx Sep 10, 2017
logo.png Sep 10, 2017
package.json Sep 10, 2017
screenshot.png Sep 10, 2017
squares.gif Sep 10, 2017
yarn.lock Sep 10, 2017

## What?

Our goal was to create a noninvasive location tracker through a confined space. Our solution provides store owners/managers with a tool to see where their consumers spend most of their time without invading the customer's right to privacy. Our goal is that the merchant incentivizes the consumer with a discounted purchase so that the store can collect data about where to optimally place products.

Usage of the product is entirely up to the consumer, and the beauty of the product is that it stops tracking a user's location beyond the confines of a store.

DISCLAIMER: This product does not violate a consumer's right to privacy, as it ends tracking by the time the consumer leaves the predefined confines of the system.

## How it works

Given a beacon at position (Xa, Ya), a user's distance from the router can be calculated through a transformed form of the Free Space Path Loss (FSPL) formula. Through communicating with the wi-fi emitted from the beacon, a computer can calculate the signal strength in dBm and the frequency in MHz. When plugged into the following equation, where f is the frequency and s is the signal strength, a distance d in meters is returned.

While this was a great start, the problem persisted as to finding the user's specific location. The equation returns a distance between the user and the beacon, which forms a circle around the beacon of radius d. In order to track the precise location, we used a technique known as trilateration (very similar to triangulation). When we use n=3 beacons, we can plot three different circles and thereby get a much more precise area as to where the user could be through optimization with least squares approximation. As can be seen with a simple graph below, the area of overlap between all three beacons can be used to generalize a location within a given confined area.

## Computational Technicalities/Specifications

A computer is used in the middle (can be as portable as an Raspberry Pi if plugged into a portable charger; we were lacking in resources so we used a laptop) to communicate with all three beacons. The computer recursively disconnects with a Wi-Fi connection, communicates with each beacon, calculates the location, then communicates with a GCP back-end via a RESTful API, mimicking multilateral U-TDOA technology that's used to geolocate cell phones. Mathematical models were originally drafted in Python, but were ported to a Node.js back-end for powerful and asynchronous network tools.

## Demonstration

Here we can see a teammate demonstrating how the beacons were able to track a very close approximate to his location. Had the beacons been more uniform and more spaced apart like in a real production use case.

## Challenges/Responsibilities

This was a first in multiple ways for all of us. Henry, Andy, and Saul came to PennApps hoping to build some kind of deep learning project as that's where their interests lay. Nathan was originally responsible for front-end interactivity. However, after arriving and spending all of Friday night brainstorming ideas and working out a lot of what ended up being useless complicated math, we decided to go with something unique and explore territories we've never dealt with in the past. None of us have ever worked with network engineering or hardware hacking, so this entire experience was brand new for all of us. Henry and Andy spent a lot of the original time writing bash scripts and mathematical models for network analyses. Nathan spent a good part of the later half of Saturday implementing the abstractions with his specialties in JavaScript (the other three mainly do Python development). Saul, being a Physics grad student right here at Penn, was able to help in both facets a myriad of times where/when needed. He was primarily responsible for the actual trilateration models in Python that then became much easier to port to JavaScript.

Also, due to the use of multiple phones and OSes as beacons, the signals weren't uniform and often resulted in diverging plots, which led to the necessity of more approximation functions. In production, all three beacons will be identical for more uniform signal analysis.

## Future Plans

We plan to implement this in small shops so that they know how to optimally organize their materials for consumers who want them at a given time and place. As brick and mortar shops are quickly succumbing to large online retail stores, this will help small businesses boost profits and hopefully attract more consumers away from online retail and toward their own business. Also, this can be used in AR/VR kits and games to map a user within a given video game world in order to make the experience more interactive.

We will also move into RF technology to eliminate the dependence on internet in lower-income areas of the country and world. For more precision, we could potentially add more nodes for linear scalability.

You can’t perform that action at this time.