Proximity Detection Scripting: Passive & Active


#1

I was inspired by others here to pursue my own scripting, to see what I could accomplish. Right now, as one running an ADS-B ‘PiAware’ reception station far (100km+) from a major airport, I was interested in getting an ‘early warning’ of flights that were in visual (and photographic!) distance. I decided to tackle this on two levels:

  1. Passive client-side alerting: tweeks to the ‘dump1090’ web pages to let me know that an aircraft is nearby i.e. changing the aircraft icon color to ‘green’ when one enters a proximity circle 10km in radius (arbitrarily).

  2. Active server-side alerting: simple shell/python scripts to log data and send gmail letting me know that an aircraft is nearby i.e. when an aircraft enters a proxity circle 10km radius (arbitrary). With a bit more knowledge and tweeking, it might also be possible to generate a cell text message.

These features have already allowed me to get a short warning of approaching aircraft, which I have then been able to see and photograph (with a telephoto lens). Over time, I hope to get an understanding of which flights ‘typically’ fly over/near my station (so far, some Tokyo/NewYork flights are the best ones).

Anybody interested in any of this? If so, I could post some code.

https://www.dropbox.com/s/r7ftojquxnit24q/IMG_6987_dal172_900x600_crop_wb_unsharp.JPG?dl=0


#2

Okay now I think this is pretty cool! I won’t have time to play with it for a few days, working on a few ideas of my own with piaware but I will soon! Thanks for sharing.


#3

Have you seen this project, which points the pi camera at the appropriate part of the sky and starts video recording?

simonaubury.com/the-pi-plane-pro … roduction/


#4

Yes, I had noticed that project, and it set the bar very high for something that I wish I could do as well :slight_smile:

I have a small computer-controlled telescope mount that would be ideal for something like this, but right now it is way beyond my ability to program it for this purpose (i.e. iOptron SmartStar-A). Maybe some day!


#5

Rather than slap my code here on the forum – which makes it awkward for me to adjust/correct/improve – I decided to try to host my first ‘github’ repository for the ‘bash/python’ email-warner

https://github.com/darethehair/flight-warning

This makes it look for ‘professional’ than it really is :wink:

If anybody tries this (even just from the command-line to see if it works), let me know!


#6

FYI: I’ve spent a few days improving my code. The logic is simpler and more robust. An email is now also generated when the aircraft leaves the detection zone. Here is a sample of what one of these emails looks like:


ALERT: Aircraft Leaving Dectection Zone: JBU63 10.1 km

2015-07-28T12:19:28.975000-05 ICAO=A849AB FLIGHT=JBU63 LATITUDE=49.27007° LONGITUDE=-98.16883° ELEVATION=10973m DISTANCE=10.1km AZIMUTH=341.6° ALTITUDE=46.5°

http://flightaware.com/live/flight/JBU63

