One-command startup: rfdf.sh¶
Lives on: the follower Pi 5, at ~/capstone/rfdf/rfdf.sh. Source in this repo under
agentcore/rfdf/.
What it does¶
Brings up the whole follower drone stack with one command, or stops it, or just checks it:
~/capstone/rfdf/rfdf.sh up # start whatever isn't running, then check each piece
~/capstone/rfdf/rfdf.sh status # check only; starts/stops nothing
~/capstone/rfdf/rfdf.sh down # stop AgentCore and the DOA app
~/capstone/rfdf/rfdf.sh down --kraken # also stop the Kraken software on the Pi 4
Before this script, starting a bench test meant three terminals and five manual steps in the right order. Now it's one line, and logs go to files instead of terminal windows.
Walkthrough: what up does, in order¶
| # | Step | How it knows the step worked |
|---|---|---|
| 1 | Pi 4 reachable over the onboard cable | SSH answers within 5 s |
| 2 | Pi 4 clock synced to the Pi 5 | timedatectl reports synchronized (waits up to 30 s) |
| 3 | Kraken software running on the Pi 4 | A fresh sample (< 3 s old) appears (waits up to 2 min) |
| 4 | DOA app running | Something is listening on local port 8770 |
| 5 | AgentCore running | Its web UI answers on port 8085 |
The order matters. The DOA app starts before AgentCore so that when AgentCore's graph starts, the app it calls is already there.
Walkthrough: safe to run any time¶
Every piece is checked before it's started. If a check already passes, that step just reports "already running":
if check_kraken >/dev/null 2>&1; then
ok "Kraken already running"
else
info "starting Kraken on the Pi 4 (takes ~1 min)..."
$SSH "cd $KRAKEN_DIR && nohup ./kraken_doa_start.sh > /tmp/kraken_start.log 2>&1 < /dev/null &"
wait_for 120 check_kraken
fi
So if one piece falls over mid-test (the Kraken's USB link dropping, say), running
rfdf.sh up again restarts only that piece. The check for the Kraken is the same idea
as the DOA app's health check: it looks at how old the newest sample is, not just whether
the page answers.
kraken_age_ms() {
local t
t=$(curl -s -m 1 "$DOA_URL" | cut -d, -f1 | tr -dc '0-9')
[ -n "$t" ] && echo $(( $(date +%s%3N) - t ))
}
wait_for <seconds> <check> retries a check once a second until it passes or time runs
out, then prints the final [ OK ] or [FAIL] line.
Things learned building it¶
- AgentCore held its printed output back when writing to a file, so the graph's
OKlines didn't show up in the log until about 4 KB had piled up. Starting it throughstdbuf -oL -eLfixed that. - Everything is started with
nohup, so closing the SSH session (or the test screen) does not stop the stack.
Still to do¶
- Start automatically at power-on for flight, with no operator (systemd services).
- Log rotation for
~/capstone/rfdf/logs/. - The same setup on the leader drone.