Python autopilot scripts that fly rockets in Kerbal Space Program without human input, driving the game live over the kRPC mod: telemetry streams out, control commands stream in, over TCP. Two scripts do the work: one launches a vessel to a permanent, stable orbit; the other flies a booster back to a soft upright landing near the pad while the upper stage reaches orbit on the same flight. Verified in-game across 25 autonomous flights. A hobby project, not a product.
launch_to_orbit.py flies the active vessel through a gravity-turn ascent and circularizes at apoapsis into a stable orbit that will not decay, 70 to 80 km by default. It handles single-stage and two-stage rockets: a two-stage craft stages automatically, dropping the first stage once its fuel runs out and finishing the orbit on the second.
Target altitude, gravity-turn end, the first-stage fuel reserve, and an optional physics time-warp to run the ascent faster are all tunable from the command line.
launch_and_recover.py runs a Falcon-9-style profile on a two-stage rocket: launch, then separate the first stage once it burns down to a set fuel limit (30% by default). From there both stages are flown at once in a single control loop: the booster turns around, burns back toward the pad, deploys airbrakes on descent, and brakes to a soft upright touchdown, while the second stage carries on to orbit.
Best run to date: the booster landed undamaged, 0.3° off vertical, descending at 2.85 m/s at touchdown, with the upper stage in a stable 70.5 × 84 km orbit on the same flight.
The autopilot reads only what a real flight computer could, then derives the rest itself: orbital elements, time to apoapsis, the landing burn, and a drag-aware prediction of where the booster will fall, the way real avionics would.