2015-07-28T12:18:26.469000-05,A849AB,JBU63,49.20406,-97.99206,10980,9.9,76.9,47.1
2015-07-28T12:18:26.469000-05,A849AB,JBU63,49.20406,-97.99206,10980,9.9,76.9,47.1
2015-07-28T12:18:28.460000-05,A849AB,JBU63,49.20618,-97.99769,10980,9.6,75.0,48.0
2015-07-28T12:18:28.890000-05,A849AB,JBU63,49.20662,-97.99889,10980,9.5,74.6,48.3
2015-07-28T12:18:29.351000-05,A849AB,JBU63,49.20712,-98.00023,10980,9.4,74.1,48.6
2015-07-28T12:18:29.931000-05,A849AB,JBU63,49.20772,-98.00185,10980,9.3,73.5,48.9
2015-07-28T12:18:30.391000-05,A849AB,JBU63,49.20822,-98.00312,10980,9.3,73.0,48.9
2015-07-28T12:18:32.272000-05,A849AB,JBU63,49.21024,-98.00847,10980,9.0,70.9,49.8
2015-07-28T12:18:33.392000-05,A849AB,JBU63,49.21138,-98.01164,10980,8.8,69.7,50.4
2015-07-28T12:18:34.333000-05,A849AB,JBU63,49.21239,-98.01424,10980,8.6,68.5,51.1
2015-07-28T12:18:36.323000-05,A849AB,JBU63,49.21451,-98.01987,10980,8.4,66.0,51.7
2015-07-28T12:18:37.304000-05,A849AB,JBU63,49.21554,-98.02269,10980,8.2,64.7,52.4
2015-07-28T12:18:38.354000-05,A849AB,JBU63,49.21664,-98.02565,10980,8.1,63.3,52.7
2015-07-28T12:18:39.345000-05,A849AB,JBU63,49.21768,-98.0284,10980,8.0,61.9,53.1
2015-07-28T12:18:39.845000-05,A849AB,JBU63,49.21824,-98.02985,10980,7.9,61.1,53.4
2015-07-28T12:18:39.914000-05,A849AB,JBU63,49.21824,-98.02985,10980,7.9,61.1,53.4
2015-07-28T12:18:40.915000-05,A849AB,JBU63,49.21935,-98.03284,10980,7.8,59.6,53.8
2015-07-28T12:18:41.375000-05,A849AB,JBU63,49.21985,-98.03417,10980,7.7,58.8,54.1
2015-07-28T12:18:41.915000-05,A849AB,JBU63,49.2204,-98.03565,10980,7.7,58.0,54.1
2015-07-28T12:18:42.496000-05,A849AB,JBU63,49.22104,-98.03734,10980,7.6,57.1,54.5
2015-07-28T12:18:42.895000-05,A849AB,JBU63,49.22145,-98.03847,10980,7.5,56.4,54.8
2015-07-28T12:18:44.277000-05,A849AB,JBU63,49.22292,-98.04234,10980,7.4,54.2,55.2
2015-07-28T12:18:44.837000-05,A849AB,JBU63,49.22351,-98.04396,10980,7.3,53.2,55.6
2015-07-28T12:18:45.027000-05,A849AB,JBU63,49.22351,-98.04396,10980,7.3,53.2,55.6
2015-07-28T12:18:45.408000-05,A849AB,JBU63,49.2241,-98.04553,10980,7.3,52.3,55.6
2015-07-28T12:18:46.318000-05,A849AB,JBU63,49.22507,-98.04812,10980,7.2,50.7,55.9
2015-07-28T12:18:46.762000-05,A849AB,JBU63,49.22552,-98.04939,10980,7.2,49.9,55.9
2015-07-28T12:18:47.308000-05,A849AB,JBU63,49.22611,-98.05095,10980,7.1,48.9,56.3
2015-07-28T12:18:47.868000-05,A849AB,JBU63,49.22666,-98.05247,10980,7.1,48.0,56.3
2015-07-28T12:18:48.328000-05,A849AB,JBU63,49.22718,-98.05385,10980,7.1,47.1,56.3
2015-07-28T12:18:48.909000-05,A849AB,JBU63,49.22778,-98.05544,10980,7.0,46.0,56.7
2015-07-28T12:18:49.479000-05,A849AB,JBU63,49.22836,-98.05706,10980,7.0,45.0,56.7
2015-07-28T12:18:50.099000-05,A849AB,JBU63,49.22836,-98.05706,10980,7.0,45.0,56.7
2015-07-28T12:18:50.440000-05,A849AB,JBU63,49.22937,-98.05974,10980,6.9,43.2,57.1
2015-07-28T12:18:50.839000-05,A849AB,JBU63,49.22983,-98.06094,10980,6.9,42.4,57.1
2015-07-28T12:18:51.359000-05,A849AB,JBU63,49.23038,-98.06242,10980,6.9,41.4,57.1
2015-07-28T12:18:53.310000-05,A849AB,JBU63,49.23239,-98.06794,10980,6.8,37.6,57.4
2015-07-28T12:18:54.381000-05,A849AB,JBU63,49.23354,-98.07094,10980,6.8,35.5,57.4
2015-07-28T12:18:54.801000-05,A849AB,JBU63,49.23399,-98.07213,10980,6.8,34.6,57.4
2015-07-28T12:18:54.941000-05,A849AB,JBU63,49.23399,-98.07213,10980,6.8,34.6,57.4
2015-07-28T12:18:56.362000-05,A849AB,JBU63,49.23564,-98.0765,10980,6.7,31.5,57.8 *** CLOSEST APPROACH ***
2015-07-28T12:18:57.232000-05,A849AB,JBU63,49.23653,-98.079,10980,6.7,29.8,57.8 *** CLOSEST APPROACH ***
2015-07-28T12:18:58.412000-05,A849AB,JBU63,49.23779,-98.08232,10980,6.7,27.4,57.8 *** CLOSEST APPROACH ***
2015-07-28T12:18:59.503000-05,A849AB,JBU63,49.23894,-98.08544,10973,6.8,25.2,57.4
2015-07-28T12:18:59.893000-05,A849AB,JBU63,49.23894,-98.08544,10973,6.8,25.2,57.4
2015-07-28T12:19:01.664000-05,A849AB,JBU63,49.24123,-98.0915,10973,6.8,20.9,57.4
2015-07-28T12:19:02.194000-05,A849AB,JBU63,49.24179,-98.09302,10973,6.8,19.9,57.4
2015-07-28T12:19:02.714000-05,A849AB,JBU63,49.24231,-98.09454,10973,6.9,18.8,57.0
2015-07-28T12:19:03.124000-05,A849AB,JBU63,49.24274,-98.09566,10973,6.9,18.1,57.0
2015-07-28T12:19:03.625000-05,A849AB,JBU63,49.24329,-98.09714,10973,6.9,17.1,57.0
2015-07-28T12:19:04.135000-05,A849AB,JBU63,49.24384,-98.09851,10973,6.9,16.1,57.0
2015-07-28T12:19:05.166000-05,A849AB,JBU63,49.24493,-98.10143,10973,7.0,14.2,56.7
2015-07-28T12:19:06.758000-05,A849AB,JBU63,49.24659,-98.10596,10973,7.1,11.2,56.3
2015-07-28T12:19:07.857000-05,A849AB,JBU63,49.24775,-98.10907,10973,7.2,9.3,55.9
2015-07-28T12:19:08.868000-05,A849AB,JBU63,49.24883,-98.11192,10973,7.3,7.5,55.6
2015-07-28T12:19:09.437000-05,A849AB,JBU63,49.24943,-98.11355,10973,7.3,6.5,55.6
2015-07-28T12:19:10.027000-05,A849AB,JBU63,49.25006,-98.11523,10973,7.4,5.5,55.2
2015-07-28T12:19:10.508000-05,A849AB,JBU63,49.25056,-98.11657,10973,7.4,4.7,55.2
2015-07-28T12:19:11.047000-05,A849AB,JBU63,49.25111,-98.11812,10973,7.5,3.8,54.8
2015-07-28T12:19:12.039000-05,A849AB,JBU63,49.25217,-98.12092,10973,7.6,2.2,54.5
2015-07-28T12:19:12.598000-05,A849AB,JBU63,49.25278,-98.12251,10973,7.7,1.4,54.1
2015-07-28T12:19:13.129000-05,A849AB,JBU63,49.25336,-98.12397,10973,7.7,0.6,54.1
2015-07-28T12:19:13.579000-05,A849AB,JBU63,49.2538,-98.12526,10973,7.8,359.9,53.8
2015-07-28T12:19:14.139000-05,A849AB,JBU63,49.25441,-98.12685,10973,7.8,359.0,53.8
2015-07-28T12:19:14.679000-05,A849AB,JBU63,49.25497,-98.12836,10973,7.9,358.2,53.4
2015-07-28T12:19:15.220000-05,A849AB,JBU63,49.25557,-98.12988,10973,8.0,357.5,53.1
2015-07-28T12:19:16.290000-05,A849AB,JBU63,49.2567,-98.13291,10973,8.1,355.9,52.7
2015-07-28T12:19:16.781000-05,A849AB,JBU63,49.2572,-98.13429,10973,8.2,355.3,52.4
2015-07-28T12:19:17.181000-05,A849AB,JBU63,49.25762,-98.13545,10973,8.2,354.7,52.4
2015-07-28T12:19:18.191000-05,A849AB,JBU63,49.25871,-98.13833,10973,8.4,353.4,51.7
2015-07-28T12:19:18.742000-05,A849AB,JBU63,49.25925,-98.13986,10973,8.4,352.7,51.7
2015-07-28T12:19:19.221000-05,A849AB,JBU63,49.25976,-98.14123,10973,8.5,352.0,51.4
2015-07-28T12:19:19.862000-05,A849AB,JBU63,49.25976,-98.14123,10973,8.5,352.0,51.4
2015-07-28T12:19:20.282000-05,A849AB,JBU63,49.26093,-98.14419,10973,8.7,350.8,50.7
2015-07-28T12:19:21.322000-05,A849AB,JBU63,49.262,-98.14716,10973,8.8,349.5,50.4
2015-07-28T12:19:21.764000-05,A849AB,JBU63,49.26246,-98.14839,10973,8.9,349.0,50.1
2015-07-28T12:19:22.342000-05,A849AB,JBU63,49.26307,-98.15005,10973,9.0,348.3,49.8
2015-07-28T12:19:22.753000-05,A849AB,JBU63,49.26352,-98.15122,10973,9.0,347.9,49.8
2015-07-28T12:19:23.163000-05,A849AB,JBU63,49.26395,-98.15236,10973,9.1,347.4,49.5
2015-07-28T12:19:23.643000-05,A849AB,JBU63,49.26446,-98.15373,10973,9.2,346.9,49.2
2015-07-28T12:19:25.053000-05,A849AB,JBU63,49.26595,-98.1577,10973,9.4,345.4,48.5
2015-07-28T12:19:26.013000-05,A849AB,JBU63,49.26695,-98.16045,10973,9.6,344.4,47.9
2015-07-28T12:19:26.494000-05,A849AB,JBU63,49.26746,-98.16179,10973,9.7,344.0,47.7
2015-07-28T12:19:27.474000-05,A849AB,JBU63,49.26851,-98.1646,10973,9.8,343.0,47.4
2015-07-28T12:19:28.014000-05,A849AB,JBU63,49.26906,-98.16615,10973,9.9,342.5,47.1
2015-07-28T12:19:28.465000-05,A849AB,JBU63,49.26954,-98.1674,10973,10.0,342.1,46.8

