Occupancy Grid¶
Image-based occupancy grid with inflation, collision queries and DDA ray casting.
OccupancyGridMap
¶
Initializes the Occupancy Grid Map from an image.
Source code in src/hivebr/engine/occupancy_grid.py
colors
instance-attribute
¶
colors = (
colors
if colors is not None
else {
"occupancy_inflated": [220, 50, 50],
"occupancy_raw": [50, 100, 255],
}
)
pygame_image
instance-attribute
¶
pygame_image = pygame.transform.flip(
pygame.image.load(resolved_path).convert_alpha(),
False,
True,
)
inflate
¶
Inflates the obstacles by dilating them using the robot's radius. Adds a small safety margin to prevent corner-cutting issues.
Source code in src/hivebr/engine/occupancy_grid.py
add_obstacle
¶
Adiciona um obstáculo circular diretamente na grade de ocupação.
Source code in src/hivebr/engine/occupancy_grid.py
world_to_grid
¶
Converts world coordinates (x, y) to grid coordinates (ix, iy). World origin (0,0) is bottom-left. Image origin is top-left. With np.flipud applied, the grid now matches the world orientation.
Source code in src/hivebr/engine/occupancy_grid.py
grid_to_world
¶
Converts grid coordinates (ix, iy) to world coordinates (x, y).
is_occupied
¶
Checks if the given world coordinates (x, y) are occupied.
Source code in src/hivebr/engine/occupancy_grid.py
cast_ray
¶
Casts a ray into the grid map using DDA algorithm for precise collision.
Source code in src/hivebr/engine/occupancy_grid.py
draw
¶
Draws the map onto the screen based on the occupancy matrix logic, including a border indicating the map boundaries.