Skip to content

Latest commit

 

History

1,948 Commits

Folders and files

Repository files navigation

AutonomousVehicleControlBeginnersGuide

Linux_CI Windows_CI MacOS_CI Book CodeFactor

Learn autonomous driving by building it. Python simulations and an open textbook of self-driving car algorithms (localization, mapping, path planning, path tracking, perception and control), and of the software architecture designed to connect them into one autonomous driving system.

PythonRobotics shows each robotics algorithm on its own. This project builds one self-driving system and swaps the algorithms inside it. You can already see the idea in localization, where EKF, UKF and a particle filter drive the same course side by side, with the same motion model and GNSS noise settings; the other stages are moving into one shared system step by step (see the roadmap).

Read the book · See all simulations · Quick start

Localization: EKF vs UKF vs PF
Localization: EKF vs UKF vs PF
Path tracking: MPPI
Path tracking: MPPI
Path planning: Hybrid A*
Path planning: Hybrid A*
Mapping: NDT
Mapping: NDT
Mapping: cost map
Mapping: cost map
Perception: rectangle fitting
Perception: rectangle fitting

Where to start

Table of Contents

About this project

Every algorithm is a small Python simulation with an animation, written to be easy to read rather than fast or complete. You can run each one with a single command, change its parameters and see what happens. Fork it and use it for studying, teaching or your own work.

Beyond single algorithms, the architecture and roadmap describe where the code is heading: stages that pass data to each other through small interfaces, so that one algorithm can be swapped for another, with the true state kept apart from the estimates. The code is moving there step by step.

Where to go next

To run autonomous driving on real vehicles, look at Autoware, open-source autonomous driving software built on ROS 2. It has the same stages as this book, such as localization, perception, planning and control, and some of the algorithms here, such as Pure Pursuit and MPC, have counterparts there.

Requirements

Choose one of the three setups in Quick Start:

For options A and B, also set up an X server to display the animations (see the note in Quick Start).

Quick Start

1. Clone this repository

$ git clone https://github.com/ShisatoYano/AutonomousVehicleControlBeginnersGuide
$ cd AutonomousVehicleControlBeginnersGuide

2. Set up the environment

Choose 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).
    $ xhost +local:
    This allows any local process on your machine to connect to your X server, so be careful on a shared machine.
  • Windows / macOS: You need an X server that the container can connect to, such as WSLg on WSL2 or XQuartz on macOS.

A. VS Code + Docker (Dev Container)

  1. Install Docker and VS Code with the Dev Containers extension
  2. Open this repository's folder in VS Code
  3. Run Dev Containers: Reopen in Container from the Command Palette
  4. All required libraries are installed automatically. Run the commands in the following steps in VS Code's terminal

B. Docker only

  1. Install Docker
  2. Build and start the container, and then open a shell in it
    $ docker compose up -d --build
    $ docker compose exec simulation bash
  3. Run the commands in the following steps in this shell. To stop the container, run docker compose down on your host

C. Local (without Docker)

  1. Install Python 3.14.x
  2. 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

3. Run a simulation

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.py

You can find all simulations in doc/EXAMPLES.md.

To try one without installing anything, run the Pure Pursuit path tracking simulation in Google Colab: Open In Colab

4. (Optional) Run unit tests

You can confirm that the environment is set up correctly by running the unit tests.

$ . run_test_suites.sh

On Windows without Docker, run run_test_suites.bat instead.

If this guide helped you understand an algorithm, consider giving the repository a star.

Examples of Simulation

Every algorithm has a runnable simulation with an animated demo, in these categories: localization, mapping, path planning, path tracking, perception and course generation. The full list with the demo GIFs is generated from src/simulations: see doc/EXAMPLES.md.

The book

The explanations are published as a free web book: https://shisatoyano.github.io/AutonomousVehicleControlBeginnersGuide/. Each chapter is planned to add one stage to the system and to explain the theory with equations and figures, show where each equation lives in the code, and suggest experiments to try. It is being written in the open (see the documentation roadmap). Comments and ideas are welcome in the Book category of Discussions, and anyone can help write a chapter: see the writing guide.

License

MIT

Citing

If you use this project in your research or teaching, please cite it. Click "Cite this repository" on the right side of the repository page to get the citation in APA or BibTeX format, or see CITATION.cff.

Use Case

I started this project to teach myself how autonomous vehicles work by implementing their algorithms in Python. You can run the simulations to study an algorithm on your own, demonstrate it in class, or compare approaches for research and development.

Used by

If you use the project, share your paper, animation or video in Show and tell.

Listed in

Contribution

Contributions are welcome, through issues or pull requests. Please read how to contribute first.
Questions about the algorithms or the code are welcome in Q&A, and feedback on the book in Book.
If you are looking for a place to start, see the good first issues and the roadmap issue.

Contributors to the Autonomous Vehicle Control Beginners Guide

Support this project

This project is free and will stay free. If it helps you, you can support it through GitHub Sponsors. Your sponsorship pays for:

  • Time to write the web book (#165)
  • Time to add algorithms and grow the code into a full navigation system (#131)
  • Time to review pull requests and keep the project maintained

Sponsors are thanked by name on the book's acknowledgments page and, depending on the tier, also here in the README (corporate sponsors with their logo). Only public sponsors are listed; if you'd rather not be listed, just tell me. Sponsorship doesn't include individual support: questions are answered for everyone in Q&A.

Sponsors

No sponsors yet. Be the first one!

Tools

Development tools are provided free of charge by JetBrains through their open source program.

JetBrains logo.

Author

Shisato Yano

Blog · X · LinkedIn

Releases

Sponsor this project

Packages

Used by

Contributors

Languages