Skip to content

A package for taking actions based on live or recorded ADS-B data.

License

Notifications You must be signed in to change notification settings

eastham/adsb_actions

Repository files navigation

adsb-actions: A package for taking actions based on live or recorded ADS-B data.

This module allows you to apply conditions and actions to JSON flight data coming from readsb, or other ADS-B data provider. The conditions and actions are specified in a simple human-readable YAML format.

These actions can then:

  • Drive a UI
  • Do real-time analysis and alerting, for example for aircraft of interest
  • Do offline analysis, for example to generate operational counts and statistics
  • Push operations to a database
  • Whatever else you can imagine!

Sample implementations of each of these are included -- here is a screenshot of the UI "stripview":

Screenshot of Stripview

Overview

Each YAML rule contains **conditions** and **actions**.

conditions are an ANDed set, and can include altitude ranges, lat/long proximity, location within a region specified in a KML file, etc.

actions include Slack, paging / JSON webhook, and python callback. See CONFIG_INSTRUCTIONS.yaml for more info.

Example YAML config:

  config:
    kmls:  # optional KML files that specify geographic regions.
      - tests/test3.kml 

  aircraft_lists:  # optional lists of tail numbers of interest.
    alert_aircraft: [ "N12345" ]

  rules:
    nearby:
      conditions: 
        min_alt: 4000        # feet MSL, must be >= to match
        max_alt: 10000       # feel MSL, must be <= to match
        aircraft_list: alert_aircraft  # use aircraft_list above
        latlongring: [20, 40.763537, -119.2122323]
        regions: [ "23 upwind" ]  # region defined in KML
      actions:
        callback: nearby_cb  # call a function registered under this name
        print: True          # print info about this match to console

API Usage:

    # First, (re)start your readsb including the option --net-json-port=[port]
    # This exposes a json-formatted live stream on that port. 
    # Then, to receive the data:

    yaml_file = "src/adsb_actions/basic_rules.yaml" # simple test config
    adsb_actions = AdsbActions(yaml_file=yaml_file, ip=[ipaddr], port=[port])
    adsb_actions.loop()

Installation from github:

  1. (download or clone code from github)
  2. python3 -m venv .venv
  3. source .venv/bin/activate
  4. pip3 install -e .
  5. (install geos native library: https://libgeos.org/usage/install/ -- "apt-get install geos" or "libgeos-c1v5" may do it)
  6. pytest -s tests/test_1hr.py

Quick initial testing:

  1. Add "--net-json-port 30006" to readsb startup args, as adsb_actions reads the json output
  2. Run "python3 src/adsb_actions/main.py --ipaddr localhost --port 30006 src/adsb_actions/basic_rules.yaml"
  3. You should see output for the aircraft readsb is seeing.
    Successful Connection
    INFO:adsbactions:Setup done
    01/21/24 14:38: Rule print_all_aircraft matched for N57111: 5350 MSL 141 deg 166.6 kts 37.8715, -122.2719
    01/21/24 14:38: Rule print_all_aircraft matched for N449WN: 7150 MSL 322 deg 194.8 kts 37.8703, -122.1147

More things to try:

  1. Tests are available: pytest -s tests/*.py
  2. Invoke a sample UI: cd src/stripview ; python3 controller.py -- --testdata ../../tests/1hr.json --rules ui.yaml --delay .01 ../../tests/test2.kml
  3. Command lines for other sample applications can be found in launch.json.

About

A package for taking actions based on live or recorded ADS-B data.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages