Skip to content

thonmay/Obstacle-Map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Occupancy Grid Mapping with Ultrasonic Sensors

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.

Final Map

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)

Core Concepts Implemented

  • 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.yaml file. 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 the yaml-cpp dependency.

How to Build and Run

This project uses CMake for building.

Prerequisites

  • A C++17 compatible compiler (like GCC, Clang, or MSVC)
  • CMake (version 3.14 or newer)
  • Git (required by CMake to fetch a dependency)

Build Steps

  1. Clone the repository:

    git clone https://github.com/thonmay/Obstacle-Map
    cd Obstacle-Map
  2. Configure the project with CMake:

    # Create a build directory
    mkdir build
    cd build
  3. Compile the code:

    cmake ..
  4. Run the application: The executable will be inside the build directory.

    make
    ./mapper_app

    The program will read the configuration from config/config.yaml, process the data, and save the final map as occupancy_map.png in the map directory.

Running the Tests

A small, predictable test case is included to verify the core geometric and mapping logic. To run it:

  1. Temporarily change the CONFIG_PATH in src/main.cpp to point to ../config/test_config.yaml.
  2. Re-compile and run.
  3. A test_map.png will be generated, which validates the coordinate transformations and grid updates.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published