Skip to content

Merge mapf_post into mapf and align types#37

Draft
arjo129 wants to merge 6 commits intomainfrom
arjo/feat/merge-mapf-post
Draft

Merge mapf_post into mapf and align types#37
arjo129 wants to merge 6 commits intomainfrom
arjo/feat/merge-mapf-post

Conversation

@arjo129
Copy link
Member

@arjo129 arjo129 commented Mar 6, 2026

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

  1. Core post Module:

    • Introduced mapf/src/post/mod.rs containing the implementation of the mapf_post algorithm based on the approach described in Hoenig et al., 2019 (https://whoenig.github.io/publications/2019_RA-L_Hoenig.pdf).
    • This algorithm converts time-discretized MAPF results into dependency-based SemanticPlans, which are more resilient to timing delays during robot execution.
  2. Semantic Planning & Following:

    • Added SemanticPlan and SemanticWaypoint types to represent agent-level dependencies.
    • Implemented WaypointFollower to help estimate an agent's progress along its assigned trajectory and identify the next safe waypoint.
  3. Collision Detection:

    • Integrated parry2d-f64 for high-fidelity collision checking between agent footprints during trajectory execution. This replaces simpler time-based checks with geometric sweeps.
  4. Spatial Allocation:

    • Added mapf/src/post/spatial_allocation/mod.rs, which provides a Grid2D and AllocationField system.
    • This system enables the reservation of spatial zones (dynamic safety areas) based on the semantic plan's dependencies, ensuring robots maintain safe separation even when they deviate from the original time-schedule.
  5. Crate Updates:

    • Updated mapf to the Rust 2024 edition.
    • Added new dependencies: parry2d, petgraph, bresenham, rand, and csv to support the new post-processing features.
    • Updated nalgebra to version 0.32.

Implementation Details

  • mapf_post identifies "Type 1" (sequential) and "Type 2" (collision-avoidance) dependencies between waypoints.
  • AllocationField implements tie-breaking rules for spatial reservations, including leader-follower hierarchies and intersection-aware prioritization.
  • WaypointFollower uses projection onto trajectory segments to remain robust against localization jitter or minor navigation errors.

Verification

  • Added unit tests in mapf/src/post/mod.rs covering:
    • WaypointFollower logic.
    • SemanticPlan waypoint and dependency management.
    • Collision detection between moving shapes.
    • Core mapf_post algorithm on a simple cross-junction scenario.
    • Violation checking and claim dictionary generation.

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.

  • I used a GenAI tool in this PR.
  • I did not use GenAI

Generated-by: Gemini-cli

@mxgrey mxgrey added this to PMC Board Mar 6, 2026
@github-project-automation github-project-automation bot moved this to Inbox in PMC Board Mar 6, 2026
@xiyuoh xiyuoh moved this from Inbox to In Progress in PMC Board Mar 10, 2026
arjo129 added 6 commits March 19, 2026 05:00
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>
@arjo129 arjo129 force-pushed the arjo/feat/merge-mapf-post branch from 0d9939c to 26e2496 Compare March 19, 2026 05:00
}

impl Scenario {
pub fn add_mobile_objects_as_agents(&mut self) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is not used anywhere.

pub real_position: (f64, f64),
}
#[derive(Clone)]
pub struct Grid2D {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs

&self,
solution: &NegotiationNode,
timestep: f64,
) -> crate::post::MapfResult {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MapfResult maynot contain the right book keeping structures for name->agentId. We should keep this API private.

&self,
solution: &NegotiationNode,
timestep: f64,
) -> crate::post::SemanticPlan {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SemanticPlan needs some way to map between Agent name and Id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants