Risk-aware Pathfinding and Trajectory Planning
A MATLAB-based autonomous navigation simulation comparing A* and Greedy Best-First Search for a mobile robot travelling through an obstacle-filled soccer field environment.
Interactive Pathfinding Demonstration
This interactive demo recreates the final MATLAB simulation logic as a browser-based pathfinding tool. It allows the obstacle width to be adjusted from 1 m to 12 m and compares how A* and Greedy Best-First Search (BFS) respond to the same obstacle layout.
A* includes a risk penalty, so it tends to favour safer paths around high-risk zones. Greedy Best-First Search uses a more direct heuristic approach, which can produce shorter routes but is more likely to travel through riskier areas as obstacle size increases.
Project Overview
Project Summary
This project investigated pathfinding strategies for an autonomous mobile robot navigating across a simulated soccer field environment based on the AGVC 2013 autonomous robotics challenge. The robot was required to visit four predefined target locations while avoiding collisions with rectangular obstacles placed throughout the field.
The simulation was developed in MATLAB and compared two informed search algorithms: A* Search and Greedy Best-First Search. The project focused on more than simply finding a valid route, as a hazard proximity map was also introduced to represent risk around obstacles. This allowed the navigation behaviour to be compared in terms of both route efficiency and exposure to unsafe areas.
Key Features
MATLAB-based Autonomous Navigation Simulation
The simulation modelled a 120 m by 90 m soccer field as a two-dimensional grid, allowing robot motion, obstacles, target zones, and path planning behaviour to be represented in a structured and repeatable format.
Risk-aware Path Planning
A hazard proximity map, referred to as the Danger Map, was generated around obstacles to represent unstable or undesirable terrain. This allowed the A* algorithm to include an additional risk penalty when selecting paths through the field.
A* and Greedy Search Comparison
A* Search was used as the primary risk-aware planning method, while Greedy Best-First Search was implemented as a comparison method. This made it possible to compare a cost-aware algorithm against a more direct heuristic-driven search strategy.
Animated Visualisation and Subplots
MATLAB plotting and animation tools were used to visualise the robot trajectory, obstacle layout, occupancy map, hazard proximity map, and algorithm behaviour. This made it easier to interpret how each algorithm responded to different obstacle sizes and risk conditions.
Technical Development
Simulation Environment and Grid Setup
The field was modelled as a 120 m by 90 m environment and divided into a grid using a 0.5 m cell resolution. This produced a 240 by 180 cell search space, balancing computational performance with enough spatial resolution for robot movement and obstacle interaction.
The robot started near the centreline of the left edge of the field at coordinates (0.25, 45.25). Four circular target zones were placed at known field locations, with each target represented as a small 2 by 2 cell goal region to make collision-free goal detection more reliable.
Obstacle and Occupancy Map Modelling
Fifteen rectangular obstacles were placed at fixed central positions throughout the field. Their widths were varied across simulation runs, with the longer edge defined as twice the obstacle width. This allowed the same navigation problem to be tested under increasingly constrained obstacle conditions.
An occupancy map was generated by checking each grid cell against the obstacle geometry. Cells overlapping an obstacle were marked as blocked and excluded from the valid search space used by the pathfinding algorithms.
Danger Map and Risk Penalty
In addition to the binary occupancy map, a Danger Map was created to represent hazard proximity around obstacles. Grid cells near obstacles were assigned increasing risk levels based on their Manhattan distance from the nearest obstacle, with risk extending outward within a 6-cell radius.
The A* algorithm incorporated this risk map by adding a danger penalty to the cost function. This encouraged the robot to avoid high-risk zones where possible, even when the safer route required a longer path.
f(n) = g(n) + h(n) + dangerPenalty
Pathfinding Implementation
Both algorithms operated on the same grid environment, with robot movement limited to four directions: up, down, left, and right. The pathfinding logic was structured into reusable segment-level functions, allowing the robot to move between successive target regions using the same planning process.
Before path planning, the target visitation order was optimised by testing permutations of the target sequence and selecting the route with the lowest Euclidean travel cost. This kept the target order consistent between A* and Greedy, allowing their behaviour to be compared more fairly.
A* Search Behaviour
A* combined the cost already travelled, the estimated cost to the target, and the additional danger penalty. This made it more suitable for risk-aware navigation because it could favour safer paths instead of simply selecting the most direct route.
In the simulation results, A* maintained fully safe paths for obstacle widths between 1 m and 8 m. As the obstacle width increased beyond this point, the environment became more constrained and the algorithm began accepting low, medium, and eventually high-risk cells where no fully safe route was available.
Greedy Best-First Search Behaviour
Greedy Best-First Search used only the heuristic distance to the target when selecting the next cell. This made the method more direct, but it did not consider cumulative path cost or the longer-term safety of the route.
This behaviour became clear as obstacle widths increased. Greedy often produced shorter routes than A*, but it entered high-risk areas much more frequently because it prioritised progress toward the target over risk avoidance.
Results and Performance Comparison
The results showed a clear trade-off between path safety and directness. At 12 m obstacle width, A* travelled 915 cells and included 26 high-risk cells. Greedy travelled 795 cells, but included 525 high-risk cells, meaning a large portion of its final path passed through unsafe regions.
| Algorithm | 12 m Steps | Safe Cells | Low Risk | Medium Risk | High Risk |
|---|---|---|---|---|---|
| A* | 915 | 762 | 45 | 82 | 26 |
| Greedy | 795 | 148 | 44 | 78 | 525 |
This comparison demonstrated that Greedy could produce a shorter path, but at the cost of significantly greater risk exposure. A* produced a longer route, but remained much more suitable for safety-conscious navigation.
Development Challenges
A significant challenge involved managing MATLAB subplot visualisation. Combining obstacle overlays, occupancy maps, hazard maps, and animated robot paths introduced issues with overlapping axes, inconsistent scaling, and visual clutter.
Animation updates also required careful handling. Earlier versions produced ghosting effects or duplicate breadcrumb markers because previous plot elements were not always cleared or updated correctly. The final implementation used more controlled plot updates to show the robot movement while preserving the intended path trail.
Project Outcome
The final simulation successfully compared A* and Greedy Best-First Search within the same obstacle-filled environment. The results showed that A* was better suited to risk-aware navigation, while Greedy produced more direct paths that became increasingly unsafe as obstacle size increased.
This project strengthened my understanding of autonomous navigation, grid-based simulation, informed search algorithms, MATLAB visualisation, obstacle modelling, and the practical trade-offs involved in designing path planning systems for mobile robots.
Future improvements would include dynamically scaling the danger penalty, replacing the permutation-based target ordering method with a more scalable heuristic approach, adding diagonal robot movement, and exploring a hybrid Greedy method with light risk weighting.