Record link: records_tx.py and records_rx.py¶
Lives on: both Pi 5s in ~/capstone/rfdf/ (records_rx.py runs on the lead only).
Source in this repo under drone-system/pi5/. Started by
rfdf.sh.
What it does¶
Gets every paired measurement from both drones into one file on the lead, where the fusion step will read it, without losing any when the radio link drops.
follower: DOA app → paired.csv → records_tx.py ──UDP──┐
├─▶ lead: records_rx.py → records_YYYYMMDD_HHMMSS.csv
lead: DOA app → paired.csv → records_tx.py ──UDP──┘
Each record is one Kraken bearing paired with the drone's position and heading at that moment (DOA app): time, latitude, longitude, heading, bearing relative to the array, true bearing, confidence and signal strength. About 2.3 per second per drone.
Walkthrough: no lost records¶
UDP doesn't guarantee delivery, so the sender keeps its own list:
- Each new row gets a sequence number and is sent as one small JSON message.
- The lead answers every record with an acknowledgement (
ack) carrying that number. - Anything not acknowledged within 1.5 s is resent, a couple at a time so a backlog catches up quickly without flooding the link.
- If nothing has been acknowledged for 3 s the link is treated as down: the sender keeps up to 300 records (about 2 minutes) and probes once a second with the oldest one.
- When the link comes back, the backlog drains.
The receiver acknowledges duplicates again but writes each (drone, run, sequence) only
once, so a resend after a lost acknowledgement doesn't double a row.
Tested: the receiver was killed and restarted mid-run. The new file had 0 missing and 0 duplicate records; about 85 records per drone came in as resends.
Walkthrough: a new file every start¶
Every time the receiver starts it opens a new file named with the date and time, and points
records_latest.csv at it. An old run is never overwritten, and the fusion script always
reads the same name.
Testing without a drone¶
records_tx.py --fake sends made-up records on the Kraken's timing, marked fake, so the
link can be tested with no Cube or Kraken.
Still to do¶
- Run it over the Microhard radios instead of the bench switch.
- The fusion script that reads the combined file (in progress).