Mobile Robot Navigation Basics
Small Python practice project for terrain grid maps, A* path planning, disturbed tracking, and simple mobile robot simulation.
This is a small Python practice project that I made to understand some basic parts of mobile robot navigation. It is not a complete autonomous vehicle project. I made it more as a learning work, because I wanted to connect my control background with path planning and simple robot motion.
The project is available here: GitHub repository
The project starts from a small grid map, then a larger terrain map, then A* path planning, and finally a simple vehicle tracking model. After that, I added one small disturbed tracking test and some simple metrics.
Basic terrain grid
The first step was a 10 by 10 NumPy grid. I used numbers for terrain types: 0 for flat terrain, 1 for rough terrain, 2 for risky terrain like snow or ice, and 9 for obstacle.
This was very simple, but useful for me. It also reminded me that NumPy indexing is row-column, not normal x-y coordinate. So (0, 0) appears at top-left.
Larger terrain map
After the small grid, I made a larger map. The random obstacles are not from real sensor data. I added them just to make the map less empty and more useful for planning practice.
I also used a fixed random seed, so the map stays same when I run the script again.
A* path planning
In this step I added A* path planning. The planner tries to find a route from start to goal. Flat cells have low cost, rough cells have more cost, risky cells have more cost, and obstacles have very high cost.
This part helped me understand that planning and control are not the same. A* gives a route, but it does not move the robot.
Simple vehicle tracking
Before connecting the A* path to the map, I tested a simple vehicle model. I used a unicycle model with x, y, and theta.
This model is basic. It does not include wheel slip, acceleration limit, motor dynamics, or terrain effect. But it was enough for practicing heading-based tracking.
A* path with vehicle tracking
Here I converted the A* path to waypoints for the vehicle model. A* gives points as row and column, but the vehicle model uses x and y.
x = column
y = row
I did not use every A* point as waypoint. I selected every few points, because the full path has many close cells and the simple vehicle would turn too much.
Disturbed tracking and simple metrics
For the last part, I added a small disturbance test. The vehicle does not move in a perfect condition. I added random heading noise, and also terrain-dependent speed. This made the simulation a little more close to rough motion, but still it is very simple.
| Metric | Value |
|---|---|
| A* path cells | 51 |
| Selected waypoints | 18 |
| Path cost | 51.0 |
| Rough cells in path | 0 |
| Risky cells in path | 0 |
| Mean tracking error | 1.71 |
| Maximum tracking error | 3.30 |
In this run, the A* path did not pass through rough or risky cells, so both of them are zero. The mean tracking error was about 1.71 and the maximum tracking error was about 3.30. The error is not very small, but for this basic model it is acceptable.
Shortest path vs risk-aware planning
After the first A* tests, I wanted to compare two different planning ideas. The shortest path planner only tries to reduce the grid distance. The risk-aware planner uses distance and terrain cost together.
This is still a simple grid example. It is not a full autonomous driving system. But it shows one useful idea: in rough terrain, the shortest route is not always the best one.
| Planner | Path length | Total terrain cost | Risk exposure | Tracking error | Success |
|---|---|---|---|---|---|
| Shortest path | 25 | 179.0 | 14 | 1.81 | Yes |
| Risk-aware path | 33 | 33.0 | 0 | 1.71 | Yes |
The result is simple but useful. The shortest path has lower distance, but much higher terrain cost. It also passed through 14 risky cells. The risk-aware path was longer, but it had zero risky cells in this test.
What I learned
This project helped me understand the connection between terrain representation, path planning, and simple mobile robot movement.
The main things I practiced were:
- making a terrain grid with NumPy,
- using numbers for terrain types,
- assigning simple costs for flat, rough, risky, and obstacle cells,
- implementing a basic A* planner,
- converting grid path to x-y waypoints,
- simulating a simple vehicle model,
- adding small disturbance and tracking error,
- plotting the planned path and tracking path together.
There are still many limitation in this project. The map is manually created. There is no camera, no LiDAR, no ROS, no real robot, and no advanced controller. The terrain cost values are also manually selected.
But for a small practice work, it was useful for me. It gave me a first working example that connects map, planner, tracking, and simple evaluation. Later I can improve it by adding diagonal movement, path smoothing, animation, or maybe a ROS 2 version.