Decision-Making and Motion Planning for Automated Driving
KIT - Karlsruhe Institute of Technology
Docs: git-scm.com/doc
# Clone a repository
git clone https://github.com/KIT-MRT/behavior_generation_lecture_python.git
# Check status of your changes
git status
# Stage changes for commit
git add myfile.py
# Commit with a message
git commit -m "Add new feature for path planning"
# Push to remote repository
git push origin main
# Pull latest changes (fetch + merge)
git pull origin main
Resources: GitHub Getting Started, Git reference
# Create a new branch
git checkout -b feature/new-controller
# Switch between branches
git checkout main
# Merge a branch
git merge feature/new-controller
# Delete a branch
git branch -d feature/new-controller
Why branches?
Docs: docs.astral.sh/uv
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create a new project
uv init my-project
# Install dependencies
uv sync
# Add a new package
uv add numpy
# Run a script
uv run python my_script.py
Central configuration file for Python projects:
Example (shortened). Full file: pyproject.toml
[project]
name = "behavior_generation_lecture_python"
version = "0.0.2"
requires-python = ">=3.12, <3.13"
dependencies = [
"numpy>=1.26.0",
"matplotlib>=2.2.4",
"scipy>=1.11.0",
# ...
]
[project.optional-dependencies]
dev = [
"pytest",
# ...
]
# tests/test_a_star.py
import pytest
from behavior_generation_lecture_python.graph_search.a_star import a_star
def test_a_star_finds_path():
"""Test that A* finds a valid path."""
start = (0, 0)
goal = (5, 5)
path = a_star(start, goal, grid)
assert path is not None
assert path[0] == start
assert path[-1] == goal
def test_a_star_no_path():
"""Test that A* returns None when no path exists."""
path = a_star(start, goal, blocked_grid)
assert path is None
Docs: docs.pytest.org
# Run all tests
uv run pytest
# Run tests with coverage
uv run pytest --cov=src
# Run specific test file
uv run pytest tests/test_a_star.py
# Run tests matching a pattern
uv run pytest -k "test_a_star"
# Show verbose output
uv run pytest -v
# Stop on first failure
uv run pytest -x
Coverage plugin: pytest-cov
Repeat!
# Format code (like Black)
uv run ruff format
# Check for linting issues
uv run ruff check
# Auto-fix what can be fixed
uv run ruff check --fix
ruff is 10-100x faster than traditional tools!
Common issues caught:
Docs: docs.astral.sh/ruff
# Without type hints - mypy cannot help
def calculate_reward(state, action):
return state * action # Bug if state is a list!
# With type hints - mypy catches errors
def calculate_reward(state: float, action: float) -> float:
return state * action # mypy ensures correct types
# Run type checking
uv run mypy path/to/package_or_module
Type hints = documentation + error prevention
Docs: mypy.readthedocs.io
CI is an automated quality gate that runs on every push / pull request.
Our CI: .github/workflows/ci.yml,
# Create a branch
git checkout -b feature/my-change
# Install (use the lock file)
uv sync --all-extras
# Run checks (see CI workflow for the exact commands)
uv run ruff format
uv run ruff check
uv run mypy path/to/package_or_module
uv run pytest
// .vscode/settings.json
{
"python.defaultInterpreterPath": ".venv/bin/python",
"[python]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff"
}
}
.venv/bin/python in the IDEuv sync --all-extras (docs, dev tools)uv.lock committedRepo files: uv.lock, pyproject.toml
| Topic | Key Tools |
|---|---|
| Version Control | git, GitHub, Pull Requests |
| Environment | uv, pyproject.toml, uv.lock |
| Testing | pytest, pytest-cov, TDD |
| Code Quality | ruff, mypy |
| Development | VS Code, Cursor, Python debugger |
# Clone the repository
git clone https://github.com/KIT-MRT/behavior_generation_lecture_python.git
cd behavior_generation_lecture_python
# Install dependencies
uv sync --all-extras
# Run the tests
uv run pytest
# Start exploring!
uv run jupyter lab