Closest approach: 6.7km


#7

For your interest…

I wanted to make the logs generated by my Python program somewhat compatible with the free online ‘CartoDB’ map generator (csv, etc.), and today I used the ‘alert’ CSV files generated in the last week or so (within 10km of my station) to generate an interactive map:

http://cdb.io/1M4SSe1


#8

For your interest…

Thanks to the code and advise from http://www.movable-type.co.uk/scripts/latlong.html, my code now attempts to ‘predict’ a likely visible flight encounter long before it actually enters the detection zone. It does this by using the aircraft course and a ‘cross track error distance’ calculation. What I have found in some experimentation is that slight course corrections can alter these predictions over time i.e. even a one degree change can make all the difference. In any case, the emails generated from these ‘early warnings’ give me much more time to prepare for a visual siting and/or camera shot :slight_smile:


#9

Update: Since I was moderately successful adding aircraft ‘prediction’ code (tracking to near my station) to my Python code, I decided to try adding similar logic to the javascript ‘/usr/share/dump1090/public_html/planeObject.js’ code. So, for the settings I am using, if the track of an aircraft will take it to within 10km of my station, the aircraft icon will turn GREEN – giving me a visual hint of something interesting ahead.

This is similar to my Python program, which sends email warning me instead. If, subsequently, the track will take it out of the 10km detection zone, the icon color returns to normal (and, for the Python program, an email is sent indicating the same thing). Today, during testing, I had two aircraft – from completely different directions – show up this way. For my location, this is highly unusual i.e. not near an airport, and a fairly small detection radius:

