{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# EE123 Lab2 - Real-Time Flight Radar App\n", "\n", "### Written by Miki Lustig and Frank Ong" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from __future__ import division\n", "import numpy as np\n", "from numpy import *\n", "from numpy.fft import *\n", "\n", "\n", "from rtadsb import rt_flight_radar" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Task III: Play with the Real-Time Flight Radar\n", "\n", "The function rt_flight_radar() in rtadsb.py creates a real-time flight position plot using your preamble detection function and an ADS-B decoder. \n", "\n", "Decoding the packets is beyond the scope of this lab, but at a high level, the decoding is done by first identifying the useful packets containing location information. For our lab, we are only interested in long squitters with Downlink Format (DF) = 17, which can be identified by the first 5 bits. Once we have identified a DF-17 packet, we can identify the airplane type (ICAO address) from Bytes 2 to 4. The rest of the packet will contain the altitude, latitude and longitude information, which look like this:\n", "\n", "`[TC-] [-Altitude-] T F [----Latitude---] [---Longitude--]`\n", "\n", "`01011 000 000011111111 0 0 10110011110111111 01001101110100110`\n", "\n", "The latitude and longitude are tricky to decode as there are not enough bits to encode all locations. Each ADS-B packet is further divided into even and odd packets and there is a complicated equation to combine one even and one odd packet to get the exact location...\n", "\n", "If you are interested in more detail, you can take a look at these links:\n", "* http://www.lll.lu/~edward/edward/adsb/DecodingADSBposition.html. There's a nice explanation how to decode position. \n", "* http://sdrsharp.com/index.php/a-simple-and-cheap-ads-b-receiver-using-rtl-sdr is a windows software to decode ads-b using rtl-sdr\n", "* http://www.blackcatsystems.com/software/cocoa1090.html is an OSX software to decode ads-b using rtl-sdr\n", "* https://github.com/antirez/dump1090 is a *nix software (linux/osx) to decode ads-b using rtl-sdr. It also has a feature that you can display planes positions on google maps. \n", "\n", "Our ADS-B decoder heavily follows the dump1090 software for mode S decoding." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Copy and paste your `detectPreamble` function to the code cell below. Scroll down to the bottom and you should be able to run rt_flight_radar()! To receive the ads-b packets from planes, it is recommended you are outside during daytime. It is also recommended to use Chrome to view the map. **Sometimes, some parts of the map become blank, but you can fix it by resizing your browser or refresh the page**.\n", "\n", "**Information obtained from the flight radar will be printed on the command line.** If a plane with position information is detected, it will be shown as a blue blob on the map. If a flight number is decoded, it will be shown next with the blue blob. It might take some time to detect a plane, but be patient. However, it might not be on the map because its position information is not received. \n", "\n", "* Run the flight radar until you see at least a plane on the map. You can check whether the plane is real by googling its flight number (if available)." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Your detectPreamble and data2bit functions below:\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "fs = 2000000; # 2MHz sampling frequency\n", "center_freq = 1090e6 # 1090 MHz center frequency\n", "gain = 49.6 # gain\n", "N_samples = 2048000 # number of sdr samples for each chunk of data\n", "\n", "pos_ref = [37.875219, -122.257939] # Berkeley's latitude, longitude for initializing the map\n", "\n", "functions = (detectPreamble, data2bit)\n", "\n", "# Run flight radar\n", "stop_flag = rt_flight_radar( fs, center_freq, gain, N_samples, pos_ref, functions )\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Run this to stop\n", "\n", "stop_flag.set()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "# I hope you enjoyed the lab!" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.11" } }, "nbformat": 4, "nbformat_minor": 0 }