| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This project implements the Grassfire (BFS) Algorithm for pathfinding in a grid-based environment, simulating the movement of a robot from a start cell to a goal cell while avoiding obstacles. The simulation visualizes the grid, the distances calculated by the Grassfire algorithm, and the shortest path found.
This project implements a robot pathfinding simulation using the Grassfire (Breadth-First Search) algorithm on a grid-based environment. The algorithm floods outward from the goal cell, computing the shortest distance to every reachable cell. The robot then follows the gradient of decreasing distance from the start cell to the goal, guaranteeing an optimal shortest path.
Clone this repository and run the start_simulation.m file, providing the grid dimensions, start cell, goal cell, and obstacles as input parameters.
To run the simulation, call the start_simulation function with the appropriate parameters:
start_simulation(m, n, startCell, goalCell, obstacles)m = 5; % Number of rows
n = 5; % Number of columns
startCell = 1; % Start cell index
goalCell = 13; % Goal cell index
obstacles = [7, 8, 12, 14]; % Obstacle cells
start_simulation(m, n, startCell, goalCell, obstacles);The Grassfire algorithm is a Breadth-First Search (BFS) that computes shortest distances on a uniform-cost grid:
| Property | Value |
|---|---|
| Search Strategy | Uniform expansion (BFS) from goal |
| Data Structure | FIFO Queue |
| Movement | 4-directional (up, down, left, right) |
| Edge Costs | Uniform (all = 1) |
| Optimality | Guaranteed (shortest path in unweighted grid) |
| Completeness | Complete (finds path if one exists) |
The project consists of the following MATLAB functions:
start_simulation.m: The main entry point that initiates the simulation, calling other functions to display the grid, run the Grassfire algorithm, and visualize the robot's path.
display_grid.m: Displays the grid with the start cell (green), goal cell (red), and obstacles (black). Validates input parameters and ensures proper visualization.
grassfire_algorithm.m: Implements the Grassfire algorithm using BFS to calculate the distance of each cell from the goal while considering obstacles. Obstacles are marked as impassable, and distances propagate uniformly to all reachable cells.
display_distances.m: Overlays the computed distance values on the grid, showing the distance from each cell to the goal.
shortest_path.m: Visualizes the shortest path from the start cell to the goal cell by following the gradient of decreasing distances. Animates the robot step-by-step along the optimal path.
draw_robot.m: Draws the robot's representation on the grid. The robot features a blue rectangular body, black wheels, and an orange circular top mount.
index_to_rowcol.m: Converts a linear cell index to its corresponding row and column indices using row-major order (left-to-right, top-to-bottom).
This project is licensed under the MIT License. See the LICENSE file for details.
Grassfire Algorithm:
Pathfinding Algorithms:
Mobile Robots:
MATLAB Graphics:
| Back | FazBrowse Home | New Git URL |