Transfer collision detection optimizations from arjo129/mapf_post - #44
Conversation
7e862f4 to
3e125d4
Compare
|
@arjo129 I believe we are sticking to the sweep line solution. I think this one is fairly good because we are doing it across the axis with maximum spread. Should I try experimenting with integrating the AABB tree approach I mentioned? I think we can still get a better performance |
|
Sure! |
|
Heyy @arjo129 . AABB tree performs kind of poorly with robots under 5k robots. there is a 1.5x improvement with the tree only after 16k robots. I think it is probably due to the data structure construction and indexing itself being time consuming compared to a simple sweep line sort. Given that practically the numbers should be much lesser, can we just merge the PR with the sweep line solution? |
|
Yes. I'd recommend going for the sweep line solution. But if you have an implementation of the AABb being worse it'd be awesome to share it. |
|
Sure I do. I'll just clean up the code and push it here in a while. |
8cb67c1 to
0a679ec
Compare
|
Heyy @arjo129. I have a tiny update. So I tested previously with my own implementation of AABB tree which led to it being slower. Testing it with parry2d crate's implementation works better though. They have simd optimizations. Can we move with the AABB tree implementaton then? |
|
I will just try to fix the style check for now |
|
1,10,50 are important benches and then also trajectory lengths are important. |
|
Ohkk yes il add that too |
|
Also for the genAI tool, we are required to use the Assisted by: attribution, so it'd be good if you just filled in which genAI tool you used. |
|
Yepp just added the attribution. thanks for reminding |
These are the results for robots against path length. I kept path length kind of small but i think its O(NT) which matters so it should scale accordingly. |
|
Is the implementation and testing fine now? |
|
Could you check the benches in as well so I can replicate it on my end?? |
|
The results can be gotten through the command |
|
Ah got it. I'll take a look. I dont think that we should be using test for this, but we should be using |
|
Ohhh I see. Thanks, il switch over to cargo bench then. |
Signed-off-by: uday-kalyan-s <udaykalyansreenivasa@gmail.com>
Signed-off-by: uday-kalyan-s <udaykalyansreenivasa@gmail.com>
Signed-off-by: uday-kalyan-s <udaykalyansreenivasa@gmail.com>
Signed-off-by: uday-kalyan-s <udaykalyansreenivasa@gmail.com>
Signed-off-by: uday-kalyan-s <udaykalyansreenivasa@gmail.com>
c170c4f to
ef4339b
Compare
|
Hi. Sorry for the delay. @arjo129 You can try testing it with cargo bench now |
New feature implementation
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.
Implementation description
The broad phase mirrors the approach already used in the sibling
mapf_postcrate: 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, viaparry2d::query::cast_shapes_nonlinear) that used to run on every pairunconditionally.
Changes:
mapf/mapf/src/post/mod.rs: replaced the brute-force Type‑2 edge loop inmapf_postwith the sweep-and-prune broad phase.mapf/mapf/src/post/mod.rs(sweep_line_testsmodule): added testscomparing 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.
GenAI Use
We follow OSRA's policy on GenAI tools
Assisted by: Claude Sonnet 5