devleaks / pyModeS

Python decoder for Mode S and ADS-B signals

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The Python ADS-B/Mode-S Decoder

PyModeS is a Python library designed to decode Mode-S (including ADS-B) messages. It can be imported to your python project or used as a standalone tool to view and save live traffic data.

This is a project created by Junzi Sun, who works at TU Delft, Aerospace Engineering Faculty, CNS/ATM research group. It is supported by many contributors from different institutions.

Introduction

pyModeS supports the decoding of following types of messages:

  • DF4 / DF20: Altitude code
  • DF5 / DF21: Identity code (squawk code)
  • DF17 / DF18: Automatic Dependent Surveillance-Broadcast (ADS-B)
    • TC=1-4 / BDS 0,8: Aircraft identification and category
    • TC=5-8 / BDS 0,6: Surface position
    • TC=9-18 / BDS 0,5: Airborne position
    • TC=19 / BDS 0,9: Airborne velocity
    • TC=28 / BDS 6,1: Airborne status [to be implemented]
    • TC=29 / BDS 6,2: Target state and status information [to be implemented]
    • TC=31 / BDS 6,5: Aircraft operational status [to be implemented]
  • DF20 / DF21: Mode-S Comm-B messages
    • BDS 1,0: Data link capability report
    • BDS 1,7: Common usage GICB capability report
    • BDS 2,0: Aircraft identification
    • BDS 3,0: ACAS active resolution advisory
    • BDS 4,0: Selected vertical intention
    • BDS 4,4: Meteorological routine air report (experimental)
    • BDS 4,5: Meteorological hazard report (experimental)
    • BDS 5,0: Track and turn report
    • BDS 6,0: Heading and speed report

If you find this project useful for your research, please considering cite this tool as:

@article{sun2019pymodes,
    author={J. {Sun} and H. {V\^u} and J. {Ellerbroek} and J. M. {Hoekstra}},
    journal={IEEE Transactions on Intelligent Transportation Systems},
    title={pyModeS: Decoding Mode-S Surveillance Data for Open Air Transportation Research},
    year={2019},
    doi={10.1109/TITS.2019.2914770},
    ISSN={1524-9050},
}

Resources

Check out and contribute to this open-source project at: https://github.com/junzis/pyModeS

Detailed manual on Mode-S decoding is published at: https://mode-s.org/decode

The API documentation of pyModeS is at: https://mode-s.org/api

Basic installation

Installation examples:

# stable version
pip install pyModeS

# conda (compiled) version
conda install -c conda-forge pymodes

# development version
pip install git+https://github.com/junzis/pyModeS

Dependencies numpy, and pyzmq are installed automatically during previous installations processes.

If you need to connect pyModeS to a RTL-SDR receiver, pyrtlsdr need to be installed manually:

pip install pyrtlsdr

Advanced installation (using c modules)

If you want to make use of the (faster) c module, install pyModeS as follows:

# conda (compiled) version
conda install -c conda-forge pymodes

# stable version
pip install pyModeS

# development version
git clone https://github.com/junzis/pyModeS
cd pyModeS
poetry install -E rtlsdr

View live traffic (modeslive)

General usage:

$ modeslive [-h] --source SOURCE [--connect SERVER PORT DATAYPE]
            [--latlon LAT LON] [--show-uncertainty] [--dumpto DUMPTO]

arguments:
 -h, --help            show this help message and exit
 --source SOURCE       Choose data source, "rtlsdr" or "net"
 --connect SERVER PORT DATATYPE
                       Define server, port and data type. Supported data
                       types are: ['raw', 'beast', 'skysense']
 --latlon LAT LON      Receiver latitude and longitude, needed for the surface
                       position, default none
 --show-uncertainty    Display uncertainty values, default off
 --dumpto DUMPTO       Folder to dump decoded output, default none

Live with RTL-SDR

If you have an RTL-SDR receiver connected to your computer, you can use the rtlsdr source switch (require pyrtlsdr package), with command:

$ modeslive --source rtlsdr

Live with network data

If you want to connect to a TCP server that broadcast raw data. use can use net source switch, for example:

$ modeslive --source net --connect localhost 30002 raw
$ modeslive --source net --connect 127.0.0.1 30005 beast

Example screenshot:

image

Use the library

Common functions

Core functions for ADS-B decoding

Note: When you have a fix position of the aircraft, it is convenient to use position_with_ref() method to decode with only one position message (either odd or even). This works with both airborne and surface position messages. But the reference position shall be within 180NM (airborne) or 45NM (surface) of the true position.

Decode altitude replies in DF4 / DF20

Decode identity replies in DF5 / DF21

Common Mode-S functions

Mode-S Elementary Surveillance (ELS)

Mode-S Enhanced Surveillance (EHS)

Meteorological reports [Experimental]

To identify BDS 4,4 and 4,5 codes, you must set mrar argument to True in the infer() function:

Once the correct MRAR and MHR messages are identified, decode them as follows:

Meteorological routine air report (MRAR)

Meteorological hazard air report (MHR)

Customize the streaming module

The TCP client module from pyModeS can be re-used to stream and process Mode-S data as you like. You need to re-implement the handle_messages() function from the TcpClient class to write your own logic to handle the messages.

Here is an example:

Unit test

To perform unit tests, pytest must be install first.

Build Cython extensions :

$ make ext

Run unit tests :

$ make test

Clean build files :

$ make clean

About

Python decoder for Mode S and ADS-B signals

License:GNU General Public License v3.0


Languages

Language:Python 90.2%Language:Cython 8.0%Language:C 1.5%Language:Makefile 0.2%