Introduction: Cat Tracking Using Bluetooth Indoor Positioning
This Instructable teaches you how to build a system to track indoor positioning of cats. The purpose of this project is to get insight into pet positioning and see their interactions.
The system incorporates RSSI (Received Signal Strength Indicator) to estimate cat position. A bluetooth device is put on the cat, and other bluetooth devices are used as device scanners ("beacons"). These beacons scan the area for the Bluetooth device attached on the cat. The scanning process results in a RSSI for the discovered device. The stronger the RSSI, the closer the cat is to the beacon. In order for the localization to work, we collected "fingerprints" of the RSSIs to multiple beacons to be used as training data for a classifier to predict the location of the cat. After collecting fingerprint data, we ran the live system with the cats to collect test data. We used Machine Learning on the actual test data to predict the location of the cats using the fingerprint data.
The system is based on http://www.kptang.com/pubs/gsmlocalization-hotmob...
List of Materials
- One or more cat to track.
- An apartment or space for cats (preferably a natural environment the cats are comfortable in)
- At least three Bluetooth-enabled devices to use as beacons. We used Android phones with an RSSI reporting app (explained in steps 3-5)
- Any Bluetooth-enabled device to attach to the cat. We used Samsung Galaxy Gear.
- A web server with a database (explained in step 1)
- A visualization for the data (explained in step 9)
This instructable was made as part of the CS graduate course "Tangible Interactive Computing" at the University of Maryland, College Park taught by Professor Jon Froehlich. Please see http://cmsc838f-s14.wikispaces.com/ for more details. This project was done by Hitesh Maidasani and Sana Malik.
Step 1: Set Up a Web Server to Collect Data
The server should be able to accept and store data in a database. The code for the server is available at https://github.com/sana-malik/CatGear.
The server receives and stores training fingerprint data. The process for collecting the fingerprint data is explained in Steps 3-4.
The server also receives and stores the actual testing data once the whole system is live. This process is explained in Steps 5-7.
The server can be hosted on a local machine or on any cloud service such as Heroku. We used a node.js server hosted on Heroku in order to avoid running a local server for the entire experiment which was run for over 36 hours.
The database and tables should be setup. Attached is a dump of the PostgreSQL database with sample data (b012.dump). The dump also consists of the schemas of the tables.
Step 2: Attach the Three Beacons to Different Parts of the Space
Tape the three Android phones to different parts of the space.
We taped one phone under a living room coffee table, the second to the table in the dining room, and the third to the dresser in the bedroom.
Ensure that the phones are connected to a stable power supply and that the phone sleep settings are turned off.
Step 3: Install Data Training App on Each Phone
The Android app for collecting training data is located here: https://github.com/sana-malik/CatGear/tree/master/...
The app has a text box for the ID for each test point location. When "Scan Devices" is pressed, the app scans the area for the two Galaxy Gears. Once they are found, the app sends the RSSI values for each Gear to the web server along with the location entered in the text box and the current phone's MAC address which is used to identify each phone. If the Gear is not found, the app reports a zero value.
Note: Do not pair the Gear with the phone. The app simply scans the area for all Bluetooth-enabled devices.
Step 4: Collect Fingerprinting or Training Data
This step is the most time consuming step.
We chose 15 spots in the apartment to track: table, litter, scratch post, hallway, dresser, couch, counter, desk, lvngrm corner, kitchen window, balcony, door, bed, bed window, food.
We placed both Gears at each location and ran the fingerprinting app on each of the three phones with the appropriate label from the above list. The app scanned for both Gears and reported the RSSI of both Gears (labeled with a gear id) to the server with the location. We ran the app 7 times at each location for reliability.
Place the two Gears at the desk. Now run the app on the first phone with the label "desk" seven times. Next run the app on the second and third phone with the same label 7 times each.
Now, the database table for the fingerprinting data should have 21 rows with location "desk. Of these 21 rows, 7 are for one MAC address, 7 for a second MAC address, and another 7 for the third MAC address. There should be some post-processing done to join these 3 sets of 7 rows to just one set that has the three RSSI from the three devices on one row.
After doing this for all 15 locations, the table should have 315 rows. After doing the post-processing and joining, the table should have 105 rows.
Step 5: Install the Data Logging or Testing App on the Android Phones
Once the fingerprinting data has been collected, the actual test data can be collected to observe the behavior of the cats. Now install the data logging app on the phones. Our app can be found here: https://github.com/sana-malik/CatGear/tree/master/...
The app scans for the Gears. The Gears can be at any location within the area. Once the app has discovered the Gears, it reports the RSSI from of both Gears (with a gear id) and the phone MAC address. This app scans every 12-15 seconds and reports the RSSI's to the server. So, there are 3 of these apps running simultaneously and reporting to the server.
We do some post processing again on this data to join the three RSSI reading of the same gear and average the readings over a minute time frame.
Step 6: Attach the Galaxy Gears on the Cats
Attach each Galaxy Gear on each cat. This may need some modification to the strap of the watch since each cat's neck has a different size. We used string to elongate the size of the strap. Ensure that the watch is not making the cat uncomfortable since this is an experiment and the device should not modify the cat's usual behavior. Also, ensure that the Gear should not be easily removed by the cat.
Note: These cats were not harmed or distressed by wearing this collar.
Step 7: Let the System Run for Several Hours
We ran the system for about 44 hours.
While doing this, it is a good idea to keep track of some sort of manual log for some location points that the cats are at. This can help test the accuracy of the location classifier used in the next step.
Step 8: Run Location Classifier
We used a K-Nearest Neighbors classifier to predict the locations of each test point. A test point consists of 3 RSSI readings from each phone for a particular Galaxy Gear. Using this test point and the training fingerprinting data, we run the KNN classifier with N=3 to obtain the predicted location.
The classification code is located at https://github.com/sana-malik/CatGear/blob/master/....
Step 9: Visualize Data
Using the predicted locations during the 44 hour period, we visualize the data using a heat map and a time flow location map.
The visualization code is available at https://github.com/sana-malik/CatGear/tree/master/...
We have a be nice policy.
Please be positive and constructive.