Write your self-driving car in Python, with as many files and trained networks as it needs, and watch it drive. Part of the free Self-Driving Cars course.
A self-driving car has two halves. The world: the road, the physics of the car, other cars, traffic lights, people, the camera. The brain: the code that looks at what the car senses and decides how to steer and how hard to press the pedals. The world is already written (it is the same simulator as the course). You write the brain.
When you press ▶ Run, the page starts Python in your browser, copies your project's files into it, and imports
main.py. Then, every step, the simulator measures what the car senses, calls your drive(car)
(or control(car)) with those readings, takes the two numbers it returns, steer and throttle,
and moves the car with them. That repeats until the lap is done, the car crashes, or time runs out.
def drive(car):
steer = -0.3 * car.cte # radians, + = left (at most ±0.55)
throttle = 0.6 * (11.0 - car.speed) # -1 full brake … 1 full power
return steer, throttle
So a small project is one file. A bigger one is a normal Python project: main.py can import your other
files, and your code can load trained networks from the models/ folder, as it would on your own computer.
| World | What your code gets | Course part |
|---|---|---|
| Exact sensors | Perfect readings (distance from the lane centre, heading error, the path ahead), 30 times a second. No traffic. | Part 1: control (PID, pure pursuit, speed planning) |
| Traffic world | What a perception system would report: the lane, the car ahead, the next traffic light, the nearest pedestrian, with errors that grow at night and in rain. 15 times a second, in 20 scenarios. | Part 5: the capstone |
| Camera + your networks | The camera image itself (a 240 × 120 NumPy array). Your U-Net, detector and traffic-light classifier find everything in it; then your decisions drive. | Parts 2 and 6: the whole car |
Pick one with ☰ Project ▸ New project from a template. Each template's README.md lists every field of car for its world,
and the What your code receives tab shows the live values while it runs.
The Studio is the workbench of the Self-Driving Cars course. Each lesson below opens the Studio with the right project, so you can go from reading to driving in one click.
The camera template starts with the course's trained networks in models/: sdc_unet.json (finds the lane),
sdc_detector.json (cars and people) and sdc_light.json (light colours). perception.py runs them with
NumPy (softmaxima_nn.py), so they work in the browser and in CARLA. To use yours, train it in the course, export it,
and drop the file on the explorer with the same name: it replaces the one in models/. A different name works too:
change the path in main.py. You can also add any file your code opens (a CSV of gains, a map, …).
☰ Project ▸ Export gives you the project as a .zip. Unzip it next to the course's offline simulator (the simulator lesson has the download), then run:
python run.py main.py --track city --show
That runs exact-sensors projects with the same physics, so a lap takes the same time as here. Camera projects run in CARLA: see Your complete car, and CARLA. A zip you exported, or the course's "Download your car" zip, can be imported back here.
| Ctrl+Enter | Run |
| Ctrl+S | Save (it also saves by itself as you type) |
| Tab / Shift+Tab | Indent / unindent the selected lines |
| Ctrl+/ | Comment or uncomment the selected lines |
| Double-click a file | Rename it |
In this browser only (IndexedDB), on this computer. Nothing is uploaded. Export a .zip to keep a copy or move it to another computer.
CPython 3.12 compiled for the browser (Pyodide). The standard library and NumPy work; it downloads about 10 MB the first time, then the browser keeps it.
The run stops, the Output panel shows the error with links to the file and line, and the editor jumps there.
Yes. Module-level variables (like the PID's integral) live for the whole run, and every Run starts fresh.
The editor and the simulator are Softmaxima's own. Python runs in your browser thanks to Pyodide, with NumPy; both are free, open-source projects.
Each step renders a camera image and runs three neural networks on it in Python. Set the speed to Max, or work in the traffic world first.