Implementation code for our paper "Crowd-FM: Learned Optimal Selection of Conditional Flow Matching Trajectories for Crowd Navigation" (arXiv:2602.06698), accepted to IEEE ICRA 2026. This repository contains the Crowd-FM code for training and testing the conditional flow-matching (CFM) policy and the learned trajectory scoring function in its pedsim/Gazebo human-robot interaction simulator. Please note that this open source version directly uses accurate pedestrian states from the simulator (via pedsim ground-truth tracks) instead of a detection-and-tracking pipeline, as in the paper.
Crowd-FM is a learning-based local planner for safe, human-like navigation in dense, unstructured human crowds, built on two components:
- Conditional Flow-Matching (CFM) policy trained over a dataset of optimally controlled (multi-modal, collision-free) trajectories — a diverse set of collision-free primitives available in any scenario. The CFM policy alone navigates collision-free with a higher success rate than existing learning-based baselines.
- Learned score function trained on human demonstration trajectories, scoring flow primitives by human-likeness — selecting the highest-scoring trajectory at inference. It picks trajectories closer to expert data than a manually designed cost function.
With inference-time refinement, Crowd-FM outperforms even expensive optimisation-based planners.
This repository contains the complete pipeline in a single catkin package:
flownav/— the ML core (vendored Python package): flow-matching trajectory generator (PyTorch Lightning), transformer trajectory scoring function, Bernstein polynomial trajectory representation, JAX-based PRIEST refinement, dataset processing and training/inference tools.src/,launch/,helper_scripts/,rviz/,benchmark/— the ROS interface and evaluation stack: a ROS1 node that runs the models online, pedsim simulation launches, and the benchmark harness.
This repo merges the former flownav and flownav_pkg repositories.
- ROS1 (Melodic/Noetic) with a catkin workspace
- pedsim_ros_with_gazebo
(
pedsim_simulator,pedsim_gazebo_plugin,robot_gazebo) for crowd navigation simulation - A conda env with a C compiler available for
torch.compile()(conda install -c conda-forge gcc gxx)
mkdir -p ~/crowd_fm_ws/src && cd crowd_fm_ws/src
git clone https://github.com/Smart-Wheelchair-RRC/crowd-fm.git crowd_fm
cd ~/crowd_fm_ws && catkin_make # run from crowd_fm_ws (the workspace root)
source devel/setup.bashThe ML stack (PyTorch/Lightning/JAX) is best kept in its own conda environment, separate from the system Python that ROS uses:
conda create -n crowd_fm python=3.10
conda activate crowd_fm
# torch.compile() needs an active C compiler inside the env
conda install -c conda-forge gcc gxx
pip install -r ~/crowd_fm_ws/src/crowd_fm/flownav/requirements.txtrequirements.txt installs the ML dependencies (lightning, torch, wandb,
matplotlib, numpy, scipy, ...).
cd ~/crowd_fm_ws/src/crowd_fm
pip install -e flownav/This installs the vendored flownav Python package in editable mode, which
makes the from flownav... imports in src/ros_interface.py resolvable. In
editable mode, changes to the code take effect immediately without
reinstalling.
Weights are gitignored and must be placed in
flownav/flownav/checkpoints/final/:
filtered_dynamic_7.ckpt— flow generatorscoring_best.ckpt— scoring function
Download them from Google Drive and copy both files into that directory.
See flownav/flownav/checkpoints/final/README.md for details and runtime
overrides. To train from scratch, follow flownav/README.md.
source devel/setup.bash
# Crowd navigation (pedsim + Gazebo + Crowd-FM)
roslaunch crowd_fm pedsim_nav.launch # terminal 1
rosrun crowd_fm ros_interface.py # terminal 2
Give a goal in RViz (2D Nav Goal / /move_base_simple/goal); sampled
trajectories and the selected best trajectory are visualized in RViz.
Useful variants:
roslaunch crowd_fm pedsim_nav.launch with_global_plan:=false # local-frame goals
From the flownav/ directory (see flownav/README.md for details):
python -m flownav.tools.train --data_dir <processed_dataset>
python -m flownav.tools.scoring_model_trainer --data_dir <processed_dataset> --flow_model_path <flow.ckpt>
python -m flownav.tools.infer --checkpoint_path <flow.ckpt> --data_dir <processed_dataset>
Dataset roots are passed via CLI flags (no hardcoded paths); SCAND bags can be
converted with python -m flownav.processing.process_bags.
WandB logging is on by default — put your key in flownav/.env:
WANDB_API_KEY=<your-api-key>
WANDB_PROJECT=crowd-fm
source devel/setup.bash && conda activate <your_env>
rosrun crowd_fm benchmark.py
Benchmark worlds/planners resolve sibling packages relative to the workspace
src/ directory; override with CROWD_FM_WS_SRC=/path/to/ws/src if your
layout differs. Results are written to benchmark/statistics/.
If you find this work useful, please cite:
@misc{singha2026crowdfmlearnedoptimalselection,
title={Crowd-FM: Learned Optimal Selection of Conditional Flow Matching-generated Trajectories for Crowd Navigation},
author={Antareep Singha and Laksh Nanwani and Mathai Mathew P. and Samkit Jain and Phani Teja Singamaneni and Arun Kumar Singh and K. Madhava Krishna},
year={2026},
eprint={2602.06698},
archivePrefix={arXiv},
primaryClass={cs.RO},
url={https://arxiv.org/abs/2602.06698},
}