feat(coordinator): add Swarm (PIBT+LNS+BVC) planner and more - #8
feat(coordinator): add Swarm (PIBT+LNS+BVC) planner and more#8BrokenHypocrite wants to merge 1 commit into
Conversation
…y playback, and Play Chess mode A complete, collision-free multi-robot planner plus the coordinator features to use it. Additive: existing planners and the wave-dispatch flow are unchanged when these are not selected. Swarm planner (planning/swarm/, swarm_planner.py, base_planner.produces_trajectory): self-contained PIBT (priority inheritance + backtracking) + MAPF-LNS flowtime refinement + Buffered Voronoi Cell execution. Complete by construction where EnhancedConflictPlanner can get stuck. Registered as 'Swarm (PIBT+LNS)'. plan_moves forward-simulates the pipeline and emits each piece's collision-free sampled trajectory as wave-ordered MoveCommands, with optimal interchangeable-piece assignment and in-bounds waypoint clamping. Smooth trajectory playback (simulation/simulator.py + main_window/path_planning wiring): play_trajectory() advances all pieces in lockstep along the synchronized trajectory (continuous, arc-like, collision-free) then rotates each to its commanded heading. Used automatically for trajectory planners; the discrete wave dispatch is untouched for the others. Play Chess mode (gui/tabs/play_chess_tab.py + chessboard_widget.py): a tab where you click a piece to see legal moves (via python-chess) and click a legal square to move it with the selected planner - captures to graveyard, castling, en passant, and auto-queen promotion via the spare queen. Hot-seat. Board size set to 57.15 mm (2.25 in tournament square): standard sizing, and the clearance the buffered-Voronoi motion needs between ~31 mm pieces to stay collision-free and efficient (see planning/swarm/README.md and config.BOARD). Adds python-chess dependency (requirements.txt). Self-tests: planning/swarm/_selftest*.py, gui/tabs/_selftest_chess.py.
|
This PR mostly just adds an additional path planning algorithm and a way to test it in a Play Chess mode. The one thing I did change is the board's cell size, from 50mm to 57.15mm. There is a massive difference in how easily the planner can route pieces with this change and 2.25in (57.15mm) is a nice size imo since it is tournament size. There is still more improvements that can be made to this planner but I believe it is a good starting point. If you have any questions you can reach me at brokenhypocrite@gmail.com or on discord, username: brokenhypocrite |
DDeGonge
left a comment
There was a problem hiding this comment.
@BrokenHypocrite Hey sorry finally got a chance to test this out. Just want the grid size reverted. Going larger does make path planning much easier, but it also complicates the physical assembly and positioning emag placement options, so for now I need to keep it at 50.
The chess game implementation is great! I had actually found this same library and was planning on doing something similar so this is really appreciated!
I do have some concerns with the path planning alg and changes to playback, in that rotation is instant and it does not have any processing to reduce move count. The curved moves are lovely in simulation but I think in reality the coordinator will struggle to send this many commands to each bot and keep everything in realtime. I will absolutely test this on real hardware once it's ready though. And yours does complete quicker in sim and deadlock far less often than mine which is nice :) Maybe it'll just need some tweaks and filters to complete but I'll see!
Once you make that change I'll merge.
| # resets and dense piece shuffles collision-free and efficient. Measured | ||
| # on scattered-reset benchmarks the larger square markedly improves | ||
| # completion and reduces total travel. See planning/swarm/README.md. | ||
| SQUARE_SIZE_MM = 57.15 # one chess square side length (2.25 in tournament size) |
There was a problem hiding this comment.
Please revert this to 50.0 and adjust the associated comments below
There was a problem hiding this comment.
Understood. I'll try to get to this this weekend.
Swarm planner, trajectory playback, and Play Chess mode
Adds a complete, collision-free multi-robot planner to the coordinator, plus the
features to use it. All additive: existing planners and the wave-dispatch flow are
unchanged unless the new options are selected.
1. Swarm planner (
planning/swarm/,planning/swarm_planner.py)New planner registered as "Swarm (PIBT+LNS)". Self-contained (standard library
plus
planning.base_plannerandconfigonly).8-connected cell grid. Complete by construction: where
EnhancedConflictPlannergets stuck, PIBT makes boxed-in pieces step aside and flow back.
plan_moves()forward-simulates the whole pipeline and returns each piece'sactual sampled trajectory as wave-ordered
MoveCommands, so the open-loop robotsreplay a provably collision-free path.
in-bounds waypoint clamping.
2. Smooth trajectory playback (
simulation/simulator.py)play_trajectory()advances all pieces in lockstep along the synchronizedtrajectory (continuous, arc-like, collision-free), then rotates each to its
commanded final heading.
produces_trajectory(added tobase_planner.py). The existing rotate/translate wave dispatch is untouched forthe discrete planners.
main_window.pyandpath_planning_tab.pyroutes trajectory plannersto the player in simulator mode.
3. Play Chess mode (
gui/tabs/play_chess_tab.py,gui/chessboard_widget.py)New tab. Rules via
python-chess.to the graveyard, castling moves the king and rook, en passant clears the
bypassed pawn, and promotion auto-queens via the spare queen.
4. Board size set to 57.15 mm / 2.25 in (
config.py)Changed
BOARD.SQUARE_SIZE_MMfrom 50 to 57.15 mm for two reasons:the gap between pieces on adjacent squares is only about 19 mm and the
buffered-Voronoi routing deadlocks or detours often. At 57.15 mm (about a 26 mm
gap) dense resets stay collision-free and efficient.
All piece coordinates derive from
SQUARE_SIZE_MM, so they scale together. Therationale is documented in
config.pyandplanning/swarm/README.md.Dependencies
Adds
python-chess(seerequirements.txt, alongsidepyqt6andpyserial).Tests
Headless self-tests, run from
firmware/MiniBot_Coordinator/:python planning/swarm/_selftest.py: plan solved, wave-ordered, collision-free.python planning/swarm/_selftest_playback.py: playback completes, stayscollision-free through interpolation, motion continuous, headings reached.
python gui/tabs/_selftest_chess.py: normal, capture, castle, en passant, andpromotion produce correct targets and dispatch through the planner.
Limitations
second same-side promotion logs a message and keeps the logical board correct).
player is a simulator-playback feature.