This project is a C++ implementation of a classic robotics task: creating a 2D occupancy grid map from sensor data. The program processes a CSV file containing robot odometry and ultrasonic time-of-flight readings to build a map of an unknown environment.
Here is the final map generated from the provided dataset. The map correctly identifies open areas (white), obstacles (black), and unexplored regions (gray). The arc-shaped artifacts and wall thickness are realistic signatures of the wide-beam ultrasonic sensors used.
(Note: You'll need to run the code once to generate this image in the map directory for it to show up here.You can also change the resolution of the image in the yaml file)
- Occupancy Grid: The map uses a log-odds representation for each cell, which allows for stable, probabilistic updates from noisy sensor data.
- Sensor Model: The 30-degree field of view of the sensors is modeled using multi-beam raycasting. This provides a more realistic "carving" of free space and results in a higher-quality map.
- Data-Driven Design: All key parameters—from map dimensions and file paths to the robot's physical sensor layout—are loaded from a
config.yamlfile. This decouples the algorithm from the configuration, so you can adapt the code to a new robot or dataset without a recompile. - Modern C++ & CMake: The project is built with C++17 and uses CMake (
FetchContent) to manage theyaml-cppdependency.
This project uses CMake for building.
- A C++17 compatible compiler (like GCC, Clang, or MSVC)
- CMake (version 3.14 or newer)
- Git (required by CMake to fetch a dependency)
-
Clone the repository:
git clone https://github.com/thonmay/Obstacle-Map cd Obstacle-Map -
Configure the project with CMake:
# Create a build directory mkdir build cd build
-
Compile the code:
cmake ..
-
Run the application: The executable will be inside the
builddirectory.make ./mapper_app
The program will read the configuration from
config/config.yaml, process the data, and save the final map asoccupancy_map.pngin themapdirectory.
A small, predictable test case is included to verify the core geometric and mapping logic. To run it:
- Temporarily change the
CONFIG_PATHinsrc/main.cppto point to../config/test_config.yaml. - Re-compile and run.
- A
test_map.pngwill be generated, which validates the coordinate transformations and grid updates.