dotbot/swarm: add the Swarm API with demos and collision avoidance#276
Open
geonnave wants to merge 44 commits into
Open
dotbot/swarm: add the Swarm API with demos and collision avoidance#276geonnave wants to merge 44 commits into
geonnave wants to merge 44 commits into
Conversation
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
Cancelling pending command tasks on shutdown dropped a final fire-and-forget command (e.g. a closing stop()), leaving a bot driving on its last move_raw. Draining them with a timeout lets the stop land. AI-assisted: Claude Opus 4.8
…n_sdk AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
Two latent bugs surfaced by `--bots`, which generates low leading-zero addresses and leaves direction unset. Frame routing used hex(addr)[2:], dropping leading zeros, so such a bot never matched its own command/uplink frames and ignored waypoints. And the unset-direction sentinel (-1000) reached the control loop as a bogus heading; it now maps to 0 like theta. AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Opus 4.8
AI-assisted: Claude Fable 5
AI-assisted: Claude Fable 5
AI-assisted: Claude Fable 5
AI-assisted: Claude Fable 5
AI-assisted: Claude Fable 5
AI-assisted: Claude Fable 5
AI-assisted: Claude Fable 5
AI-assisted: Claude Fable 5
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #276 +/- ##
===========================================
- Coverage 83.27% 76.66% -6.62%
===========================================
Files 119 158 +39
Lines 11120 13252 +2132
Branches 570 569 -1
===========================================
+ Hits 9260 10159 +899
- Misses 1857 3089 +1232
- Partials 3 4 +1
🚀 New features to boost your workflow:
|
The whole pydotbot package is branded the DotBot SDK, so an sdk subpackage inside it was redundant. swarm names the thing the API drives and deliberately pairs with the dotbot swarm CLI namespace: one fleet, operated from the CLI, driven from Python. AI-assisted: Claude Fable 5
AI-assisted: Claude Fable 5
AI-assisted: Claude Fable 5
AI-assisted: Claude Fable 5
AI-assisted: Claude Fable 5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the Python Swarm API (
from dotbot.swarm import Swarm): a live fleet object over a running controller (REST + ws/status), per-bot verbs (set_color,goto,move_to,follow), fleet handles, events, link-budget pacing of all downlink sends, andswarm.map_size(). Ships adotbot/examples/sdk_demo/suite (LED + motion demos) meant to run unchanged in the simulator and on the testbed.The centerpiece is collision avoidance. Motion demos used to command straight lines through occupied space; real robots collide. The SDK now offers it at two levels:
Swarm.connect/run(..., collision_avoidance=True)(or the--collision-avoidanceflag injected bySwarm.run): every motion command is shepherded through buffered Voronoi cells (Zhou et al., RA-L 2017) - each bot only ever steps inside the region closer to it than to any neighbour, shrunk by a safety buffer, plus arena-wall planes. Needs positions only (the 2 Hz LH2 feed; no velocity estimates), emits exactly one waypoint per bot per tick, paced to the gateway downlink budget. Separation is the guarantee; arrival stays best-effort (TimeoutErrorsurfaces blocked goals).stop()/move_raw()bypass it.dotbot.swarm.avoidexposes the pure geometry (bvc_waypoint,safe_hop) for custom control loops.The shepherd is grounded in firmware behavior: DotBots arc while turning (never pivot), a waypoint within the threshold is "already reached" and moves nothing, positions glitch, and a gateway sustains ~80 cmd/s. Hence the heading-aware yield/short-bite turning rules, the scaled hop thresholds with a 60 mm floor, the LH2 glitch gate in
Bot, and the contact guard that stops a bot pinned against a neighbour instead of letting it grind.Also fixes a controller crash seen with ~50 real bots: concurrent
notify_clientstasks writing the same websocket trip an AssertionError deep in the websockets protocol; sends are now serialized per connection and a failing client is dropped instead of killing the controller.Validated in the simulator with a collision monitor that interpolates between position samples (zero collisions across all motion demos, including an all-cross swap benchmark with naive user code), plus short metric runs on the real ~56-bot fleet that drove the tolerance work. 427 unit tests pass, including the BVC geometry and position-gating suites.
Note: the package was renamed from
dotbot/sdk/todotbot/swarm/within this PR - "SDK" names the whole pydotbot package in the docs branding, so adotbot.sdksubpackage was redundant.dotbot swarm(CLI, fleet ops) andSwarm(Python, fleet control) intentionally share the noun: one fleet, two rungs;dotbot swarm --helpnow points at the Python rung.