A ROS plugin and toolset for generating 2D/3D maps from Gazebo world files. This tool allows you to scan Gazebo simulations and export the results as point clouds, occupancy grids, and various navigation-compatible formats.
- 2D/3D Map Generation - Generate both 2D occupancy grids and 3D point clouds from Gazebo worlds
- One-Click Script - Automated script that launches Gazebo, waits for services, and exports maps
- Multiple Output Formats - Exports to PCD, PGM, PNG, YAML, and OctoMap (.bt) formats
- Customizable Resolution - Adjustable scanning resolution for detail vs. performance tradeoffs
- Progress Estimation - Real-time progress tracking with calibration support
- Example Terrains - Included sample terrain models (desert) for testing
- Ubuntu 20.04
- ROS 1 Noetic
- Gazebo 11 (Classic)
sudo apt update
sudo apt install -y libboost-dev libpcl-dev liboctomap-dev# Clone the repository
git clone <repository-url> GM
cd GM
# Source ROS environment
source /opt/ros/noetic/setup.bash
# Build the workspace
catkin_make
source ./devel/setup.bash# Generate a map with default parameters
./generate_map.shThis will:
- Launch Gazebo with the default world file
- Scan the specified area
- Export the map to
kongdi_map.{pcd,bt,pgm,png,yaml}
The generate_map.sh script provides a one-click solution for map generation.
# Default parameters
./generate_map.sh
# Custom world and scan area
./generate_map.sh src/gazebo_map_creator/kongdi.world -30 -30 -1 30 30 8
# Custom resolution and output prefix
./generate_map.sh src/gazebo_map_creator/kongdi.world -25 -25 -3 25 25 10 0.1 maps/kongdi_map脚本行为:
- 启动前清理旧的 Gazebo 进程
- 等待
save_map服务 - 显示估算进度(可通过
EST_STEPS_PER_SEC调整) - 结束后自动关闭 Gazebo
进度估算调优:
EST_STEPS_PER_SEC=380000 ./generate_map.sh| Argument | Description | Default |
|---|---|---|
world_file |
Path to Gazebo world file | src/gazebo_map_creator/kongdi.world |
x_min, y_min, z_min |
Lower-left corner coordinates | -25, -25, -3 |
x_max, y_max, z_max |
Upper-right corner coordinates | 25, 25, 10 |
resolution |
Scan resolution in meters | 0.05 |
output_file |
Output file prefix | kongdi_map |
# Adjust progress estimation speed (default: 380000)
EST_STEPS_PER_SEC=500000 ./generate_map.shUse estimate_steps.sh to auto-calibrate progress estimation for your system.
# Default calibration
./estimate_steps.sh
# Custom parameters
./estimate_steps.sh src/gazebo_map_creator/kongdi.world -30 -30 -1 30 30 8 0.1 maps/kongdi_map
# Adjust calibration fraction (default: 0.5)
CALIBRATION_FRACTION=0.3 ./estimate_steps.shExample world with desert terrain:
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:models
gazebo worlds/desert_mesh.worldTerrain customization:
- Scale: Edit
models/desert_mesh/model.sdf(current:3 3 3) - Position: Edit
worlds/desert_mesh.world - Texture: Replace
models/desert_mesh/materials/textures/sand.png
The map generation produces multiple files:
| Format | Extension | Description |
|---|---|---|
| Point Cloud | .pcd |
PCL point cloud format |
| OctoMap | .bt |
Binary OctoMap for 3D navigation |
| Occupancy Grid | .pgm |
Portable Gray Map format |
| Image | .png |
PNG visualization |
| Metadata | .yaml |
Navigation stack configuration |
GM/
├── README.md
├── generate_map.sh # Main map generation script
├── estimate_steps.sh # Progress calibration script
├── models/
│ └── desert_mesh/ # Example terrain model
├── worlds/
│ └── desert_mesh.world # Example world file
├── src/
│ └── gazebo_map_creator/
│ ├── gazebo_map_creator/
│ │ └── src/gazbeo_map_creator.cpp # Core plugin
│ └── gazebo_map_creator_interface/
│ └── srv/MapRequest.srv # ROS service definition
├── build/
└── devel/
Q: Gazebo fails to start?
Check for existing Gazebo processes:
killall gzserver gzclient gazeboQ: Progress estimation is inaccurate?
Run the calibration script:
./estimate_steps.shOr manually adjust:
EST_STEPS_PER_SEC=380000 ./generate_map.shQ: Compilation errors?
Ensure all dependencies are installed:
sudo apt install -y libboost-dev libpcl-dev liboctomap-dev
source /opt/ros/noetic/setup.bash
catkin_make clean && catkin_makeThis project is inspired by and builds upon ideas from arshadlab/gazebo_map_creator, which provides a ROS 2 implementation.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request