mirror of
https://github.com/pollen-robotics/microduck.git
synced 2026-12-03 02:47:45 +08:00
A trained detector exists (yolo11n at 320, one class, mAP50 0.976 on a held-out session, 3.9 MB quantised) and nothing on the robot could run it. This is the three things between a camera frame and a bounding box, plus the tool that measures them on a real board. `dlopen`, not link. librknnrt.so is a vendor blob in no Debian suite, and a crate that linked it could not be cross-compiled in CI at all — robotd reaches ONNX Runtime the same way, for the same reason. The cost is one file of transcribed ABI; the benefit is that `cargo board --bins` still works on a laptop, which it does. Four things in here are where this goes wrong quietly rather than loudly. The head is `[1, 5, N]` **planar** — every cx, then every cy — and read as five-per-box it produces boxes that are almost plausible, which looks like a bad model rather than a bad reader. It suppresses nothing, so one duck is twenty overlapping boxes until the decoder does. The letterbox has to match what training did, padding included. And the sampler folds the camera's mount rotation into the resample it is already doing, because rotating in the pipeline costs the encoder its zero-copy path — 8 fps and 97 °C, which is the branch before this one. Three ABI values were guessed wrong and only a board could say so, so they are now comments rather than constants anybody has to rediscover: `rknn_query`'s INPUT_ATTR is 1 and OUTPUT_ATTR is 2 (swapped, it answers about the output and complains it cannot make sense of `[1, 5, 2100]` as an input); SDK_VERSION is 5; and **NCHW is 0 while NHWC is 1** — backwards, `rknn_inputs_set` logs a normalize error and *returns success anyway*, so inference runs on an unset buffer and reports two confident boxes on every frame for ever. The struct-offsets test caught two more of my errors before the board did. `duck-bench` answers three questions in order: does it run, does it still see ducks (a model that runs and detects nothing looks exactly like one that works), and what does it cost — latency percentiles, CPU, and the SoC temperature, because running it flat out took the board to 95 °C and the CPU to 408 MHz. It paces at 2 Hz for that reason; `--hz 0` finds the ceiling deliberately. `scripts/setup-npu.sh` installs the runtime at a pinned tag and reports on the driver, which is the real gate: Armbian ships `npu@fde40000` as `status = "disabled"` on this board, and the only overlay it offers is one that disables it further. `--enable-node` writes the one-property overlay (deploy/overlays/), never reboots, and says how to undo it. The pin agrees with Cargo.toml by a test.