A Python class for aligning and fusing two binary occupancy maps using a genetic algorithm. It includes additional methods for comparison using cross-correlation and ORB+RANSAC-based alignment.
- Genetic algorithm-based optimisation for translation and rotation.
- Fitness function using Normalised Cross-Correlation (NCC) for robust evaluation of overlapping areas.
- Edge-weighted IoU available for additional metric analysis.
- Fused map generation after alignment.
- Alternative alignment methods:
- Cross-correlation
- ORB keypoints + RANSAC
- Python 3.7+
- NumPy
- SciPy
- scikit-image
- OpenCV
- Matplotlib
- PIL (Pillow)
- IPython (for Jupyter notebook display)
Install dependencies:
pip install numpy scipy scikit-image opencv-python matplotlib pillow ipythonfrom genetic_fusion import GeneticMapFusion
ref_map = ... # Binary 2D numpy array
target_map = ... # Binary 2D numpy array
fusion = GeneticMapFusion(ref_map, target_map)best_params = fusion.evolve(
tx_range=(-20, 20),
ty_range=(-20, 20),
theta_range=(-15, 15),
fitness_threshold=0.80,
min_generations=30,
max_generations=1000
)fused_map, ref_canvas, target_canvas = fusion.fuse_maps_aligned(best_params)- Cross-Correlation:
params_cc = fusion.align_with_cross_correlation()- ORB + RANSAC:
params_ransac = fusion.align_with_ransac()best_params:[tx, ty, theta]transformation to aligntarget_maptoref_map.fused_map: Combined occupancy map with partial transparency (0.5) in overlapping areas.- Optional visualisation using
matplotlib.pyplot.imshow.
- Input maps must be binary numpy arrays.
- Performance depends on image quality, overlap, and initial parameter ranges.
- The evolutionary method is slower but more robust for maps with partial overlaps or low keypoint matches.
We provide the ROS 2 node to test directly the algorithm reading occupancy grid maps from two different topics (robot 1 and robot 2). These topics are named /map1 and /map2, be sure to change the name if topics are named differently. Fused map is published to /fused_map
map_fusion_ga/
├── map_fusion_ga/
│ ├── init.py
│ ├── fusion_node.py
│ └── genetic_fusion.py
├── launch/
│ └── fusion.launch.py
├── setup.py
├── package.xml
colcon build
source install/setup.bash
ros2 launch map_fusion_ga fusion.launch.py
CC by 4.0
@misc{https://doi.org/10.5281/zenodo.15696363,
doi = {10.5281/ZENODO.15696363},
url = {https://zenodo.org/doi/10.5281/zenodo.15696363},
author = {Luna, Cristina and Ruiz, Enrique and López, Paula and F. Barrero, David},
title = {Genetic Algorithm-based Map Fusion},
publisher = {Zenodo},
year = {2025},
copyright = {Creative Commons Attribution 4.0 International}
}
Or: Luna, C., Ruiz, E., López, P., & F. Barrero, D. (2025). Genetic Algorithm-based Map Fusion (preliminary). Zenodo. https://doi.org/10.5281/zenodo.15696363