High Precision WiFi Indoor Positioning Framework: FIND

2016-10-07T03:31:28
ID N0WHERE:123010
Type n0where
Reporter N0where
Modified 2016-10-07T03:31:28

Description

High Precision WiFi Indoor Positioning Framework


The Framework for Internal Navigation and Discovery ( _ FIND _ ) allows you to use your (Android) smartphone or WiFi-enabled computer (laptop or Raspberry Pi or etc.) to determine your position within your home or office. You can easily use this system in place of motion sensors as its resolution will allow your phone to distinguish whether you are in the living room, the kitchen or the bedroom, etc. The position information can then be used in a variety of ways including home automation, way-finding, or tracking!

> Simply put, FIND will allow you to replace _ tons _ of motion sensors with a _ single _ smartphone!

The system is built on two main components – a server and a fingerprinting device. The fingerprinting device ( computer program or android app ) sends the specified data to the machine learning server which stores the fingerprints and analyzes them. It then returns the result to the device and stores the result on the server for accessing via a web browser or triggering via hooks.

Can I use an iPhone?

No. We currently do not support iPhone. Unfortunately, the information about the WiFi scanning has to come from the use of the Apple80211 library . This is private library which means that a user would have to jail break their device in order to use it .

> We do not want to distribute an app that would require users to jailbreak their phones, so we will have to avoid developing for iOS until Apple removes this restriction. Sorry!

What’s the point of this?

The point is to eventually incorporate FIND into home automation. FIND can replace motion sensors to provide positional and user-specific information. Anything that you would do with a motion sensor you can do with FIND . Anything you can do with GPS information you can do with FIND information. Except here you get internal positioning so you could tell apart one table from another in a cafeteria, or one bookshelf from another in a library.

As Wi-Fi singleboard computers get smaller and smartphones become more ubiquitous there will be more and more opportunities to harness WiFi signals into something useful for other applications.

FIND classifies locations using two methods.

  • FIND uses a very simple, but very effective machine learning formulation known as a Naive-Bayes classifier for Method 1 .
  • The second method is uses the _ prevalence _ of a specific Mac address in a single fingerprint. A single fingerprint is composed of all the Mac addresses and signal values that were detected in that read. In certain locations, you can more frequently sample certain routers than other routers. Thus, a very simple method of classification can use the frequency of “seeing” a Mac address as a basis. This calculation is _ Antenna based _ since different devices will be able to “see” more or less routers based on their antenna type. Thus, this type of calculation will often be used for single-device learning.
  • Mixin – There is a mixin variable that calculates the linear combination of Method 1 and 2 that results in the optimal parameter set.

Does the smartphone version use up the battery quickly?

No. One important benefit of using WiFi-based technologies as they are relatively cheap sensors in the smartphone/computer. They are cheap in a monetary sense, as well as a power supply sense. Normally, a GPS sensor that is probed every 2 seconds will quickly drain your battery. Probing the WiFi every 2 seconds will take hours to drain your battery and is less taxing than many apps.

Can it replace motion sensors?

Yes…probably. Replacing motion sensors with FIND has the added benefit of automatically providing _ user information _ as well as the position/time information. The main disadvantage is that there is time delay of 1-5 seconds to register, so timing applications are not as good. It is possible to increase the scan speed to accomplish better timing applications but it will drain the life of the battery faster.

Does it use a Wi-Fi location database ?

No. There is no dependency on external resources like Wi-Fi location databases. However, these type of databases can add additional information that might be worthwhile to explore to also integrate into FIND .

What is the minimum distance that can be resolved?

It depends. This system harnesses the available WiFi routers. If you have very few WiFi routers in the vicinity (i.e. <3 in 50 meters) then your resolution will suffer. Otherwise, you can typically get less than 10 square feet in location resolution.

Can you run the server on a Raspberry Pi?

Yes. Its been tested and runs great on a Raspberry Pi model B+, and model 3. Also, all the releases include a ARM release for running on a Raspberry pi .

Install with Go


First install Go if you haven’t already. FIND is tested on Go version 1.5+.

