run once "lib/guidance". local APOAPSIS_TARGET is 80000. local GRAVITY_TURN_START is 5000. SensorCheck(). // Configure subsystems. CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Open Terminal"). RCS off. SAS off. // Countdowns are cute. print "Initiating automated launch sequence". from { local x is 5. } until x = 0 step { set x to x - 1. } do { print "..." + x. wait 1. } print "Launching". // throttle controls when TWR() > 1.5 then { if SHIP:ALTITUDE > 32000 { lock THROTTLE to 1.0. return false. } lock THROTTLE to ThrottleToTWR(1.5). return true. } // Main ascent control. lock THROTTLE to 1.0. lock STEERING to heading(90,90,-90). stage. wait until SHIP:ALTITUDE > 200. lock STEERING to heading(90, 85, -90). wait until SHIP:ALTITUDE > GRAVITY_TURN_START. print "Beginning gravity turn". until SHIP:ORBIT:APOAPSIS > 80000 { local adjustedPrograde is SHIP:ORBIT:PROGRADE * NORTH. local angle is max(30, adjustedPrograde:pitch). print "Adjusted Prograde = " + adjustedPrograde. print "Angle = " + angle. lock STEERING to heading(90, angle, -90). wait 0.001. } print "Releasing controls. Good luck, Kerman!". set THROTTLE to 0.0. unlock THROTTLE. unlock STEERING. wait 5. CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Close Terminal").