Long distance sound localization with the Raspberry Pi
medium.com
medium.com
https://resenv.media.mit.edu/pubs/theses/Resynthesizing_Volu...
Rather than manually finding the timestamps in the individual audio files you can do pretty well with using cross-correlation to find the relative delays between the mic signals. Any particular delay between a pair of microphones corresponds to a hyperbola through the mic array. If you visualize the hyperbola from all the pairs of microphones, the correct location pops up as the intersection of them. The cross-correlation peak can get pretty smeared out though, because each microphone is hearing a different version of the source signal.
You could probably use something like this in a war zone to locate from where somebody is trying to shoot you. A quick google later yields e.g. https://www.rheinmetall.com/en/products/c4i/reconnaissance-a... or https://transvaro.com/wp-content/uploads/akustik-eng.pdf (which lists accuracy of... 1-2m).
Last weekend I localized an explosion to within 20m when two of the microphones were 3 km apart. I went to the location and they were firing fireworks as part of some religious ceremony.
To everyone: if you make something and put it on the web, please spend 10 minutes to write a single paragraph of introduction for people who just learned that your thing exists.
The Android Team Awareness Kit (ATAK), for civilian use, or Android Tactical Assault Kit (also ATAK) for military use - is a suite of software that provides geospatial information and allows user collaboration over geography.
ATAK was originally developed by the Air Force Research Laboratory (AFRL) and is now maintained by the TAK Product Center (TPC).
There's more information on the About page (accessible via the navigation bar on desktop, or the menu on mobile): https://www.civtak.org/atak-about/
But his article presents a fun challenge. He doesn’t say where his receiver locations are but he does give a triangle dimensions. I wonder if it’s possible to map this onto the street names and then work out which farm it was. It seems likely that there is only one way to map that triangle so each vertex is on the street it is reported to be on.
Then you could invent a time, any time and add the number of seconds that he mentions to get the two other times. Now you have the times and the co-ordinates, within the constraints from the time inaccuracies you could run the docker version of my localization program (https://github.com/hcfman/sbts-aru) on this input and it would output the map link to the offending farm. With a largish degree of error.
Note. From the diagram, the sound source doesn’t fall within the triangle of receivers. This can still work, but the convergence drops off after a time so you can only practically localize this if the distance is not too far outside. But if you make battery powered receivers, you choose a better spot and move one if the recorders so it does fall within the triangle.
Also, just one second of error is a lot!
$ docker run -i localize_event 20
Enter GPS coordinates and timestamps. Press enter twice to finish.
51.014131667,5.813736667 2023-09-17_15-49-48.522301
51.015373333,5.811656667 2023-09-17_15-49-48.810330
51.016368332,5.814084879 2023-09-17_15-49-48.710824
51.015238333,5.815941667 2023-09-17_15-49-48.543376
Location: 51.014903961182846,5.814442712946816
Web links:
OpenStreetMap:
https://www.openstreetmap.org/?mlat=51.014903961182846&mlon=...
Google Maps:
https://www.google.com/maps?q=51.014903961182846,5.814442712...
Note also, you can simulate this easily by choosing locations on a map and calculating the expect time of arrivals. Then you can introduce one more seconds of error and see what difference it makes.
It’s lovely to work things out for yourself but he could have saved himself some weeks of sleep by googling sound localization if that was his primary interest :-)
It is weird that you can leg off air cannons all night for three weeks and not have the authorities on your head though.
*Coordinates, or lat/long
Other navigation systems are available, including other GNSS!
> 51.014903961182846,5.814442712946816
I'm not sure localisation to the level of the atomic lattice is entirely relevant in this use case.
* His listening posts were part of a triangle with sides of length 3.8km, 3.0km and 6.3km
* The vertices were on the roads in Corvallis, Bellfountain Rd, Brooklane Dr and Rivergreen Ave
* The relative times of arrival are 0, 4, 6
* The temperature was 35F or 1 degree celsius
The only way I can make a triangle that fits on those three roads yields a set of the following likely co-ordinates from where his listening posts are:
44.52421,-123.33492 44.53796,-123.29172 44.52975,-123.25571
Adding the relative times to the co-ordinates in a form whereby my localization program can work on it and putting it through my localization program I get the following result:
$ localize_event.sh 1
44.52421,-123.33492 2024-05-27_12-00-00.0
44.53796,-123.29172 2024-05-27_12-00-04.0
44.52975,-123.25571 2024-05-27_12-00-06.0
Enter GPS coordinates and timestamps. Press enter twice to finish. Location: 44.488866130770134,-123.31219694386117
Web links:
OpenStreetMap:
https://www.openstreetmap.org/?mlat=44.488866130770134&mlon=...
Google Maps:
https://www.google.com/maps?q=44.488866130770134,-123.312196...
Which results in a location south and west of the airport as described in the article :)
Knowing how localization works where the sound source is outside of the polygons it could be a bit further South as well.
I'd be very curious to know how close I have been in working this out.
And also points out that the longer the distances involved the less critical time error is making mobile phone time of arrival viable.
We had 4 raspberry pis with mic arrays. They were time synced over a wifi mesh network (indoor so no GPS). Each had a detector running, and would send detection segments to a base station to run generalized cross correlation.
It worked pretty well, but we were doing it in room scale 20' environments. Our biggest issue was that we could not disambiguate echos, and had to hack in a hold off period.
We did not end up having time but I wish we could have gotten beamforming working on each pis microphone array, then we could have combined angle of arrival with tdoa, and potentially better handled the echo.
I understand wanting to avoid firing a gun, an explosive.
But my mind recalls putting dry ice in a 2-liter soda bottle containing already hot water. Lid goes on quickly and tightly....
Legal? Not sure. Definitely gives you shotgun-level decibels though. Not at all directional.
How do you time-synchronize the 4 RPi? When you power them off, you lose the sync. So it is difficult to do it correctly.
Also it may be possible that the different RPi have different clock drift over time? i.e. 1.0000 hour on one of them = 1 hour + 20 milliseconds on another one
https://github.com/hcfman/sbts-aru
uses a GPS to synchronise the time with and then even when running completely disconnected from any network the clocks will be accurate to real time with less than 1 microsecond of error. Typically the system time hovers around 100 ns or less from the real time. And I’ve tested this by triggering interrupts on gpio’s on two devices with the same switch and printing the time.
Syncing to sub microsecond accuracy is usually achieved in under a minute.
I’m a person that likes extremes so the extremely accurate clock time I could get with a GPS synched Oi really appeals to me. Although it’s not really necessary I want to get an rtk GNSS next year to experiment with. Together with ultrasonic microphones I’m pretty sure it could do a great job localizing bats.
In the example further down the page where I attempt to work out where the air cannon was fired from, the “1” is for 1 degree Celsius.