$ git clone https://github.com/schollz/find.git
$ cd find
$ go get ./...
$ go build

Then to run,

$ ./find
-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----
   _________  _____
  / __/  _/ |/ / _ \  ______ _____  _____ ____
 / _/_/ //    / // / (_-&lt; -_) __/ |/ / -_) __/
/_/ /___/_/|_/____/ /___|__/_/  |___/\__/_/

(version 2.X) is up and running on http://192.168.1.2:8003
-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----

MQTT support


Setup (Self-hosted servers)

Basically, right now you can only run mosquitto using a instance running from a configuration file created specifically by _ FIND _ . To get started, you’ll first need the latest copy of mosquitto :

wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
cd /etc/apt/sources.list.d/
sudo wget http://repo.mosquitto.org/debian/mosquitto-wheezy.list
sudo apt-get update
sudo apt-get install mosquitto-clients mosquitto

Then goto your FIND folder and create a file (in the future I’ll have FIND do this automatically):

mkdir /path/to/find/mosquitto
touch /path/to/find/mosquitto/conf

Now, start mosquitto in the background:

mosquitto -c /path/to/find/mosquitto/conf -d

Now, you can startup FIND :

./find -mqtt ADDRESS:1883 -mqttadmin ADMIN -mqttadminpass ADMIN_PASS -mosquitto `pgrep mosquitto` -p :PORT ADDRESS:PORT

The ADDRESS and PORT is the address and port your using for FIND . The pgrep mosquitto is for getting the mosquitto PID, which is used to send SIGHUP to reload the passwd file. The ADMIN and the ADMIN_PASS are your secret name and password to access read/write access to every MQTT channel. Make sure these are not simple enough to guess.

That’s it!

Client (MQTT connections)


Register

To receive data from the FIND MQTT, follow these steps. First, register your group using the following:

curl -X PUT "https://ml.internalpositioning.com/mqtt?group=YOURGROUP"

where YOURGROUP is your group name. This command will tell FIND to add group level access to your own special MQTT channel. You’ll receive a message like:

{
    "message": "You have successfully set your password.",
    "password": "YOURPASSWORD",
    "success": true
}

The password is what you can use to access MQTT now. You can retrieve your password by using the same curl command. These passwords are completely random, and not hashed – so totally not guessable.

Subscribing

First make sure to register. To subscribe to your channel to see current locations, simply use the topic YOURGROUP/location/# , e.g.:

mosquitto_sub -h ml.internalpositioning.com -u YOURGROUP -P YOURPASSWORD -t "YOURGROUP/location/#"

Publishing Fingerprints

Currently, MQTT takes only a very specific type of fingerprint. Basically, to utilize the minimal MQTT byte size you have to compress the mac addresses and RSSI components.

To publish fingerprints, use the channel YOURGROUP/track/USERNAME for tracking or YOURGROUP/learn/USERNAME/LOCATION for learning. The body needs to be a multiple of 14 bytes where the first 12 bytes are the Mac address and the next 2 bytes is the RSSI value (absolute value). For example, if your detected routers are

"ab:cd:ef:gf:ij:kl":-32
"mn:op:qr:st:uv:wx":-3

then you’ll need to send the following as the body:

"abcdefgfijkl32mnopqrstuvwx 3"

SVM support


Follow these instructions if you are running a FIND server and would like to add SVM to the machine learning routines.

Setup (Self-hosted servers)

FIND will automatically utilize libsvm once it is installed. Here are the instructions to install (you should run with root/sudo):

sudo apt-get install g++
wget http://www.csie.ntu.edu.tw/~cjlin/cgi-bin/libsvm.cgi?+http://www.csie.ntu.edu.tw/~cjlin/libsvm+tar.gz
tar -xvf libsvm-*.tar.gz
cd libsvm-*
make
cp svm-scale /usr/local/bin/
cp svm-predict /usr/local/bin/
cp svm-train /usr/local/bin/

Then just restart FIND! It will automatically detect whether its installed. When SVM is enabled, you will see SVM data along with the Naive-Bayes information.

High Precision WiFi Indoor Positioning Framework: FIND Download