Skip to content

swarmit/testbed: carry LH2 stations by mask in calibration and device info - #175

Merged
geonnave merged 2 commits into
DotBots:mainfrom
geonnave:lh2-multi-host
Oct 16, 2026
Merged

geonnave merged 2 commits into
DotBots:mainfrom
geonnave:lh2-multi-host

Conversation

@geonnave

@geonnave geonnave commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

The host half of storing LH2 stations by a 16-bit mask instead of a dense count, so a robot can hold the stations on, say, channels 3 and 9 without anything in slots 0 to 7. Today send_lh2_calibration refuses anything but stations 0 to N-1, and device info reports a count.

Wire, as the new bootloader and net core expect it (byte-for-byte with PyDotBot's packer):

  • 0xA3 calibration message, still 84 bytes: u32 station_mask (bit i = station i, bits 16-31 zero) at 0, u32 station_index at 4, the float32 matrix at 8, this station's own u32 valid_mm[4] at 44, site name at 60, calibration id at 76. One message per station in index order; the mask, site and id are identical across a push.
  • Device info 4, 179 bytes: lh2_homography_count (u8) becomes lh2_station_mask (u16) at offset 152, so lh2_flags moves to 154.

Host behaviour.

  • send_lh2_calibration checks a push is one push: a mask naming 1 to 16 stations below 16, messages carrying exactly the mask's stations once each in index order, a non-empty rectangle in each, the same mask, site and id in every message.
  • helpers.read_lh2_calibration_payload reads calibration schema 4 (each station's own valid_mm is required), builds the mask from the station indices, and refuses an index outside 0 to 15 or a duplicate. Schema 3 files are refused.
  • DeviceInfo.lh2_summary names stations by index and channel, e.g. stations 2, 8 (channels 3, 9; valid, from flash); the fleet table's cell lists the indices. Robots below device info 4 read as firmware to reflash.

Flash together. This only talks to a bootloader and net core built for the station mask (config page magic SWRP); those come by cable, both images on every robot in one visit, and nothing should be pushed over the air to a robot that has not been reflashed. Install this host first: an old host would send the old count format, which the new net core cannot commit. PyDotBot's matching change (schema 4 files, mask messages, the baked page) is in DotBots/PyDotBot#322 and the PRs stacked on it.

Validation. Host only: 240 passed (pytest swarmit/tests), including the shared wire fixture pinned in both repos (stations 2 and 8 with different rectangles, so keying by position or sending the union in every message fails it), an empty rectangle refused, stations 2 and 8 going out under mask 0x0104, the refusals above, the device-info layout at offsets 152-155, and an emulated node's mask surviving the round trip. The calibration files PyDotBot writes produce identical bytes through both packers. Dashboard frontend builds; pre-commit clean.

File + -
swarmit/testbed/controller.py +43 -35
swarmit/testbed/helpers.py +43 -35
swarmit/testbed/protocol.py +21 -23
swarmit/tests/lh2_wire_fixture.py +32 -22
swarmit/tests/test_controller.py +53 -31
swarmit/tests/test_helpers.py +47 -10
swarmit/tests/test_protocol.py +19 -15
5 small files: swarmit/cli/main.py, dashboard/frontend/src/App.tsx, tests/test_client.py, tests/test_webserver.py, tests/utils.py +15 -12
Total, 12 files +273 -183

… info

Breaking, cross-repo: matches a bootloader and net core that store
stations by mask (device info 4, 179 bytes) and PyDotBot's schema 4
calibration files; robots below device info 4 read as firmware to
reflash, and schema 3 files are refused.

AI-assisted: Claude Opus 5.5
@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 (db07551) to head (8019e7a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #175      +/-   ##
==========================================
- Coverage   91.30%   91.04%   -0.27%     
==========================================
  Files          27       27              
  Lines        5082     5124      +42     
==========================================
+ Hits         4640     4665      +25     
- Misses        442      459      +17     

☔ 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.

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