SpaceX Autopilot

Project · Software & hardware · 2025

A program that docks the Dragon capsule to the ISS on its own.

Scroll ↓
Overview

My diploma thesis at HTL Vöcklabruck, together with ABATEC GmbH: an autopilot for SpaceX’s official docking simulator and a control panel built from real hardware that hands over to the autopilot at the push of a button. My part was the software – from reading the website and the control algorithm to an attempt to learn docking with reinforcement learning.

Client
ABATEC GmbH
Year
2025
Role
Autopilot, web scraping, AI experiments
Team
Team of two · diploma thesis at HTL Vöcklabruck
Duration
15 months
Tools
Python · Selenium · TensorFlow · Raspberry Pi 5 · PyCharm
SpaceX’s docking simulator in a browser window, in front of it a photo of the finished control panel with blue illuminated buttons and a display.
Challenge

Docking without an interface.

The simulator at iss-sim.spacex.com shows what NASA astronauts see too: eleven telemetry values and twelve control buttons. Only when position and attitude are at zero and every rate is below 0.2 does the capsule dock.

There is no programming interface. The autopilot has to read and operate the website like a person. ABATEC wanted an eye-catcher for trade fairs: a panel where visitors fly themselves and, at the push of a button, watch the autopilot take over.

How it works: the autopilot switch decides who controls the simulator – when off, the control panel with its buttons; when on, the autopilot software in Python.
Solution

Read, calculate, press.

Selenium reads the values straight from the page. Each axis is an object with two buttons, a rate and an error. From these the algorithm calculates a target speed: five percent of the remaining error – the closer to the target, the slower.

If the rate is too high or too low, the program presses the matching button – in a loop over all six axes until “Success” appears. On the Raspberry Pi 5 inside the control panel, one button switches between manual control and autopilot at any time.

The autopilot’s control loop in five steps: read values, calculate target speed, compare with the rate, press a button, the simulator reacts – until “Success” appears.
Result
173hworking hours in my activity log
11telemetry values, read continuously
7days of training for the AI autopilot
Overview
Scroll →Swipe →
Under the hood

The simulator

At iss-sim.spacex.com SpaceX offers a simulator in which the Dragon capsule docks to the International Space Station – with the same kind of displays astronauts use.

Eleven telemetry values describe the situation: the distance on three axes, the attitude in roll, pitch and yaw with one rate each, plus the straight-line range and an overall rate. Twelve buttons move or rotate the capsule. The zero point sits at the ISS docking port.

The SpaceX simulator in the browser, next to it the eleven telemetry values (position, attitude, rates, range) and the twelve control buttons; goal: all values towards 0, every rate below 0.2.

Web scraping with Selenium

Without an interface, only the surface remains. Selenium opens the page, clicks “Begin” and finds every display and every button by its CSS identifier.

Each axis is an object of the HudItem class: two buttons, the identifier of the rate and of the error. That way one loop handles all six axes the same way.

For the three position axes the simulator shows no individual rate, only a combined one. So I calculate it myself: the change of the error since the last reading, divided by the time that has passed.

Code excerpt: an axis is created as a HudItem, the adjustItem method calculates the target speed and presses the matching button, a loop runs until docking.

The control algorithm

The core is one line: expectedRate = error × 0.05. The desired speed is always five percent of the remaining error. Far away the capsule moves fast, close to the target only slowly – it brakes by itself.

If the measured rate is below the target, the program presses one button of the axis, otherwise the other. One special case applies to the last five metres: there the capsule approaches the station at a fixed rate of −0.3 m/s.

The result was an autopilot that docks reliably. The biggest hurdle was not the calculation but Selenium itself: it reacted at different speeds depending on the machine, and the code had to be adapted once more for the Raspberry Pi.

The AI attempt

In addition, an autopilot was meant to learn docking by itself. I evaluated three approaches – the PILCO algorithm, reinforcement learning with TensorFlow and OpenAI Gymnasium – and chose TensorFlow.

The neural network receives the eleven telemetry values and picks one of twelve buttons. A reward system scores every step: getting closer earns points, too large distances and spin rates cost a lot. Several browsers trained in parallel without a window, and their models were merged afterwards.

After seven days of training the capsule no longer spun out of control – but it never got close to the ISS. Possible reasons: wrong priorities in the reward system or an undiscovered bug. One small model per axis would probably have been simpler. For the Raspberry Pi the training was too heavy anyway.

The neural network of the AI attempt: eleven telemetry values as input, hidden layers with 128, 64 and 64 neurons, twelve outputs – one per control button.

Hardware and switching

My project partner built the control panel: a Raspberry Pi 5 with 8 GB, twelve illuminated buttons for steering, a start and an autopilot button, and a 5-inch display showing time and mode. The housing made of film-faced plywood was designed in Creo; its shape is inspired by the Cybertruck.

To make switching work, manual control lives in the same code as the autopilot. One press of the autopilot button is enough, and the program takes over mid-flight – or hands control back.

The finished control panel: a black wooden housing with twelve blue illuminated buttons and a display, next to it the open interior with the Raspberry Pi and wiring.
Process
Dec 2023 – May 2024Autopilot

Scraping, algorithm, first docking.

Aug – Dec 2024Hardware

Raspberry Pi, prototype, code on the Pi.

Nov 2024 – Feb 2025AI attempt

PILCO, reinforcement learning, training.

Feb – Mar 2025Completion

Final panel, thesis, presentation.

Next projectPersonal BrandingOne brand, one website, one application – from one system.