Merge mapf_post into mapf and align types - #37
Conversation
0d9939c to
26e2496
Compare
Generated-by: Gemini-CLI Signed-off-by: Arjo Chakravarty <arjoc@intrinsic.ai>
This adds solve(), derive_mapf_result(), and derive_semantic_plan() to the Scenario struct for tighter integration between MAPF solving and trajectory derivation. Generated-by: Gemini-CLI Signed-off-by: Arjo Chakravarty <arjoc@intrinsic.ai>
…cies This allows obstacles in a Scenario to be represented as agents in the MAPFPost output, enabling traffic dependency analysis for moving objects. Generated-by: Gemini-CLI Signed-off-by: Arjo Chakravarty <arjoc@intrinsic.ai>
- Changed edition to 2021 in mapf/Cargo.toml - Refactored 'let chains' in post module to nested 'if let' blocks - Removed unused petgraph import - Updated formatting across multiple files to match 2021 edition Signed-off-by: Arjo Chakravarty <arjoc@intrinsic.ai>
Signed-off-by: Arjo Chakravarty <arjoc@intrinsic.ai>
Signed-off-by: Arjo Chakravarty <arjoc@intrinsic.ai>
Signed-off-by: Arjo Chakravarty <arjoc@intrinsic.ai>
- Move agent ID assignment from negotiate to derive_mapf_result - Remove id_to_name field from Scenario struct - Change negotiate and Scenario::solve to take shared references - Add agent_name_to_id to MapfResult and SemanticPlan - Add get_agent_id helper to SemanticPlan Generated-by: Gemini CLI Signed-off-by: Arjo Chakravarty <arjoc@intrinsic.ai>
Signed-off-by: Arjo Chakravarty <arjoc@intrinsic.ai>
- Add Grid2D::from_scenario and From<&Scenario> for Grid2D - Correctly calculate grid dimensions and occupancy from Scenario data - Update allocate_trajectory to use dynamic grid dimensions - Add unit test for from_scenario constructor Generated-by: Gemini CLI Signed-off-by: Gemini CLI <gemini-cli@google.com> Signed-off-by: Arjo Chakravarty <arjoc@intrinsic.ai>
1282d90 to
a001f0e
Compare
Proposal to switch to spatial partitioning for broad-phase collision detectionHi! I'm Uday. I had previously submitted a GSoC proposal to work on this PR, and I'm still very interested in contributing to it. As part of that proposal, I planned to implement the MAPF-POST improvements from P3GASUS, which includes replacing the current broad-phase collision detection with a more efficient spatial partitioning approach. Some references I found useful while working on this: One of the earlier blockers was supporting heterogeneous robots (robots with different sizes). That issue has since been addressed by replacing KD-trees with AABB trees in the graph creation pipeline. I implemented and benchmarked this approach here: I believe this work provides a solid foundation for implementing the same idea here. Would it be okay if I started by using this branch in my fork to develop the changes, and later opened a PR targeting the |
|
Hi @uday-kalyan-s upstream (https://github.com/arjo129/mapf_post) already has a broadphase based acceleration. I would encourage you to look at it and implement the same on this branch. |
|
Right yes I found the implementation of the AABB tree there. extremely sorry for my earlier comment. I will get to working on this branch then. |
### Implemented feature Adds an AABB sweep-and-prune broad phase to `mapf::post::mapf_post`'s Type‑2 (cross-agent collision) dependency detection, replacing the previous brute-force O(N²T²) nested-loop check. Also adds Criterion benchmarks so the improvement (and any future regression) is measurable rather than just asserted. <!-- TODO: link the feature-request/tracking issue here, e.g. Closes #XXXX --> ### Implementation description The broad phase mirrors the approach already used in the sibling `mapf_post` crate: for every trajectory segment, compute a merged AABB spanning its start and end pose, pick whichever axis (X or Y) has the larger spread across all segments, sort segments by AABB min on that axis, then sweep with an early-exit break once a later segment's AABB min passes the current segment's AABB max on that axis. Only AABB-overlapping pairs go through the exact continuous collision check (`collides`, via `parry2d::query::cast_shapes_nonlinear`) that used to run on every pair unconditionally. Changes: - `mapf/mapf/src/post/mod.rs`: replaced the brute-force Type‑2 edge loop in `mapf_post` with the sweep-and-prune broad phase. - `mapf/mapf/src/post/mod.rs` (`sweep_line_tests` module): added tests comparing the sweep-line output against a brute-force reference implementation across several scenarios (crossing, following, head-on swap, diagonal, far-apart, unequal-length trajectories), plus a sort-axis-invariance test (X-sort vs. Y-sort scenes must agree). Complexity is unchanged in the worst case (still O((N·T)²) when a scene is AABB-dense on both axes), but substantially better in the common case of spatially separated trajectories, since the sweep prunes the AABB comparisons that no longer need the expensive narrow-phase check. Signed-off-by: uday-kalyan-s <udaykalyansreenivasa@gmail.com> * fixed styling Signed-off-by: uday-kalyan-s <udaykalyansreenivasa@gmail.com> * code cleanup and better benchmarking Signed-off-by: uday-kalyan-s <udaykalyansreenivasa@gmail.com> * moved analysis to cargo bench Signed-off-by: uday-kalyan-s <udaykalyansreenivasa@gmail.com> --------- Signed-off-by: uday-kalyan-s <udaykalyansreenivasa@gmail.com>
Implemented feature
#29
Implementation description
This PR merges the mapf_post functionality into the mapf crate, as tracked in issue #29. This consolidation simplifies the codebase and aligns the types between the core MAPF utilities and the post-processing algorithms used for robust plan execution.
Motivation
Previously, mapf_post existed as a separate utility or was part of an external experimental repository. Merging it into mapf allows for tighter integration with the base traits and types of the multi-agent planning framework, facilitating a more seamless transition from planning to execution-ready semantic plans.
Key Changes
Core post Module:
Semantic Planning & Following:
Collision Detection:
Spatial Allocation:
Crate Updates:
Implementation Details
Verification
GenAI Use
We follow OSRA's policy on GenAI tools
Note the original library doesnt use gen-ai I used gen-ai to see if it could merge the two libraries and reconcile APIs.
Generated-by: Gemini-cli