Skip to content

device/bootloader: hand each calibrated sweep pair to the app as floor lines - #174

Open
geonnave wants to merge 5 commits into
DotBots:mainfrom
geonnave:lh2-multi-lines
Open

geonnave wants to merge 5 commits into
DotBots:mainfrom
geonnave:lh2-multi-lines

Conversation

@geonnave

@geonnave geonnave commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #173: this branch carries #173's four commits under its own one. Review the last one here; the diff shrinks to them once #173 merges.

The secure side holds the homographies, so it is the side that can turn sweeps into geometry the app can fuse. For every calibrated station whose solve lands inside its own rectangle, localization_get_position() now also produces that pair's two floor lines with db_lh2_sweep_lines() from DotBot-libs. They go into a ring of 8 (four stations, two sweeps each), and the new veneer swarmit_localization_get_lines() drains it, oldest first. The veneer checks the app's buffer with cmse_check_address_range (non-secure, read-write) and the struct's alignment. The app then gates each line in its pose estimator (DotBot-firmware PR, below). The nearest-station fix of #173 stays as the lower rung: it seeds the estimator, feeds telemetry and the advertisement, and is what the robot uses whenever the estimator is not tracking.

Other changes:

  • The secure stack grows from 1 KiB to 2 KiB on the three dual-core bootloaders. The line solve runs on it under swarmit_keep_alive(), with secure main()'s frame still live, and a review estimated the peak just past 1 KiB.
  • The fresh-pair drain copies pairs in place rather than onto the stack.

Veneer table. swarmit_localization_get_lines lands mid-table and moves swarmit_init_rng, swarmit_localization_get_position, swarmit_get_min_tx_interval_us and swarmit_ipc_isr. The regenerated sample/cmse_implib.a is the one DotBot-firmware takes.

Flash order. Cable-flash this bootloader first, with the net core of #173 if not already done. Then, in the same visit, OTA every sandbox app rebuilt against this cmse_implib.a (the DotBot-firmware PR). An app built against the old library on this bootloader, or the reverse, calls the wrong veneers: never update apps first.

Validation.

  • SES 7.22 builds the bootloader for dotbot-v3, dotbot-v2 and nrf5340dk in Debug and Release, with 1.4 KiB of flash free in Debug and 4.5 KiB in Release. The nrf52840dk single-core bootloader (Debug), the net core and the sample also build.
  • The line maths is host-tested in DotBot-libs#42.
  • Nothing here has run on a robot. The bench has to show the per-station fix rate with two stations visible and the seam behaviour against the field camera.

Design: multi-station LH2 calibration plan, https://github.com/DotBots/dotbot-workspace/blob/main/plans/lh2-multi-station/plan.html (rendered copy not published).

+ - Files
#173, merges separately +410 -184 18
This PR's own commit: localization.c/.h, cmse_implib.c/.h, sample/cmse_implib.a (binary, 4 veneers moved), 3 project files +56 -3 8

Update: rebased onto #173 on main, and first bench run

This branch is rebased onto #173, which is now on main with #176's fix for a secure HardFault (no non-finite printf, no secure UNALIGN_TRP). This PR's own commit is unchanged, and its table above still holds.

Bench, three DotBot v3 robots, two stations, this PR with #173 and #175 (bootloader and net core cable-flashed, the dotbot app from DotBot-firmware#435 over the air):

  • The app reads every kept station's floor lines through the new veneer. With no heading yet, and a test calibration that shifts one station by +30 mm, it advertises one position between the two stations' solves (14 and 16 mm from the bootloader's per-station fix), steady over 82 and 83 adverts.
  • One station rebooted at rest after a drive: the robot's heading and axle are unchanged over 113 to 131 adverts. Before the libraries' heading hold, the same test turned a robot 13 degrees.
  • Station restarts with the app running on all three robots: every robot stays Running, last reset soft-reset.
  • The bench ran the pre-rebase tip. The rebase changes only a comment and the position of _clamp_mm in localization.c; the bootloader and net core build clean at this tip (SES Debug, dotbot-v3).

@codecov-commenter

codecov-commenter commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.04%. Comparing base (d68840d) to head (b8c83a1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #174   +/-   ##
=======================================
  Coverage   91.04%   91.04%           
=======================================
  Files          27       27           
  Lines        5124     5124           
=======================================
  Hits         4665     4665           
  Misses        459      459           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…ation

Breaking: the config page magic moves to SWRP, so every robot reads as
uncalibrated until it is cabled with a page baked by a matching host,
and a push only commits from a host sending the mask encoding. Flash the
bootloader and the net core together.

AI-assisted: Claude Opus 5.5
Points at the unmerged DotBot-libs branch adding drv/lh2_geometry; move
it to the merge commit once that lands. Both bootloaders now link
00drv_lh2_geometry, which the camera point moved into.

AI-assisted: Claude Opus 5.5
…r lines

Adds swarmit_localization_get_lines, which moves the init_rng,
get_position, get_min_tx_interval_us and ipc_isr veneers: every sandbox
app must be rebuilt against this cmse_implib.a and flashed after this
bootloader. The secure stack grows to 2 KiB, since the line solve runs
on it under swarmit_keep_alive.

AI-assisted: Claude Opus 5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants