DonePlan PyDotBotswarmitDotBot-libsDotBot-firmware

Several lighthouses, one calibration, from spinning robots

Install several LH2 base stations, spread robots over the floor and let each one spin where it stands. A spin seen by two stations is a tie point between them, so one joint solve over all stations puts every station in one metric frame, scaled by the spin radius, with a predicted error map that says where the calibration is weak. The site editor places the whole calibration on a hand-made site as one rigid body; robots spread over the site can anchor it to the room instead. On the robot, stations stop having to be numbered 0 to N-1, an uncalibrated station stops shadowing a calibrated one, a push carries its calibration id so two solves never mix, and fixes come first from the nearest calibrated station, then from every sweep of every station fused in the pose estimator.

Where this came from

The developer, 2026-10-02: support for multiple LH2 base stations, with a plan. Two questions first: do the base stations need to be "in sequence" in the bootloader, and how should calibration work with N stations. The intended design to evaluate: robots spread across the arena spin and record whatever stations they see; robots seeing two or more stations tie them together; one joint calibration; the site editor (phase 6 of the site-editor plan) places it on the site map; optionally four robots at known corners for a true lab frame. Bootloader and firmware changes acceptable if worth it.

Same day, after the first draft: the developer approved implementing it, and asked for the best of an independent clean-sheet design (written without reading this plan, with its own simulation) to be folded in, defaults chosen for the open questions, and the interfaces frozen so three tracks (PyDotBot host, swarmit plus DotBot-libs firmware, site editor) can be built in parallel. Section 09 is that freeze.

Live state

Status done Progress 7 of 7 merged Validated tests (host tests in this plan; the two-station bench runs are logged in lh2-multi-bench, not here)

Created 2026-10-02 Updated 2026-11-10 Tracker none; the shipped work is tracked on DBK-182 by lh2-conics-calibration

Interfaces frozen 2026-10-02 (section 09)

Code refs PyDotBot main @ c715d7d (merge of #331, the top of the host stack); swarmit main @ 6a6857f (merge of #174); DotBot-libs main @ 228ce9a (merge of #42); DotBot-firmware main @ 9e1d6a8 (merge of #435) Released PyDotBot 0.34.0, swarmit 0.12.0, DotBot-firmware 1.26.0, DotBot-libs 0.6.0 (2026-11-09)

Review summary

Phases 1 to 5, 8 and 9 shipped: the host stack and swarmit's Python merged 2026-10-16, the firmware wave (DotBot-libs #42, swarmit #173 and #174, DotBot-firmware #435) on 2026-11-09, and all of it went out in the 2026-11-09 release. The firmware PRs merged after the two-station bench bring-up in lh2-multi-bench, and the same release carried the follow-ups to this work (swarmit #176 second-station HardFault, #177, #178 sensor retry; DotBot-libs #43; PyDotBot #341 to #344, #347, #348, and the workflow doc #350). Validation in this plan is host tests; the two-station runs on robots are that plan's, logged there by the bench agent, and the release was checked on the bench with 2 stations and 3-4 robots. Placement in the site editor (phase 6) moved to PyDotBot #315, still open; phase 10 is postponed.

RepoPRWhatLinesFilesStateMerged
PyDotBot#322Phase 1: joint solve, station graph, error map, report, schema 4+2317 / -17315merged10-16
PyDotBot#323Phase 2: collect --spin --append, calibrate-lh2 show+207 / -94merged10-16
PyDotBot#324Phase 3 host half: push and bake by mask with per-station rectangles+298 / -14128merged10-16
swarmit#175Phase 3 host half: swarmit's Python, 0xA3 by mask, device info 4+273 / -18312merged10-16
PyDotBot#325Phase 8 (optional): anchors, collect --spin --anchor+378 / -215merged10-16
PyDotBot#331Phase 9 (optional): next-round planner, show --next-round+1221 / -9040merged10-16
DotBot-libs#42Phase 5: per-sweep floor lines, fused in the pose estimator+2024 / -10524merged11-09, 1st
swarmit#173Phases 3 (firmware half) and 4: calibrations keyed by station mask, nearest calibrated station+412 / -19118merged11-09, 2nd
swarmit#174Phase 5: each calibrated sweep pair handed to the app as floor lines+56 / -38merged11-09, 3rd
DotBot-firmware#435Phase 5: the sandbox dotbot app fuses the floor lines of every calibrated station+336 / -118merged11-09, 4th
PyDotBot#326Phase 6: place a calibration on a hand-made site+4787 / -1327closed, in #315 (open)-

01The problem

One station is calibrated and pushed today; the floor needs several
pushed today
0..N-1stations must be numbered from zero, no gaps
stored per robot
16homography slots, one per LH2 channel; kept
recorded per spin
4stations, the calibrate-spin app's cap; kept
to tie two stations
2shared circles 300 mm apart at least; 4 advised

One LH2 base station covers about 3 m of floor at a usable elevation (plans/lh2-calibration-frames/multi-station.html, section 01), so the arena plus staging already wants two, and a floor wants seven. The spin calibration of plans/done/lh2-conics-calibration/ (DotBot-firmware #433, PyDotBot #317) removes the surveyed marks for one station, and its solver already records every visible station's reads per spin. What is missing is everything after that: tying the stations into one frame with a residual a reviewer can trust, telling the operator where the calibration is weak, pushing a set of stations whose channels are not 1 to N, using more than one station sensibly on the robot, and placing the result on a site.

Verdict

The intended design is sound and most of its pieces exist. What it needs: a station graph with explicit tie thresholds and a predicted error map; one joint refinement over all stations, with chaining only as its seed; per-station validity rectangles carried to the robot; a station mask and a calibration id in place of the dense count (Question A); a runtime that skips uncalibrated stations now and fuses every sweep later; and the site editor's placement applied to all stations at once. Robots keep per-station homographies for this implementation; a pose-plus-corrections station model is recorded as a later option, gated on measured model error.

02What exists already

Prior work, and the clean-sheet design folded into this revision
WhereWhat it holdsWhat this plan does with it
plans/done/lh2-conics-calibration/plan.html phase 5"Several stations in one frame", optional: solve_calibration() aligns every station to the one with the most circles through 2 or more shared centres. Prototyped, never tested with two stations.Takes it over. The prototype is phase 1's starting point; that phase 5 should point here.
plans/lh2-calibration-frames/multi-station.html (status idea)Floor layout (seven stations, six seams, 3 m reach), loops beating chains, the 16-slot ceiling, per-station tables keyed by lighthouse index.Keeps the layout and the invariants. Ties are shared spin circles instead of surveyed seams.
ideas/lh2-calibration/conics-swarm.htmlTwo stations each owning half the strip, fused through the overlap circles; 5 to 7 mm error floor per station from the sweep model.Sets the expected seam disagreement and the phase 7 layout.
BACKLOG.md C7; the RA-L 2024 and 2025 papersC7: multi-LH at scale. The conics paper finds "Two LH 2D" (stations related by correspondences alone) the worst method it tested.Why each station is rectified metrically by its own circles first.
Clean-sheet design, 2026-10-02 (scratch, not committed)Written without reading this plan: stations as calibrated angular cameras with a pose, one joint bundle adjustment, a predicted error map, per-sweep scalar EKF fusion with innovation gating and per-station health, a constellation id in the push, active collection, anchors spanning the site, and a simulation behind each claim.Folded in: joint-not-chained (section 06), the error map and "spread beats count" (section 05), runtime phases A and B (section 07), the calibration id rule (section 09), active collection (phase 9), anchors spanning the site (section 11), its open questions (section 13). The pose model is recorded, not built (section 04).

03Do stations have to be "in sequence"?

Question A: how a station's calibration is indexed, and what breaks for channels 3 and 9
Channel to polynomial to lh_index to homography slot, then today's dense count against the proposed station mask
Figure 1. How a station reaches its homography slot, and the two ways of saying which slots are filled. The key is the channel set on the base station; nothing depends on arrival order.

Indexing is by channel, end to end. Each LH2 channel uses two LFSR polynomials; the decoder takes basestation = selected_polynomial >> 1 (DotBot-libs bsp/nrf/lh2_default.c:379) and uses that index for the period table (:109-126) and for the homography it applies (:454-456). db_lh2_store_homography() writes slot basestation_index (:462-473). So a homography sits in the slot of its station's channel minus one, never in arrival order, and the bootloader's raw-count drain tags each read with the same index (swarmit device/bootloader/Source/localization.c:111-125). Figure 1 traces it.

The "sequence" comes from a count, in three places. The calibration message carries homography_count and homography_index (swarmit device/network_core/Source/protocol.h:208-215); the net core zeroes the table on index 0, takes the count as the number of slots and commits to flash when index == count - 1 (network_core/Source/main.c:596-635); the config page and the shared struct store a count and a dense array (main.c:50-61, :205-241, bootloader/Source/ipc.h:89-95); and localization_init() loads slots 0 to count - 1 (localization.c:46-56). The host enforces the consequence: pushable_stations() refuses any set that is not exactly 0, 1, ..., N-1 (PyDotBot dotbot/calibration/lighthouse2.py:402-422), for the OTA push and for the baked config page alike (dotbot/firmware/flash.py:175, :197).

What happens with channels 3 and 9 today. Collect solves stations 2 and 8 and writes them; push and bake refuse the file with "stations must be numbered from zero without gaps". The working answer is to set the stations to channels 1 and 2. Renumbering the file by hand would be wrong, not just untidy: the robot would apply station 2's homography to channel 1's counts, computed with channel 1's period.

The firmware would actually tolerate gaps. If the host sent count 9 with zero matrices in slots 0, 1 and 3 to 7, a zero homography gives 0/0, a NaN, and the fence rejects it because it is written as a negated conjunction (localization.c:91-97). That is nine 84-byte messages for two stations, and it relies on a NaN.

One real bug the gap case exposes. localization_get_position() solves with the lowest-index station that has a fresh sweep pair and stops there (localization.c:73-80), without checking that the station has a homography; lh2_calibration_complete[] is set by the store and read nowhere on this path. A station that is visible but not calibrated (a neighbour room's, a newly installed one, a zero-padded gap) at a lower index than the calibrated one wins the solve, yields NaN, and the call returns no fix even though a calibrated station had fresh data. It also leaves the other stations' flags set, so a later call can use a stale pair.

Verdict on Question A

Not a real constraint: an artifact of a count-based encoding, enforced on purpose by the host because the count would otherwise claim slots nothing filled. Calibrations are indexed by LH2 channel, so channels 3 and 9 are fine on the decoder side. The fix is small (a station mask instead of a count, phase 3), and it comes with one genuine bug fix: the solve must skip a station with no homography (phase 4). The likelier real-world failure is naming: the station console says channel 1 to 16, the decoder index 0 to 15 (section 13).

04Station model and the intended design

Homographies on the robot now; pose plus corrections recorded as a later option

The choice. A station is an angular camera, so in principle it has a 6-degree-of-freedom pose and known intrinsics, against the 8 of a general homography. The clean-sheet simulation fitted both to the same synthetic spins. With an ideal station the pose model is about twice as accurate for the same data (at 20 spins, 1.5 mm against 3.3 mm). With a 1 % unmodelled sweep-tilt error, about 0.3°, the pure pose model stalls near 5.5 mm while the homography keeps improving (3.1 mm at 20 spins), because its extra freedom absorbs the error; a pose model with one physical correction term recovers the best of both. The bench data say the error is real: b54cb043 implies a camera aspect of 0.902, and forcing identity intrinsics on recorded circles left them 49 mm off (conics plan, section 02).

Decision

Robots keep per-station 3x3 homographies for this implementation: no new robot maths, the push and the solve already speak them, and they absorb the station error the bench has measured. The pose-plus-corrections model (pose per station, factory sweep corrections from the OOTX stream or estimated tilt terms) is a later option, phase 10, built only if phase 7 measures a station model error that the homography leaves in the overlaps and corrections are available to handle it; without corrections it stalls around 5.5 mm and buys nothing.

ProposedAssessmentRefinement
Robots spread over the arena spin and record every station they seeHolds. The calibrate-spin app keeps up to 4 stations per robot, keyed by lh_index in first-seen order (DotBot-firmware apps-sandbox/calibrate-spin/main.c:45, :171-182).Keep the cap at 4. Report a robot that saw more (the fifth is dropped today). Uplink at 4 stations is about 87 chunks sent twice, about 46 s at 3.77 packets/s, inside the 90 s capture timeout.
Robots seeing two stations tie them (shared spin centres)Holds. Each station is first rectified metrically by its own circles, so a tie only has to fix 3 degrees of freedom.One shared circle fixes translation, not relative yaw: the simulation puts a one-circle tie about 20 mm off. Thresholds and the error map in section 05.
Solve one joint calibration, metric via the spin radiusHolds if "joint" means one refinement over everything. The prototype is a star of rigid fits (conics.py:702-750), and its fence is the reference station's field alone.Chaining seeds a joint refinement over all stations (section 06). Fence per station.
Place it on the site with the site editorHolds. Site-editor phase 6 applies one rigid move to a spin calibration; self_defined_site() already moves every station at once.One transform for all stations, per-station rectangles transformed, a placement below zero refused (section 10).
Optionally four robots on known cornersHolds if the corners are the site's extremes; four robots near one station fix position but not yaw.Anchors must span the site (section 11).
Bootloader changes if worth itWorth it: the mask, the calibration id rule, the skip, and later the per-sweep lines.Phases 3, 4 and 5.

05Overlap and connectivity

The station graph, how strong a tie must be, and a predicted error map
Three stations on the floor with spin circles; the graph links stations 0 and 2, and station 8 is an island
Figure 2. The station graph. Nodes are stations; an edge is the set of kept circles both stations saw. The graph depends on where robots stood, not on how the coverage cones overlap: station 8 overlaps station 2 on the floor but only one robot stood in the overlap.

The graph. After each station's own solve and health gate, a circle is identified by its robot and round (name plus round) and an edge between two stations is the set of circles kept by both. Figure 2 shows the case to design for: an overlap on the floor with too few robots in it is an island, not a link.

Spread matters more than count. With shared centres spread over a baseline L and a per-centre disagreement σ, relative yaw is uncertain by about √2·σ/L, and a point at distance r moves by r times that. The clean-sheet simulation of two stations makes it concrete: two shared spins 1.5 m apart leave 0.7 mm of disagreement in the overlap; twenty clustered within 5 cm leave 0.9 mm; two clustered leave 4.2 mm; one leaves about 20 mm. σ on real stations is dominated by sweep-model error, 5 to 7 mm at a view's edge (conics-swarm.html), so real numbers are larger and the ratio between layouts is the point.

  • Hard minimum per link: 2 kept shared circles whose centres are at least 300 mm apart. Below that the link does not exist.
  • Advised per link: 4 or more spread along the overlap band, at least 600 mm end to end. The report warns below it.
  • Per station: 3 kept circles of its own for the closed form (TRACKS_MIN; two give the wrong conjugate pair half the time).
  • Whole graph: every station that kept circles is in one connected component. Loops and hubs beat chains: in the simulation five stations came out at 3.6 mm rms as a chain, 2.9 mm as a star and 2.5 mm as a ring, and a ring with no overlap gave 73 mm, an answer that looks like an answer.

Predicted error map. From the joint solve's Jacobian at the solution, form the information matrix, remove the 3 gauge directions, invert, scale by the residual variance, and push each station's homography covariance onto a 100 mm floor grid inside its rectangle; where several stations cover a cell, combine as 1/σ² = Σ 1/σs². The report prints the worst covered cell and the number of cells over 10 mm, and phase 9 drives robots to where it is worst. It complements, not replaces, the per-link numbers: a link the map says is fine can still be under the hard minimum, which stays a refusal.

An island. When a station kept circles but is not in the main component, the solve refuses to write the file and names it: the station, its neighbours by rectangle overlap, and the instruction to put 2 or more robots, well apart, where it and a neighbour both see them, and run another round. Dropping it is explicit, never a default: --drop-station 8.

06The joint solve

Per-station rectification, a spanning-tree seed, one refinement over everything, then the gauge
Five-stage pipeline: per-station solve, station graph, seed, joint refinement, gauge, fence and error map; then the report
Figure 3. The joint solve. Stage 1 is solve() as it stands on #317; stages 2 to 5 are new. Stage 3 is only the starting point of stage 4.

Joint, not chained. Composing pairwise fits along a chain accumulates error with no check. In the clean-sheet simulation the far end of an 8-station chain fitted on its first station was about 45 mm off, where the joint solution of a 5-station chain fitted globally was about 3.6 mm rms; tripling the shared spins per link barely moved the far end. So the spanning tree is the seed, and the answer is one refinement over every station and every shared circle.

Unknowns. One homography Hs per station (8 degrees of freedom, section 04), and one centre ck per physical circle k, shared by every station that saw it. The radius rk is the track's recorded spin radius (51.4 mm on a v3 unless overridden), identical across stations.

Residual. For every read q of circle k by station s: ‖Hs(q) − ck‖ − rk, in floor millimetres: #317's per-station residual with the centre shared, so a station with no shared circle decouples into today's solve exactly. This residual is validated on hardware for homographies (13 robots, 1.1 mm circle rms). The simulation's warning applies to the pose model: a floor-domain radial residual let its station height collapse to zero, so phase 10 fits in the angle domain. For homographies the guard is a per-station check after the solve: every kept circle keeps an axis ratio of 0.95 or more, and no station's own-circles scale differs from the joint one by more than 2 %. Levenberg-Marquardt on a block-sparse Jacobian (scipy.optimize.least_squares with a sparsity pattern), a robust loss on reads.

Seed. Stage 1 runs solve() per station. Stage 3 takes a maximum spanning tree of the graph weighted by shared count times spread, roots it at the station with the most circles, and composes rigid fits on shared centres (similarity(..., scale=False)).

Gauge. The joint problem is fixed up to one rigid move of the floor. During refinement the root station's rigid part is held by a weak prior; afterwards stage 5 re-frames exactly as free mode does today, over every kept centre of every station: minimum-area rectangle of all centres, the quarter turn that points starting headings along +y, zero at the top-left grown by the axle reach. A single-station run produces the frame it does on #317.

Fence. Each station gets its own rectangle: the axis-aligned box of its kept centres in the final frame, grown by 300 mm, clipped at zero. The global fence is the union. This replaces the prototype's reference-only valid_mm (conics.py:736-750), under which a robot seen only by another station would have every fix rejected.

Gates and refusals. The per-track gates stay (axis ratio, radius spread, read count). A shared circle whose centre two stations place more than 3σ apart after the joint solve is dropped from the tie and named, and the solve repeats, at most 4 rounds. Refused: an island; a link under the hard minimum after gating.

Reported. Per station: kept and dropped circles, rms, rectangle, scale ratio. Per link: shared count, spread, disagreement before and after stage 4, yaw uncertainty. Per loop: closure residual. The error map's worst cell and cells over 10 mm. Link records go in the file, so a reviewer can judge a calibration without re-running it.

07How a robot uses several stations

Phase A: nearest calibrated station. Phase B: every sweep, gated, into the pose estimator
Two panels: today the fix alternates between stations in the overlap; proposed nearest station then per-sweep fusion
Figure 4. A robot crossing a seam. Left, today: the source of each fix alternates in the overlap. Right, proposed: phase 4 takes one calibrated station per fix, phase 5 fuses every sweep of every station in the pose estimator.

Today the firmware neither fuses nor selects. The secure side solves once per swarmit_keep_alive() when sweep data arrived (swarmit device/bootloader/Source/cmse_implib.c:41-57), taking the first station in index order whose sweep pair is fresh (localization.c:73-80). In an overlap the track alternates between two estimates (Figure 4, left). The app's pose estimator gates each fix by Mahalanobis distance (DotBot-libs drv/pose_estimator/pose_estimator.c:320-361), so a disagreement inside the gate is jitter and one outside it is rejected fixes and, eventually, a kidnap.

Phase A, phase 4: nearest calibrated station. Every fresh sweep pair is consumed on every solve; a station without a homography is skipped; a solve outside its own station's rectangle is dropped; among what is left, the station whose rectangle centre is nearest its own solve wins. One station per fix, deterministic, easy to explain and to debug, and it fixes the bug of section 03. The exact rule is frozen in section 09.

Phase B, phase 5: per-sweep fusion. Each sweep is a plane through its station, which a homography maps to a line on the floor. Every line is a scalar measurement of the photodiode position: fused one at a time in the pose estimator, it needs no pairing across stations, weights grazing geometry correctly, and lets the innovation gate reject one bad sweep (a reflection, a collision) while the others outvote it. Per-station health, a running innovation mean and accepted and rejected counts, shows a bumped station (mean drifting from zero) or reflections (high rejection rate). The secure side, which holds the homographies, turns each fresh pair into two floor lines; a pure function in DotBot-libs applies them to the pose estimator with gating and health, host-tested; the dotbot app calls it. Phase A stays as the lower rung: it seeds the estimator, feeds telemetry and the advert, and is what a robot uses whenever the estimator is not tracking. A lone sweep whose plane identity is uncertain is not fused (section 13).

08File, wire and push

What changes, why schema 4, and which images flash together
SurfaceTodayAfter this plan
Calibration fileSchema 3, one valid_mm, tracks keyed by name.Schema 4: a rectangle per station, tracks keyed by name and round, link records; the fence is the union. Schema 3 files are refused.
Message 0xA3 (84 B)Count, index, matrix, fence, site, id; commit on the last index.Same size and type: mask, index, matrix, that station's rectangle, site, calibration id; a session per calibration id; commit when every bit of the mask has arrived.
Config page, ipc_lh2_calibration_tCount, 16 dense matrices, one fence; magic SWRO.Mask, 16 matrices by slot, 16 rectangles; magic SWRP.
Device infolh2_homography_count, uint8.lh2_station_mask, uint16.
BootloaderLoads slots 0..count-1; lowest fresh index wins.Loads by mask; nearest calibrated station (phase 4); floor lines for fusion (phase 5).

Why schema 4. An older reader would push the union as every station's fence and tie circles across rounds by name alone, silently. A version bump makes it refuse instead. Schema 3 files are refused too, by the beta clean-break rule: a corner calibration is re-collected, a spin calibration re-collected or re-solved from its own tracks by a one-off script outside the CLI, never by a compatibility path in the reader.

Push size. 84 B per station, popcount(mask) messages, at most 16 (1,344 B). Channels 3 and 9 cost 2 messages. Every message is identical for every robot, so a broadcast push is possible; this plan does not change how the push addresses robots.

Which images flash together, and in what order

Phases 3 and 4 (one firmware wave): the shared struct and the config page change layout, so the swarmit bootloader and net core are one unit, both by cable, on every robot, in the same visit. No NSC veneer changes, so sandbox apps are not reflashed; confirm against the regenerated cmse_implib.a. Order: (1) install the PyDotBot release first: an old net core reads a mask of stations 0 and 1 as count 3 and never sees index 2, so never commits, and refuses a mask above 16; (2) cable-flash swarmit with the calibration baked into the config page, since the new magic leaves every robot uncalibrated until it holds a new page; (3) push over the air only to robots on the new swarmit.

Phase 5: adds a veneer, so cmse_implib.a is regenerated and veneers may move. Cable-flash the bootloader first, then over the air every sandbox app rebuilt against the new library, in the same visit. An app built against the old library on the new bootloader, or the reverse, is not supported and can call a wrong veneer: never update apps first.

09Frozen interfaces

What the three implementation tracks code against; a change here is a logged plan revision

Frozen 2026-10-02. Tracks add private helpers freely; anything below changes only by a logged revision of this section, because another track depends on it. Station indices are lh_index, 0 to 15, in code, files and wire; user-facing text prints both, "station 2 (channel 3)", with channel = index + 1 to be confirmed on the bench (section 13). Multi-byte fields are little-endian.

9.1 Calibration file, schema 4 (PyDotBot)

schema_version = 4

[metadata]
created_at = "2026-10-02T12:00:00Z"
id = "<64 hex, sha256 of the canonical content, as today>"
robot = "dotbot-v3"
tag = "arena-2st"                    # optional

[site]
name = "c405-arena"
anchor = "free mode: ..."            # FREE_FRAME_ANCHOR, a self-defined anchor, or the site's

[validity]
valid_mm = [0, 0, 6200, 3400]        # union of the station rectangles; uint32 mm, x_min, y_min, x_max, y_max

[[track]]                            # evidence; one per (station, robot, round)
station = 2                          # lh_index 0..15
name = "B4AB5A04DF9E2426"            # robot address
round = 0                            # NEW: collection round, 0-based; a circle is (name, round)
radius_mm = 51.4
turn = 1
count1 = [ ... ]
count2 = [ ... ]

[[station]]                          # one per solved station, sorted by index
index = 2
solved_from = "conics-joint"         # direct | conics-free | conics-joint | conics-anchored
points = 3120
residual_mm = 1.3
valid_mm = [0, 0, 3600, 3400]        # NEW, required: this station's rectangle; site extent for a corner calibration
homography = [[h00, h01, h02], [h10, h11, h12], [h20, h21, 1.0]]   # camera point to frame mm

[[link]]                             # NEW: one per station pair with 1 or more shared kept circles; a < b
a = 2
b = 8
shared = 4
spread_mm = 820.0                    # largest distance between two shared centres
disagreement_mm = 1.9                # rms distance between the two stations' centres after the joint solve
yaw_sigma_mrad = 3.1

Rules: indices unique; every valid_mm has x_min < x_max, y_min < y_max, all within 0 to 232-1; [validity] valid_mm equals the union of the station rectangles; [[link]] present whenever more than one station is solved; everything above enters the id. Placements ([[placement]]) are unchanged from schema 3. Any other schema_version is refused with a message naming re-collection.

9.2 Message 0xA3 (host to net core, unicast or broadcast)

Preceded by the type byte 0xA3; the 84-byte payload, offsets from its first byte. The C struct stays swrmt_lh2_calibration_data_t, with fields renamed as below and _Static_assert(sizeof == 84) kept.

OffsetSizeFieldMeaning
04uint32 station_maskbit i set: station i is in this calibration. Bits 16 to 31 must be 0; 0 is invalid.
44uint32 station_indexthe station this message carries, 0..15; its bit must be set in the mask.
836float homography[3][3]row-major, float32, camera point to frame mm.
4416uint32 valid_mm[4]this station's rectangle: x_min, y_min, x_max, y_max, mm.
6016char site_name[16]ASCII, NUL-padded; identical in every message of a push.
768uint8 calibration_id[8]first 8 bytes of the file id: the session key (the clean-sheet design's constellation id). Identical in every message of a push.

9.3 Net-core session and commit rule (swarmit network_core)

// RAM only; lost on reboot, which discards a half-received push
static struct { bool open; uint32_t mask; uint32_t received; uint8_t id[8]; } _lh2_session;

on 0xA3:
  drop unless status == SWRMT_APPLICATION_READY and length >= 1 + 84
  drop unless mask != 0, (mask >> 16) == 0, index <= 15, (mask >> index) & 1
  if !open or id != session.id or mask != session.mask:
      open = true; session.mask = mask; session.id = id; received = 0
      zero the RAM copy of homographies[16][3][3] and valid_mm[16][4]
  copy homography and valid_mm into slot index        // a repeated copy is idempotent
  received |= 1 << index
  if received == mask:
      config.station_mask = mask; config.site_name, config.calibration_id from the message
      commit the page and reboot (as _commit_config_and_reboot today)

A message from another push (another id or mask) restarts the session, so a half-received push never mixes two solves; the page is only written when one push is complete.

9.4 Config page and shared struct (swarmit, both cores; PyDotBot bake)

swarmit_config_t offsetSizeField
04magic = 0x57535250 ("SWRP"); any other value: page has no calibration
44has_net_id (unchanged)
84net_id (unchanged)
124station_mask (replaces homography_count; 0 = uncalibrated)
16576float homographies[16][3][3], by slot; slots outside the mask are ignored
592256uint32 valid_mm[16][4], by slot
84816char site_name[16]
8648uint8 calibration_id[8]
_Static_assert(sizeof(swarmit_config_t) == 872); fits the 2 KB page. PyDotBot's SWARMIT_CONFIG_* offsets and CONFIG_MAGIC_BY_ROLE["dotbot-v3"] follow.

ipc_lh2_calibration_t (both copies of ipc.h): uint32 station_mask at 0, float homographies[16][3][3] at 4, uint32 valid_mm[16][4] at 580, char site_name[16] at 836, uint8 calibration_id[8] at 852; _Static_assert(sizeof == 860), 4-byte aligned in ipc_shared_data_t. The net core copies the page into it at boot exactly as today, with the mask in place of the count.

9.5 Device info (swarmit; PyDotBot parser)

swrmt_device_info_pkt_t: uint8 lh2_homography_count becomes uint16 lh2_station_mask at the same position (offset 152, now 2 bytes, so lh2_flags moves to 154), size 179, info_version incremented. SWRMT_LH2_FLAG_VALID is set exactly when the mask is non-zero. ipc_device_info_t gets the same field, padded to keep sizeof % 4 == 0. The host prints the stations a robot holds as indices and channels.

9.6 Bootloader load and phase A selection (swarmit localization.c)

void localization_init(float homographies[][3][3], uint32_t station_mask,
                       const uint32_t valid_mm[][LH2_VALID_MM_LEN]);
  // stores slot i for every bit i of the mask; a rectangle of all 0xFF reads as the default
  // (0, 0, LH2_VALID_MM_MAX_DEFAULT, LH2_VALID_MM_MAX_DEFAULT); the global fence is the union

bool localization_get_position(position_2d_t *position):
  best = none
  for i in 0..15 with both sweeps of i fresh:
      consume both flags of i                       // every fresh pair, every call: nothing stale is used later
      if !(station_mask >> i & 1): continue          // the skip: no homography, no solve
      p = H_i(camera_point(count1, count2, i))
      if p is not finite or p outside valid_mm[i]: continue
      d = |p - centre(valid_mm[i])|
      if best is none or d < best.d: best = (p, d)    // ties keep the lower index
  if best is none: return false
  publish best.p                                    // inside the union by construction

9.7 Phase B: floor lines, fusion and the veneer (DotBot-libs, swarmit, DotBot-firmware)

/* DotBot-libs drv/lh2_geometry.h: no hardware calls, host-testable */
void db_lh2_camera_point(uint32_t count1, uint32_t count2, uint8_t station, double cam[2]);
  // the pinhole formula now in bsp/nrf/lh2_default.c:438-452, moved here; lh2_default.c calls it

typedef struct {      // naturally aligned, like lh2_raw_sample_t: the secure side stores through a veneer
    float   nx, ny;     // unit normal of the floor line, frame axes
    float   d_mm;       // the photodiode satisfies nx*x + ny*y = d_mm
    float   var_mm2;    // variance along the normal, from DB_LH2_SWEEP_SIGMA_RAD through H
    uint8_t station;    // lh_index 0..15
    uint8_t sweep;      // 0 or 1: which tilted plane
    uint8_t _pad[2];
} db_lh2_floor_line_t;  // _Static_assert(sizeof == 20) and offsets: part of the NSC ABI

uint8_t db_lh2_sweep_lines(uint32_t count1, uint32_t count2, uint8_t station,
                           const float homography[3][3], db_lh2_floor_line_t out[2]);
  // 2 on success, 0 when degenerate; the two lines intersect at H(db_lh2_camera_point(...))

/* DotBot-libs drv/lh2_fusion.h: no hardware calls, host-testable */
#define DB_LH2_FUSION_STATIONS (16U)
#define DB_LH2_FUSION_GATE     (10.83f)   // chi-square, 1 dof, 99.9 %
typedef struct {
    float    innovation_mean_mm;   // EMA of the signed innovation, alpha 1/16
    uint16_t accepted;             // saturating counters
    uint16_t rejected;
} db_lh2_station_health_t;
typedef struct {
    db_lh2_station_health_t station[DB_LH2_FUSION_STATIONS];
    float gate;
} db_lh2_fusion_t;
void db_lh2_fusion_init(db_lh2_fusion_t *fusion);
db_pose_estimator_result_t db_lh2_fusion_update(db_lh2_fusion_t *fusion, db_pose_estimator_t *est,
                                                const db_lh2_floor_line_t *line);

/* DotBot-libs drv/pose_estimator.h: new entry point beside db_pose_estimator_update() */
db_pose_estimator_result_t db_pose_estimator_update_line(db_pose_estimator_t *est, float nx, float ny,
                                                         float d_mm, float var_mm2, float gate);
  // scalar gated update of h(x) = n . (axle + lever(theta)), with the same fix-age forward move;
  // REJECTED unless TRACKING (seeding and LOST keep using phase A fixes)

/* swarmit cmse_implib.h: new veneer; the secure side writes two lines per fresh calibrated pair */
uint8_t swarmit_localization_get_lines(db_lh2_floor_line_t *lines, uint8_t max);
  // drains up to max lines produced since the last call; buffer of 8 (4 stations x 2)

9.8 Python: data model, joint solver, report, push, placement (PyDotBot)

# dotbot/calibration/lighthouse2.py
CALIBRATION_SCHEMA_VERSION = 4
TrackSample.round: int = 0
StationSolution.valid_mm: tuple[int, int, int, int]            # required in schema 4
@dataclass
class LinkRecord: a: int; b: int; shared: int; spread_mm: float; disagreement_mm: float; yaw_sigma_mrad: float
Calibration.links: list[LinkRecord]
def station_mask(calibration: Calibration) -> int
def pushable_stations(calibration) -> list[StationSolution]    # sorted; refuses > 16 or index > 15; no gap rule
def calibration_messages(calibration) -> list[bytes]           # one 84-byte 9.2 payload per station, index order

# dotbot/calibration/multi_station.py (new)
LINK_SHARED_MIN = 2;  LINK_SPREAD_MIN_MM = 300.0
LINK_SHARED_ADVISED = 4;  LINK_SPREAD_ADVISED_MM = 600.0
RECT_MARGIN_MM = 300;  ERROR_MAP_CELL_MM = 100.0
@dataclass(frozen=True)
class CircleKey: name: str; round: int
@dataclass
class StationGraph:
    stations: list[int]; links: list[LinkRecord]; components: list[list[int]]
@dataclass
class ErrorMap:
    origin_mm: tuple[float, float]; cell_mm: float
    sigma_mm: np.ndarray            # (rows, cols), NaN where no station covers the cell
    worst_mm: float; cells_over_10mm: int
@dataclass
class JointSolution:
    homographies: dict[int, np.ndarray]        # 3x3, H[2,2] == 1
    centres: dict[CircleKey, np.ndarray]
    rectangles: dict[int, tuple[int, int, int, int]]
    valid_mm: tuple[int, int, int, int]        # union
    field_mm: tuple[int, int]
    graph: StationGraph
    loops: list[tuple[list[int], float]]       # station cycle, closure residual mm
    station_rms_mm: dict[int, float]
    scale_ratio: dict[int, float]
    dropped: dict[CircleKey, str]              # circles dropped from ties, and why
    error_map: ErrorMap
class MultiStationError(ValueError):
    islands: list[int]; weak: list[LinkRecord]

def station_graph(tracks: Mapping[int, Sequence[Track]]) -> StationGraph
def solve_joint(tracks: Mapping[int, Sequence[Track]], *, margin_mm: float | None = None,
                rect_margin_mm: int = RECT_MARGIN_MM, drop: Collection[int] = ()) -> JointSolution
    # Track gains key: CircleKey; raises MultiStationError on an island or a link under the minimum
def multi_station_report(calibration: Calibration, joint: JointSolution | None = None) -> list[str]
    # the report lines; from the file's stations, links and tracks when joint is None

# dotbot/calibration/conics.py
def solve_calibration(samples, site, robot=ROBOT_DEFAULT, tag="", drop_stations=()) \
        -> tuple[Calibration, JointSolution, dict[int, str]]       # unsolved stations and why

# dotbot/calibration/placement.py (new; used by site init, reframe of a spin calibration, the editor)
@dataclass(frozen=True)
class Rigid2D:
    dx_mm: float; dy_mm: float; theta_deg: float    # rotate about the frame origin, then shift
    def matrix(self) -> np.ndarray
def place_calibration(calibration: Calibration, site: Site, transform: Rigid2D) -> Calibration
    # T @ H for every station, normalised; each rectangle becomes the box around its turned corners,
    # rounded outwards; union recomputed; tracks and links copied; new id.
    # ValueError if not free-mode (FREE_FRAME_ANCHOR or self-defined) or any rectangle reaches below 0.

9.9 Site editor routes (PyDotBot site_editor.py, console-web)

GET  /api/calibrations                 -> [{"id", "id8", "created_at", "free": bool, "stations": [int]}]
GET  /api/calibrations/{id}            -> {"id", "id8", "free", "fence": [x0, y0, x1, y1],
                                           "stations": [{"index", "channel", "rect": [x0, y0, x1, y1],
                                                         "centres": [[x, y], ...]}],
                                           "links": [{"a", "b", "shared", "weak": bool}]}
POST /api/calibrations/{id}/place      {"dx_mm", "dy_mm", "theta_deg"}
                                       -> 200 {"id", "path", "push": "dotbot swarm calibrate-lh2 push <id> --site <name>"}
                                       -> 422 {"detail": "<place_calibration's message>"}

The editor never picks the newest calibration: the operator chooses one from the list. Rotation snaps to 90° (Alt for free); scale has no handle.

9.10 CLI (PyDotBot)

Frozen for phase 1: dotbot swarm calibrate-lh2 collect --spin runs the joint solve whenever more than one station is seen and prints multi_station_report(); --drop-station N, repeatable. Not frozen: the phase 2 names (--append ID for another round, calibrate-lh2 report ID), which go through the cli-naming skill first; the site editor does not depend on them.

10Placing it on a site

Site-editor phase 6, with every station moving as one rigid body

Site-editor phase 6 (plans/site-editor/plan.html) loads a spin calibration as an overlay, lets the operator drag it and rotate it, locks scale because the file is metric through the spin radius, and on Save applies the rigid move and writes a new calibration. For several stations: the overlay draws every station's spin centres and rectangle, one colour per station, labelled "station i (channel i+1)", with the links drawn faintly so a weak tie shows on the map; one transform is applied to every homography, never one per station, which would undo the solve; a turned rectangle is saved as the box around it, which only grows; a placement that puts any rectangle below zero is refused because positions are uint32; and the save goes through place_calibration(), the same code as site init --from-calibration, so command and editor cannot disagree. Robots receive homographies already in site coordinates and never apply a site transform themselves. A corner-collected or anchored calibration is tied to the floor and the editor refuses to move it.

11Anchoring to the room (optional)

Robots on known points fix the gauge for every station at once; they must span the site

When a true lab frame is wanted, robots standing on known points (the four field corners by role, or --anchor ADDR=X,Y, as the conics plan's phase 6 proposes) add residuals Hs(qa) − pa for every station that sees anchor a. Two anchors fix the rigid move; every further anchor is a residual, the only absolute-accuracy number the system can print without a camera. Anchors must span the site: four robots in one corner fix position but determine yaw over a short baseline, and a small yaw error becomes a large one at the far end; put them at the ends of the longest path through the station graph. The fit is rigid only. The spin radius sets scale, and a consistent scale error in the anchor residuals is a finding (radius wrong, slip bias, floor not flat), reported as a ratio, never absorbed.

12How it gets validated

Synthetic fixtures and host tests for the code; the bench for anything on a robot

Python, synthetic fixtures (phases 1, 3, 6). A generator places N stations (the c405 station inverted from b54cb043, plus moved and rotated copies with a 0.9 aspect on one image axis), drops 51.4 mm spin circles, keeps the reads each station sees inside a reach and view cone, adds 1 to 3 mm point noise. Each case a test:

  • two stations, 4 shared circles spread: both map a grid to the same points within 1 mm at 1 mm noise;
  • a chain against a ring of five: the ring's worst station error is below the chain's, and the joint solve beats chaining alone at the chain's far end;
  • an island and a one-circle link: MultiStationError naming the station; drop= writes the rest;
  • shared centres under 300 mm apart: not a link;
  • the error map: predicted σ against the Monte Carlo spread over 20 seeds, within a factor of 1.5;
  • stations 2 and 8: solved, written as schema 4, encoded as two 9.2 payloads with mask 0x0104, and a baked 9.4 page decodes back to the same slots;
  • a single station: the same homography and frame as #317's solve_calibration() to 0.1 mm;
  • appended rounds: circles keyed by name and round; a schema 3 file refused;
  • place_calibration(): a two-station fixture turned 90° and shifted lands where expected within 0.1 mm, rectangles as boxes, a placement below zero refused.

C, host tests (phase 5). DotBot-libs make test: db_lh2_sweep_lines() lines intersect at H(camera point) within 0.01 mm over random counts; db_lh2_camera_point() matches the values lh2_default.c produced before the move; db_pose_estimator_update_line() converges on synthetic lines from two stations crossing a seam, gates an outlier line, and its seam step is under the phase 4 nearest-station step; health counters and the innovation mean behave on a biased station. Phases 3 and 4 have no host test (swarmit has no host-side C harness): their check is the build with the new static asserts, and the bench.

Only the bench can prove: that a mask push stores and loads the right slots on a real net core and that an interrupted push leaves the old page; that a robot under a second, uncalibrated station keeps its fix; the per-station fix rate with two or three stations visible, since sweeps collide on one photodiode; the seam disagreement and step against the field camera; whether overlap circles seen obliquely pass the axis-ratio gate; and whether channel equals index + 1.

13Decisions and open questions

Defaults taken so implementation can proceed, and what is still open
QuestionDecision, 2026-10-02
Schema 3 files under a schema 4 readerRefused (beta clean break). Re-collect, or re-solve a spin file from its tracks with a one-off script.
Rectangle margin300 mm around a station's kept centres; phase 7 measures whether it is right.
Link thresholdsHard minimum 2 shared circles at least 300 mm apart; advise 4 over 600 mm.
Stations per robotThe firmware's existing ceiling, unchanged: 16 stored (LH2_BASESTATION_COUNT, every channel), 4 recorded per spin by calibrate-spin.
FusionNot optional: phase 4 (nearest calibrated station) then phase 5 (per-sweep fusion).
Station modelHomographies on the robot; pose plus corrections is phase 10, gated on phase 7.
Second base station for the benchUnknown; phase 7 is left to the developer.
TrackerA checklist on DBK-182, written when Jira is reachable.
  1. OOTX: does the decoder capture the station's slow OOTX stream (factory sweep corrections and serial number)? If not, is reading them over USB once at install an acceptable substitute? Phase 10 depends on it, and a serial would let the host key stations by serial with the channel as an attribute.
  2. Real station model error after the pinhole fix, in the overlaps: phase 7 measures it; it decides phase 10.
  3. Floor flatness: does one plane hold at millimetre level across the arena and a whole floor? A spatial pattern in the seam disagreement is the signature.
  4. Sweep collision rate on the TS4231 front end with 3 to 4 stations in view, and whether the decoder rejects garbled sweeps rather than emitting a wrong angle.
  5. Channel naming: settle "channel 1 to 16" against "index 0 to 15" once, across the station console, decoder, file and UI. This plan uses index in code and prints both; channel = index + 1 is to be confirmed on the bench.
  6. Lone sweeps: can a single sweep's plane identity be trusted (the decoder assigns sweep slots by timing, and the pair formula swaps them by count order, lh2_default.c:446-450)? Until it can, phase 5 fuses pairs as two scalar lines.

14Phases

Three tracks in parallel against section 09; the bench closes them
Phase dependencies: 1 feeds 2, 3, 6, 8, 9; firmware 3, 4, 5 in sequence; 4 and 5 feed the bench run 7, which gates 10
Figure 5. Phases and their order. Host track: 1, 2 (and 3's encoding). Firmware track: 3, 4, 5. Site-editor track: 6, which needs 9.8's place_calibration() and site-editor phase 6. Phase 7 needs a second base station.
Phase 1Joint solve, report and error map ~3 daystestsDone

PyDotBot, host track, on top of #317. 9.1 schema 4 read and write; 9.8 multi_station.py (graph, seed, joint refinement, gauge, rectangles, error map, report) and the new solve_calibration(); collect --spin printing the report, --drop-station. Push stays dense-only until phase 3 lands its encoding.

Deliverable + check One PyDotBot PR. pytest dotbot/tests/test_calibration_multi_station.py → the section 12 Python cases except push, bake and placement pass; test_calibration_conics.py passes with the single-station parity case.
Log
  • - planned. Starting point is solve_calibration() on lh2-conics @ 827a807, whose star alignment and reference-only fence this phase replaces.
  • - revised after the clean-sheet design: chaining is the seed only, the error map joins the report, the Python API is frozen in 9.8.
  • - in review as PyDotBot #322 (branch lh2-multi-joint, on PyDotBot main @ 9cad08f, which has #317). Joint refinement is a numpy Levenberg-Marquardt with an analytic Jacobian and Huber weights (no scipy dependency); the error map uses the information matrix scaled to unit diagonal with its 3 smallest directions dropped. Tests: 18 in test_calibration_multi_station.py plus 2 two-station collect --spin runs over a faked swarm; full suite 1730 passed. Evidence: two stations agree within 1 mm across the overlap at 1 mm noise; predicted sigma against 20 noisy solves has a median ratio of 1.07; with weak ties (2 spins 400 mm apart per overlap) a ring of five drifts 3 to 6 mm end to end against 9 to 28 mm for the chain, and the joint solve beats chaining down the ring in every seed tried; with strong ties per-station shape error dominates and ring and chain are within noise, which the error map shows too. Single-station parity is exact (0.0 mm) against main's solver on a real 13-robot calibration (86b6d38a), whose tracks are now a test fixture; the stored file itself was made by an older branch and differs from both. Deviations from 9.1/9.8, all additive or interpretations, none touching the wire: JointSolution gains solutions, unsolved, seed_disagreement_mm, warnings (and in phase 8 anchor_residuals, anchor_scale_ratio); Track gains round with key a property, and CircleKey lives in conics.py, re-exported by multi_station, to avoid an import cycle; station_graph() takes the per-station solutions as an optional argument; one station returns free mode's own solve rather than running the refinement, which is what makes parity exact; MultiStationError is raised for islands only, a weak link between stations tied some other way being reported, and the island message names neighbours by shared circles, since an untied station has no frame for rectangle overlap; the 2 % scale and 0.95 axis-ratio checks are report warnings; the file id stays 16 hex characters as today (9.1's example says 64); [[link]] is required only when two or more spin-solved stations are present. site init --from-calibration: the field is recomputed from the stored tracks (the file no longer carries it, the fence now being the union of rectangles), each station's rectangle moves with it, and the placed fence is that union rather than the whole site.
  • - independent review of the host stack, fixes pushed (lh2-multi-joint @ 53aed73). (1) The refinement built a dense Jacobian, reads by parameters: 652 MB for 200 robots over two stations and 4 GB for 500 over four, out of reach of a 1,000-robot floor; the normal equations are now assembled per block (8 station + 2 centre columns per read), same answers, 57 MB and 113 MB, 61 s down to 15 s. (2) When the last tie round still untied circles, the solution kept them tied while the report listed them untied: with one round allowed, 8.3 mm of overlap disagreement; the solve now re-runs after the last untie, and the post-untie island check uses the root's component. (3) A link's yaw sigma came from post-fit residuals, which a two-circle tie leaves near zero ("0.1 mrad" on a weak 350 mm link, against about 4 mrad from sqrt(2) sigma / L); the per-axis noise is now floored at TIE_SIGMA_FLOOR_MM. Each fix has a test that fails without it; the block normal equations are checked against a finite-difference Jacobian. Refuted or left: schema 4 round trip, schema 3 refusal and the file rules hold; the error map's gauge is a minimum-norm choice in the scaled metric, not exactly stage 5's frame, left as designed. Full suite 1733, CI green on the head.
  • - converge: done, merged as PyDotBot #322 on 2026-10-16 (8d2e4ac) and released in PyDotBot 0.34.0. Later changes to the solve rode other PRs in the same release: collect --spin leaves out the circles that keep the rest from solving (#347) and refuses before flashing, confirming calibrate-spin by digest (#348).
Phase 2Rounds and the report command ~1 daytestsDone

PyDotBot, host track. Another round appended to a calibration, and the report printed from a file, after the cli-naming skill (names in 9.10 are proposals) and a persona-review read of the report.

Deliverable + check A PyDotBot PR on phase 1. pytest ... -k "append or report" → passes; the report command on a phase 1 fixture prints the station and link tables with no broker running.
Log
  • - planned.
  • - in review as PyDotBot #323, stacked on #322. Names after the cli-naming skill: dotbot swarm calibrate-lh2 show CALIBRATION rather than report, since the CLI's read-only inspectors are list/show; collect --spin --append CALIBRATION, since add already means copying something handed over (site add). show recomputes the error map from the file. An appended file does not inherit the old tag, so tag lookups stay unique; a placed or corner calibration cannot be appended to. Corner stations print as "4 marked points" (persona read: "0 circles" was misleading). Tests: 5 new; full suite 1735. Run for real in a throwaway home: show on a synthetic channels 3 and 9 file and on the real calibration re-solved from its tracks.
  • - rebased onto the reviewed phase 1 (lh2-multi-rounds @ 3b887b1); no finding of its own. show run in a throwaway home on the real 86b6d38a re-solved from its tracks, on a synthetic channels 3 and 9 file and on a weak two-circle file; a schema 3 file is refused with "collect the calibration again". Full suite 1738, CI green.
  • - converge: done, merged as PyDotBot #323 on 2026-10-16. In 0.34.0 a placed calibration also records placed_from, so --append names the calibration to extend (#343), and calibrate-lh2 place --to-calibration (#344) moves a newer free-frame round onto the calibration a site already uses.
Phase 3Station mask, calibration id and rectangles on the robot ~3 daystestsDone

swarmit (firmware track): 9.2 message, 9.3 session and commit, 9.4 page and shared struct with magic SWRP, 9.5 device info, 9.6 localization_init() by mask. PyDotBot (host track): 9.8 station_mask(), calibration_messages(), the 9.4 page in flash.py, the device-info parser. Flash order in section 08 goes in both PR bodies.

Deliverable + check swarmit and PyDotBot PRs. Firmware: dotbot fw build for the bootloader and net core → both build with the new static asserts (872, 860, 84, 179). Host: pytest ... -k "mask or push or bake or device_info" → the stations 2 and 8 case passes. On the bench (phase 7): a 2-station push leaves lh2_station_mask = 0x0104, and a push cut after one message leaves the previous calibration in place.
Log
  • - planned.
  • - revised: the calibration id in every message is now the session key (9.3); the runtime selection moved to its own phase 4.
  • - split between tracks: the host track also owns swarmit's Python half of 9.2 and 9.5 (swarmit/testbed/protocol.py PayloadCalibrationData and PayloadDeviceInfo, helpers.py reading schema 4, the dashboard's display of the mask, their tests), in its own swarmit PR; the firmware track owns the C under device/. No change to section 09.
  • - firmware half in review as swarmit #173: 9.2 message, 9.3 session as a pure lh2_session.c, 9.4 page and shared struct (872, 860), 9.5 device info (179, version 4), 9.6 load by mask; static asserts on every size and offset; bootloader and net core build (Debug; Release net core hangs in segger-cc on mari, as on main). Host half still open, so the phase stays building. The firmware track had also written swarmit's Python half before the split above reached it; dropped from its PRs, kept on the local branch lh2-multi-python-reference (410ef4c, 33a74fe) for the host track to compare. The shared wire fixture there encodes the host track's schema 4 file with mask 0x3.
  • - host half in review as PyDotBot #324 (stacked on #323) and swarmit #175 (swarmit's Python), so the phase is in review. PyDotBot: 0xA3 by mask with each station's rectangle, pushable_stations() without the gap rule, the 9.4 page (SWRP, 872 bytes, network id under the new magic), push --dry-run, stations named by index and channel, console reading lh2_station_mask; push.DEVICE_INFO_VERSION_MIN and the console's minimum raised to 4, so a robot that would read a mask as a count is refused. swarmit: PayloadCalibrationData fields renamed station_mask/station_index (its site_fields property becomes push_fields: mask, site, id), device info 4 with the uint16 mask at 152, send_lh2_calibration validating mask, order, non-empty rectangles and identical push fields, helpers.py reading schema 4, summaries such as "stations 2, 8 (channels 3, 9; valid, from flash)". Matches the firmware track's reference branch in substance. Per the firmware track's review: the shared wire fixture (identical in both repos) is now stations 2 and 8 with different rectangles, and an empty per-message rectangle is refused. Tests: a hand-built 9.2 buffer for stations 2 and 8 byte for byte; solve, file, payloads with mask 0x0104 and a baked page decoding back slot by slot; both packers byte-identical on real files; PyDotBot 1740 passed, console 818 passed plus build and lint, swarmit 240 passed plus dashboard build. Found, not changed: the app advertisement's calibrated byte covers stations 0 to 7 only, so stations 8 to 15 never show there (the controller's "holds stations the calibration does not solve" warning cannot see them); the firmware track may want to widen it.
  • - independent review of the firmware half and swarmit #175. No byte mismatch: 0xA3 (84, offsets 0/4/8/44/60/76), the page (872), ipc_lh2_calibration_t (860, identical in both ipc.h copies) and device info 4 (179, mask at 152, flags at 154) agree between C, swarmit's Python and PyDotBot. The session rule holds for partial pushes, repeats and interleaved ids (a second push restarts the session; two pushes racing can starve each other but never mix). Fixed in the PRs: the advertisement's calibrated field is now a uint16 (DotBot-libs 0197692, DotBot-firmware bd04ac2, PyDotBot f501452e on #324): with one byte, a calibration naming station 8 or above made the controller read every sandbox robot's not-applicable 0xFF as missing it and resend homographies on each advertisement, a defect and not only a display limit. The not-applicable value is 0xFFFF, the advertisement is 43 bytes, DB_CONTROL_ABI_VERSION is 3 and PyDotBot's vendored wasm is rebuilt from DotBot-libs 0197692 (to rebuild from #42's merge commit). doc/wire-protocol.md and doc/swarmit.lua describe the new 0xA3 and device info 4 (swarmit e17ed8b on #173). PyDotBot p8 and p9 still need a rebase onto the new #324 head: they hold another agent's unpushed commits, so this review left them alone; the rebase has no overlapping files.
  • - CI on swarmit #173 failed build-bootloader-and-sample (dotbot-v3, Debug): .data no longer fits FLASH1 with CI's SES, here and on the previous head 05e5427, because the decoder's build-for-size change only reached swarmit through #174's dotbot-libs bump. The bump commit moved from #174 into #173 (now 3837a9a; #174 is its one producer commit, 20bb3a2, tree unchanged), so main never holds #173 without it. #173 now merges after DotBot-libs #42. Local builds of #173's head: bootloader Debug 4.3 KiB free (dotbot-v3), Release 7.4 KiB, every target, net core Debug and the nrf52840dk single-core bootloader also build; sample/cmse_implib.a rebuilds byte-identical.
  • - host review: the advertised one-byte calibrated mask made the controller treat every robot as missing station 8 and above (no LH2 fixes taken, homographies resent on each advertisement, the simulator masked to 0xFF too); fixed by the firmware review's 16-bit commit, rebased in onto the reviewed phases 1 and 2 (lh2-multi-mask @ c1006ed). 0xA3 bytes for stations 2 and 8 and the 872-byte page re-checked against 9.2 and 9.4; push --dry-run run on a channels 3 and 9 file. Full suite 1744, console 818 passed and build clean.
  • - CI green on every firmware-track head: DotBot-libs #42 0197692 (style and doc now pass), swarmit #173 3837a9a, swarmit #174 20bb3a2, DotBot-firmware #435 bd04ac2, plus swarmit #175 8019e7a and PyDotBot #324 c1006ed. The host track's own review rebased the PyDotBot stack (p3 to p9, pushed) with the 16-bit mask commit unchanged, so the p8 and p9 rebase noted above is done.
  • - converge: done. Host half merged 2026-10-16 (PyDotBot #324, swarmit #175); firmware half merged 2026-11-09 as swarmit #173 (db0b882), after DotBot-libs #42, and released in swarmit 0.12.0. On robots under lh2-multi-bench: swarmit #176 fixed a HardFault with an uncalibrated second station, and non-dense masks were pushed and read back there (mask 0x11). The 9.4 page checks of this phase's deliverable were not re-run here.
Phase 4Runtime A: nearest calibrated station ~1 daytestsDone

swarmit bootloader, firmware track: the 9.6 selection in localization_get_position(), fixing the section 03 bug. Ships in the same firmware wave as phase 3.

Deliverable + check A swarmit PR (or a second commit series on phase 3's). dotbot fw build → bootloader builds; no host test exists. Bench (phase 7): an uncalibrated third station switched on at a lower channel costs no fix.
Log
  • - planned; split out of phase 3 and made a required phase.
  • - in review in swarmit #173, with phase 3's firmware half: every fresh pair consumed, stations outside the mask skipped, non-finite or out-of-rectangle solves dropped, nearest rectangle centre wins, ties to the lower index; logic in a pure lh2_select.c. Checked by a scratch host harness (30 checks, session and selection). The Debug bootloader keeps 75 bytes of its 56 KiB segment here, against 115 on main.
  • - review: the selection matches 9.6 (every fresh pair consumed, skip outside the mask, NaN and out-of-rectangle dropped, nearest centre, ties to the lower index), no change. Observed, not changed: localization_get_position() now drains every station's fresh pair, so on a calibrated robot running calibrate-spin each swarmit_keep_alive() eats one generation of raw counts for every station, including the one being collected; the loss is one sweep window per keep-alive, small, but the phase 7 collection should not see a lower raw rate than before. Debug bootloader still 1448 B free, Release 4496 B.
  • - converge: done, in swarmit #173, merged 2026-11-09 and released in 0.12.0. The bench plan built and then dropped a mean-of-stations variant of this selection (lh2-multi-bench, 2026-10-14 14:27), so the nearest-calibrated-station rule shipped as designed.
Phase 5Runtime B: per-sweep fusion ~4 daystestsDone

DotBot-libs: drv/lh2_geometry, drv/lh2_fusion, db_pose_estimator_update_line(), host tests (9.7). swarmit: the line producer and swarmit_localization_get_lines(), cmse_implib.a regenerated, DotBot-libs bumped. DotBot-firmware: the dotbot app feeds lines to the estimator while tracking and keeps phase A fixes otherwise; the new cmse_implib.a. Firmware track.

Deliverable + check DotBot-libs, then swarmit, then DotBot-firmware PRs. make -C repos/DotBot-libs test → the new fusion and geometry tests pass with the existing ones; dotbot fw build dotbot → the app links against the new library. Bench (phase 7): seam steps below phase 4's on the same walk.
Log
  • - planned; was an optional mean-of-stations phase, now per-sweep fusion with gating and health, required.
  • - revision of 9.7 by the firmware track, behaviour only: layouts and signatures are unchanged, so the host track is unaffected. (1) The secure side produces a pair's two floor lines only when that station's own solve lies inside its rectangle, not for every fresh calibrated pair: outside it the homography is extrapolating, the case the rectangles exist to cut. (2) db_lh2_floor_line_t's normal, whose orientation 9.7 left open, points the way the line moves as its sweep angle grows; with an arbitrary sign the two sweeps of a turned station cancelled in the innovation mean. (3) The estimator records a line's squared distance in a new last_line_d2, beside last_innovation_mm, and leaves last_d2 to fixes, which the bench telemetry reads against the 2-dof gate.
  • - in review: DotBot-libs #42, swarmit #174 (stacked on #173), DotBot-firmware #435. Beyond 9.7: the app reaches the estimator through a new db_control_lines() in the control core, which withholds the tick's fix only when every line was accepted, so the fix's 2-dof gate and the kidnap check still see a jump along one line's direction (a review caught the first version, which withheld it on any accepted line). The Debug bootloader overflowed its segment by 2.5 KiB, so the LH2 decoder and geometry libraries are built for size in every configuration (1.4 KiB free after). The secure stack grows to 2 KiB for the line solve under swarmit_keep_alive. Host tests: geometry parity and line properties, fusion gating, health, seam step, heading on a straight and a spin, line age, kidnap and reflection interplay; mutations of the heading Jacobian, the age move and the control rule were checked to fail. DB_LH2_SWEEP_SIGMA_RAD is a placeholder for phase 7.
  • - review: the veneer checks the app's buffer with cmse_check_address_range (non-secure, read-write) and the struct's alignment; the ring is touched only from swarmit_keep_alive() and the drain, both the app's main context, not from the SPIM ISR; the committed cmse_implib.a in swarmit and DotBot-firmware is byte-identical to a fresh build and lists the 16 veneers of cmse_implib.h; the scalar update's Jacobian, Joseph form, gate and forward move check out. Fixed: DotBot-libs CI style (clang-format 18 reformats two test lines differently from 15) and doc (the two new groups missing from the Sphinx toctree), squashed into the commits that introduced them. Recommendation, not changed: DB_LH2_SWEEP_SIGMA_RAD is compiled into the secure image, so retuning it after phase 7 costs a cable flash of every robot; an app-side variance scale in db_lh2_fusion_t would make it an OTA change. Also for the bench: the LH2 decoder's Release build moved from O2 to Os, and it runs in the SPIM interrupt. All SES targets of the three firmware PRs rebuilt (DotBot-libs every target, DotBot-firmware bare and sandbox, swarmit bootloader Debug and Release, net core Debug), zero warnings.
  • - converge: done. DotBot-libs #42 (228ce9a), swarmit #174 (6a6857f) and DotBot-firmware #435 (9e1d6a8) merged 2026-11-09 in that order and released in DotBot-libs 0.6.0, swarmit 0.12.0 and DotBot-firmware 1.26.0. What merged differs from the 2026-10-04 heads: DotBot-firmware #435 grew from +12 / -7 to +336 / -11 (the app fusing the lines of every calibrated station), after the fusion work of lh2-multi-bench; DotBot-libs #43 keeps a bimodal sweep out of the fix, bumped in by DotBot-firmware #439. The merged code is authoritative where it departs from section 9.7.
Phase 6Place a multi-station calibration on a site ~2 daystestsSuperseded

PyDotBot, site-editor track: 9.8 placement.py (also used by site init and by reframe of a spin calibration), the 9.9 routes, the console-web overlay of section 10. Builds on site-editor phase 6 (PyDotBot #315 and #317 first); can start against fixtures before phase 1 merges.

Deliverable + check A PyDotBot PR. pytest ... -k place → the placement cases of section 12 pass; npm --prefix repos/PyDotBot/dotbot/console-web run build clean (vitest does not typecheck). By hand: BROWSER=true dotbot site edit <name> --headless, load a two-station fixture, turn it 90°, save; a new id appears beside the untouched original.
Log
  • - planned; waits on site-editor phase 6.
  • - built together with site-editor phase 6 and in review as PyDotBot #326, against schema 3 on main with the 9.8 and 9.9 shapes: placement.py with Rigid2D and place_calibration(calibration, site, transform), used by the editor, by reframe of a spin calibration and by site init; the three routes with fence, stations (index, channel, rect, centres) and links (weak from multi_station's advised thresholds, read only when a file has links). A station's valid_mm, when present, is boxed after the turn and the fence is their union; a centre or rectangle below zero is refused; links are copied. The overlay draws every station in its colour, labelled "station i (channel i+1)", and links faintly, a weak one dashed. Divergences from 9.8: free mode is read from the stations' solved_from (conics-free, conics-joint), not the anchor, because a placed file carries its site's anchor and must stay movable; place_calibration adds keyword-only reanchor (the site-editor plan's explicit Re-anchor of a corner calibration) and taken_tags; the 200 body also carries the overlay and warnings. Tested with a two-station fixture whose stations carry their own rectangles (a test-only subclass, since schema 4's data model is not on main): both stations' centres land within 0.1 mm after a 90 degree turn and offset, rectangles boxed, fence the union, below-zero refused; the schema 4 file itself is untested until the host track's model lands. No multi-station solver file was edited.
  • - superseded here, not merged. #326 was closed and folded unchanged into PyDotBot #315 (the site editor, open, with #327 and #345 stacked on it), so placement in the editor is the site-editor plan's to land. What did ship for placement is the CLI side: site init --from-calibration carries the spin radius (#342) and calibrate-lh2 place --to-calibration (#344).
Phase 7Two-station bench run ~1 bench daySuperseded

No repo; left to the developer, since a second base station is not known to be available. A second station on a non-adjacent channel per conics-swarm.html; collect in two rounds; push by mask; then the camera comparison, the seam walk with phase 4 and with phase 5, the per-station fix rate with one and two stations visible, the uncalibrated-station skip, an interrupted push, and whether channel equals index + 1. Sets the link thresholds and the rectangle margin as constants, and measures the station model error that decides phase 10.

Deliverable + check A logged run in this phase following dotbot-hil-validate (localization). Pass: joint positions within 10 mm rms of the camera over both halves after the best rigid move; seam steps under the pose estimator's gate; no fix lost to the uncalibrated station; the interrupted push leaves the old calibration.
Log
  • - planned; needs a second LH2 base station on the arena.
  • - superseded by lh2-multi-bench, which ran the two-station bench bring-up on 2026-10-14 (phases 1 to 4 there, logged by the bench agent): station restarts with no crash, LH1 calibrated from LH0, spin calibration of both stations on full overlap, non-dense channels, fusion against nearest-centre. Its partial-overlap and lab-scale phases carry what this phase listed and that run did not cover (the camera comparison over both halves, the interrupted push). Not counted as hil evidence for this plan, since the runs are logged there.
Phase 8Anchors in the joint solve ~1 daytestsOptionalDone

PyDotBot: anchor residuals in solve_joint() on the conics plan's anchored mode; a warning when anchors do not span the site (their spread under half the union's diagonal); per-anchor residuals and the scale ratio in the report.

Deliverable + check pytest ... -k anchored_multi → four spread anchors split across two synthetic stations recover the true frame within 2 mm at 1 mm noise, and four clustered ones trigger the warning.
Log
  • - planned.
  • - in review as PyDotBot #325, stacked on #324. Shipped as a rigid post-fit rather than residuals inside the refinement: an anchor is a spin whose pivot sat on a known point (Anchor(CircleKey, point_mm)), and the free joint solution is moved by the best rigid motion onto the anchors, which is what section 11's "fit is rigid only, scale never absorbed" asks; the scale ratio comes from the best similarity. solve_joint() and solve_calibration() gain an anchors= argument; CLI collect --spin --anchor ADDRESS=X,Y, two or more; stations saved as conics-anchored with the site's own anchor. Tests: four corner anchors over two stations land within 2 mm rms of the true floor at 1 mm noise with no alignment; clustered anchors warn; 1 % mis-spaced marks report ratio 1.01; refusals; one end-to-end CLI run. Full suite 1746.
  • - review fixes (lh2-multi-anchors @ 74a26b1): an anchor address not among the robots ready to spin is now refused before the spin rather than after the 90 s capture, and matched case-insensitively to the spun robot's name; anchors that put a station's rectangle below the site's zero are refused by name instead of writing a file the reader refuses. Full suite 1752.
  • - converge: done, merged as PyDotBot #325 on 2026-10-16 and released in 0.34.0. This also covers the conics plan's optional anchored mode (its phase 6), which is marked superseded there.
Phase 9Active collection ~3 daystestsOptionalDone

PyDotBot, later: after a first round, take the cells where the error map is worst and the links under the advised strength, and drive robots that already localise under one station to the far ends of those overlaps for another round. The operator scatters robots once; the system fills the gaps, which is the testbed's second priority.

Deliverable + check In simulation, driving to the suggested cells shrinks the worst predicted error faster than the same number of random spins (pytest ... -k active); then one bench round.
Log
  • - planned, from the clean-sheet design.
  • - the planner in review as PyDotBot #331, stacked on #325; driving the robots there is not built. next_round() proposes the two far ends of every overlap whose link is missing or under the advised strength, then the worst error-map cells (400 mm apart, 150 mm inside a rectangle); show CALIBRATION --next-round N prints them in the calibration's frame. In simulation (two stations tied by two spins 350 mm apart), four spins where suggested leave a lower worst predicted error than four random spins averaged over five draws. The bench round is left for phase 7. PyDotBot's simulator models LH2 only as noisy position fixes, with no stations, sweeps or homographies, so these runs use the synthetic station model of the tests rather than dotbot run simulator.
  • - review fixes (lh2-multi-active @ 4f6668e): show --next-round refuses a placed, anchored or corner calibration, since --append would refuse the round it plans, and names stations by index and channel. Run on the weak two-circle file: the overlap ends come first, then the worst cells. Full suite 1756.
  • - converge: done, merged as PyDotBot #331 on 2026-10-16 (c715d7d). Driving robots to the suggested cells is still not built.
Phase 10Pose-plus-corrections station model unsizedOptionalPostponed

Later, and only if phase 7 measures station model error the homography leaves in the overlaps, and sweep corrections are available (open question 1). Pose plus physical corrections per station, fitted in the angle domain; robots carry pose records; the fusion's line model changes underneath an unchanged db_lh2_fusion_update(). Without corrections the simulation stalls near 5.5 mm and it is not worth building.

Deliverable + check A plan revision first: this phase gets its own design and interfaces when it is taken up.
Log
  • - recorded, gated on phase 7.
  • - postponed. Gated on phase 7 measuring station model error in the overlaps; the bench run that replaced phase 7 (lh2-multi-bench) did not establish that need, and sweep corrections (open question 1) are still unavailable. Resume with a plan revision if the lab-scale calibration shows overlap error the homographies leave.

15Risks

What could go wrong, and what only hardware can settle
  • Decode rate with several stations visible. One photodiode receives every station's sweeps; with two or three in view, collisions lower each station's fix rate and the spin's read count. Phase 7 measures it; the 12-read minimum per track and the innovation gate are the guards.
  • Overlap circles at shallow angles. The far station sees an overlap circle obliquely, where the sweep model is worst. If those circles fail the axis-ratio gate, links starve. Place stations so the overlap band is in both stations' good cone; the report shows per-station kept ratios.
  • Homography error in the overlaps. Each station's homography bends independently where it is extrapolating, which is exactly where seams are. The rectangles limit it, phase 5's gating and the error map expose it, and phase 10 is the cure if it matters.
  • Chains of many stations. On a seven-station floor without loops, yaw error compounds. The report's per-link numbers and the error map show it; the fix is a station that closes a loop or a hub, not more spins.
  • Rollout. Phase 3 changes the config page and phase 5 the veneers; section 08 gives the order. Every robot is uncalibrated between the cable flash and its new page unless the calibration is baked in.
  • Mixed host and firmware. Not supported, by policy. A mismatch fails as a refused or never-committed push, not a wrong calibration.
  • Three parallel tracks. They meet at section 09. A track that needs a change there logs a revision of the section and tells the others, rather than diverging locally.