https://www.dropbox.com/s/0fdn5t2o01tvysv/dlh446_dal582_encounter.png?dl=0

Now, in the coding world, I should probably ‘fork’ the official ‘dump1090’ code and include my stuff, so that it is all tracked nicely. However, I don’t know how to do this, and I can’t find the GitHub code repository that ‘FlightAware’ is using to do this – or if they are even interested in these modifications…


#10

The FA dump1090 code is here: github.com/flightaware/dump1090 … ump1090_mr


#11

FYI: A ‘spin off’ of the data log generated from my ‘Flight Warning’ scripts is an ‘antenna range’ overlay similar to what the Windows users get with the ‘Virtual Radar Server’ software (I use Linux myself):

https://www.dropbox.com/s/1mgxw05wy23nf4y/antenna_limits.png?dl=0

I highly doubt that this is the most efficient way to generate and use such a graphic, but I wanted to explore my abilities to code this up. I simply used Linux utilities (awk, etc.) to extract lat/lon/bearing info from my log, put the most distant entries into a 360 degree array, extract to a CSV file, convert to a KML file, and use ‘geoxml3’ javascript to plot the result as a polygon on top of the ‘dump1090’ Google Map.

P.S. How does one imbed an image into a post here?


#12

A range plot on dump1090 would be a great feature. Covering upto 24 hours if possible.


#13

I agree that having a ‘range plot’ built directly into dump1090 would be the best solution for all :slight_smile: In my case, I decided to flex my coding muscles to see what I could accomplish in the meantime. For my own test, I had been gathering stats for about 7 days. Other enhancements that I would love to see in dump1090 include:

  • visual sighting prediction (to the receiver)
  • extra columns in the tabular display to indicate distance and bearing to the aircraft (as well as ‘expected overhead’ times)
  • an easy toggle for metric/nautical/statute measurements