Re-discovering basic MAPF (Multi-Agent Path finding) algorithms, and in the process building a simulator + visualizer + robots + planning.
Also to give reasons for paths, might build an inventory management system with Sqlite3/MQTT etc.
Some Concepts used:
- Robot/Agents with move/wait actions (todo: pick/drop)
- 2D gridworld simulator with state detection
- vertex/edge collision of paths
- Aplanner / Space-Time A planner (STA*) / Conflict Based Search (CBS)
- Matplotlib live visualization + animation
- sqlite3 database inventory management
MQTT message passing using local MQTT brokerNo longer needed
To catch up on the current state of multi-robot path planning this repo starts as a sandbox of robots in 2D grid environments pathing around walls and each other.
To create our world, we'll start with a
Then, for each robot, we'll have a
Assuming just one robot, only wall collisions exist. For this type of world where the grid is static and known and heuristics are simple/admissable, path planning with Ain 2D is a decent option.
There's alternatives to consider in the future, Dijkstra variants, bi-directional A, greedy, Detc which have some pros/cons, but these considerations will change as soon as we add robots and change our environment up. For now, A with it's worst case time complexity of something like
Now if we have
A solution is valid if over all the paths, no two paths have a vertex (robot on other robot) or edge (robot swapping other robot) collisions, and no robot ever goes on a wall tile.
An algorithm to find this solution given these inputs is sometimes called a Multi-Agent Path Finding (MAPF) algorithm, and there is quite a variety of them out there optimized for different use-cases. For example; multiple self-driving vehicles, drone swarms, automated warehouse order consolidation, strategy game multi-unit pathing, etc. I particularly enjoyed David Silver's Cooperative Path Planning paper as an overview on this topic. Depending on the world (ex. grid-based/real space/3D/etc.) or knowledge (static known/unknown, fog of war, dynamic etc.) or speed (real-time, fixed, etc.) , the types of MAPF algorithms can vary.
A simple/naive first-pass we'll call MAPF0 is to use A* for each robot with no knowledge of each other, just the grid. For sparse worlds/grids this isn't a problem. One could imagine a few people standing randomly on a football field, and told to go to some other random locations on the field. The likelihood of them colliding is pretty small, even if a few obstacles were places on the field. Now if that same situation happened in a cubicle office, it's very likely there'd be collisions. The big O for this would be
A step up from this is first to define a method to identify collisions, we'll call find_collisions(path1, path2) -> list of collisions
where a
Now in a loop, we update the paths with collisions with a new Asearch that also includes this collision. Note that the collision has a time component, and naive A doesn't use time. We want to be able to path plan with temporary obstacles that happen at certain times, a simple but computationally expensive way to do this is the expand the search space of our grid from
So now, we have our MAPF1 algorithm, where we start with Apaths for each robot, adding these time-based (ie. dynamic) collisions between paths, and then in a loop update those paths with our STA algorithm, using our ever expanding list of dynamic collisions. We keep doing this until no conflicts remain, and we have a valid solution. This is close but not always optimal, as we are arbitrarily choosing which path to update, rather than trying both options in an ever expanding binary tree to get to the optimal solution (todo).
Scale up # of robots from handful to 100's, similarly scale up grid. This'll definitely require going closer to state-of-the-art in CBS etc. Then, transition from known start/goal positions to dynamic/live, ie. new start/goals are requested during computation, call these tasks.
Manage and allocate free robots to tasks as they come up, update MAPF# algorithms to work live, might transition to D* or alternative low-level path finding algorithms at this point - Done
Generate tasks via inventory management system (IMS), possibly extend to ticket/order-based system with grouping/consolidation etc. - Done
Update CBS via:
- A*/STA* use true-path heuristic
- re-org code for cleanliness (separate IMS to other folder)
- Conflict-based search for optimal multi-agent pathfinding Guni Sharon, Roni Stern, Ariel Felner, Nathan R. Sturtevant - Artificial Intelligence, 2015
- Multi-agent path finding with mutex propagation H Zhang, J Li, P Surynek, TKS Kumar, S Koenig - Artificial Intelligence, 2022
- Assignment on MAPF S Koenig
- Cooperative Path Planning David Silver
- SIPP: Safe Interval Path Planning for Dynamic Environments