Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary Occupancy Grid Implementation #23

Conversation

shantanuparabumd
Copy link

PR Description: Binary Occupancy Grid Implementation

Overview

This PR introduces a BinaryOccupancyGrid class that provides a grid-based representation of the environment for autonomous vehicle path planning and simulation. The implementation supports obstacle modeling, clearance handling, and visualization, making it a robust foundational tool for tasks like path planning, collision avoidance, and trajectory generation.

Key Features

1. Grid-Based Representation
  • The grid is created based on user-defined limits (x_lim, y_lim) and resolution.
  • Each cell in the grid represents a specific region of the map, allowing for spatial discretization.
  • Resolution determines the granularity of the grid: higher resolution captures finer details but requires more memory.
2. Obstacle Handling
  • Supports adding obstacles with attributes such as position (x, y), dimensions (length, width), and rotation (yaw).
  • Obstacles are represented in the grid with values corresponding to their presence.
3. Clearance Space
  • Clearance is calculated as a combination of obstacle clearance and an additional buffer to ensure safe navigation.
  • Clearance is marked distinctly on the grid for visualization purposes, providing a clear separation between free space, clearance zones, and obstacles.
4. Visualization
  • Utilizes a custom colormap to visually distinguish:
    • Free space: White.
    • Explored nodes: Light blue.
    • Path: Green (if integrated with a path planner).
    • Clearance zones: Gray.
    • Obstacles: Black.
  • Users can save the grid as an image (.png), JSON (.json), or binary NumPy file (.npy).
5. Obstacle Modeling
  • Obstacles are defined using corner-based calculations and transformations to account for rotation (yaw).
  • Efficient marking of grid cells within obstacle and clearance boundaries using polygon-based collision checks.
6. Map Saving
  • The grid map can be saved in multiple formats:
    • PNG: For visualization.
    • Numpy Binary (.npy): For programmatic reloading.
    • JSON: For sharing or debugging.

Usage Instructions

Input
  1. Map Configuration:

    • Provide x_lim and y_lim to specify map boundaries.
    • Set the grid resolution to control cell size.
    • Specify a clearance value for obstacle and vehicle safety.
  2. Obstacles:

    • Define obstacles with attributes like position, length, width, and yaw.
    • Add obstacles using an ObstacleList object.
Example
obst_list = ObstacleList()
obst_list.add_obstacle(Obstacle(State(x_m=10.0, y_m=15.0), length_m=10, width_m=8))
obst_list.add_obstacle(Obstacle(State(x_m=40.0, y_m=0.0), length_m=2, width_m=10))

bin_occ_grid = BinaryOccupancyGrid(MinMax(-5, 55), MinMax(-20, 25), resolution=0.5, clearance=1.5)
bin_occ_grid.add_object(obst_list)
bin_occ_grid.save_map("map.json")
Output
  • A saved grid map in the specified format (e.g., JSON, PNG).
  • Visualized grid showing free space, obstacles, and clearance zones.

@ShisatoYano ShisatoYano added the enhancement New feature or request label Jan 27, 2025
@ShisatoYano ShisatoYano linked an issue Jan 27, 2025 that may be closed by this pull request
@ShisatoYano
Copy link
Owner

This PR can not be accepted because the previous commits for A star path planning implementation are also included. You need to recreate a new PR and it should include changes only for Binary Occupancy Grid Map implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implementation of A-Star Algorithm
2 participants