Python sample codes and documents about Autonomous vehicle control algorithm. This project can be used as a technical guide book to study the algorithms and the software architectures for beginners.
- What is this?
- Goal of this project
- Requirements
- Quick Start
- Examples of Simulation
- Documents
- License
- Use Case
- Contribution
- Author
This is a sample codes collections about Autonomous vehicle control algorithm. Each source codes are implemented with Python to help your understanding. You can fork this repository and use for studying, education or work freely.
I want to release my own technical book about Autonomous Vehicle algorithms in the future. The book will include all of codes and documents in this repository as contents.
The next goal is a simulator where you can learn the whole navigation of an autonomous vehicle, swapping algorithms at each stage and comparing the results. See the architecture and roadmap and the roadmap issue.
Please satisfy with the following requirements on native or VM Linux in advance.
For running each sample codes:
- Python 3.13.x
- Matplotlib
- NumPy
- SciPy
- CasADi (for MPC path tracking)
- do-mpc (for MPC path tracking)
For development:
- pytest (for unit tests)
For setting up the environment with Docker (see Quick Start):
- Docker
- VS Code with the Dev Containers extension (only for option A)
$ git clone https://github.com/ShisatoYano/AutonomousVehicleControlBeginnersGuide
$ cd AutonomousVehicleControlBeginnersGuideChoose one of the following options.
Note for options A and B: The container shows the animations through your host's X11 display.
- Linux: Allow local connections to your X server before starting the container. This setting is reset when you log out, so run it again after logging in (or run it automatically at login).
This allows any local process on your machine to connect to your X server, so be careful on a shared machine.
$ xhost +local:
- Windows / macOS: You need an X server that the container can connect to, such as WSLg on WSL2 or XQuartz on macOS.
- Install Docker and VS Code with the Dev Containers extension
- Open this repository's folder in VS Code
- Run
Dev Containers: Reopen in Containerfrom the Command Palette - All required libraries are installed automatically. Run the commands in the following steps in VS Code's terminal
- Install Docker
- Build and start the container, and then open a shell in it
$ docker compose up -d --build $ docker compose exec simulation bash - Run the commands in the following steps in this shell. To stop the container, run
docker compose downon your host
- Install Python 3.13.x
- Create a virtual environment and install the required libraries
- Linux / macOS:
$ python3 -m venv .venv $ source .venv/bin/activate $ pip install -r requirements.txt - Windows (PowerShell):
> python -m venv .venv > .venv\Scripts\Activate.ps1 > pip install -r requirements.txt
- Linux / macOS:
Each simulation runs with one command. For example, localization with an Extended Kalman Filter, where the vehicle estimates its position from sensor observations while following a course:
$ python src/simulations/localization/extended_kalman_filter_localization/extended_kalman_filter_localization.pyYou can find all simulations in doc/EXAMPLES.md.
You can confirm that the environment is set up correctly by running the unit tests.
$ . run_test_suites.shOn Windows without Docker, run run_test_suites.bat instead.
Add star to this repository if you like it!!
Each simulation script adds its own module search paths at runtime with
sys.path.append(...), since this project doesn't use a standard Python
package layout. Static analysis tools (Pylance/pyright) can't see those
runtime sys.path.append(...) calls, so without extra configuration your
editor will show false "import could not be resolved" errors and code
completion won't work for these modules.
To fix this, pyrightconfig.json (for pyright/Pylance, e.g. Neovim or VS
Code without Dev Containers) and .devcontainer/devcontainer.json's
python.analysis.extraPaths (for VS Code + Dev Containers) list every
directory under src/components and src/simulations that directly
contains a .py file.
Whenever you add a new module (a new directory under src/components or
src/simulations), regenerate both files by running:
$ python generate_pyrightconfig.pyThis scans the project and rewrites both files automatically, so you don't need to edit them by hand.
Run this script on your host machine, not inside the container. It only
uses the Python standard library (json, pathlib), and since the project
directory is bind-mounted into the container as-is, the files it writes are
the same on both sides either way. Running it on the host is simplest since
it doesn't depend on the container's Python environment at all.
Every algorithm has a runnable simulation with an animated demo, organized into these categories:
- Localization
- Mapping
- Path Planning
- Path Tracking
- Perception
- Course
The full list with demo GIFs is generated from src/simulations — see doc/EXAMPLES.md.
Design documents of each Python programs are prepared here. The documents are still not completed. They have been being updated. If you found any problems in them, please tell me by creating an issue.
Documents link
MIT
I started this project to study an algorithm and software development for Autonomous Vehicle system by myself. You can also use this repo for your own studying, education, researching and development.
If this project helps your task, please let me know by creating a issue.
Any paper, animation, video as your output, always welcome!! It will encourage me to continue this project.
Your comment and output is added to this list of user comments.
Any contribution by creating an issue or sending a pull request is welcome!! Please check this document about how to contribute.
If you are looking for a place to start, see the good first issues and the roadmap issue.
