feat(coordinator): add Swarm (PIBT+LNS+BVC) planner and more#8
Open
BrokenHypocrite wants to merge 1 commit into
Open
feat(coordinator): add Swarm (PIBT+LNS+BVC) planner and more#8BrokenHypocrite wants to merge 1 commit into
BrokenHypocrite 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.
Author
|
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 |
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.
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.