import("library/lib_staging"). import("library/lib_math"). import("library/lib_vessel_utils"). import("library/lib_orbits"). declare function Ascent{ parameter targetOrbit is 100. parameter vericalAscent is 1000. parameter ascentProfile is 1.2. print "Vertical Climb to " + vericalAscent. set tgtPitch to 90. lock throttle to 1. lock steering to heading(90, tgtPitch, 270). local lock asccent_prog to Map(apoapsis, 0, targetOrbit, 0.0, 1.0). wait until altitude > vericalAscent and asccent_prog > 0. print "Start Gravity turn. Target Apoapsis: " + targetOrbit. local lock ease to EaseOutExp(asccent_prog, ascentProfile). local lock tgtPitch to (1 - ease) * 90. when periapsis < targetOrbit then { print "P: " + round(asccent_prog, 2) + " T:" + round(ease, 2) + " Pitch: " + round(tgtPitch, 2) + " " at(0, 2). print "Ap: " + round(apoapsis, 2) + " Pe:" + round(periapsis, 2) + " Alt: " + round(altitude, 2) + " " at(0, 3). wait 0.1. preserve. } //Auto Staging when periapsis < targetOrbit then{ AutoStage(). wait 0.01. preserve. } wait until apoapsis >= targetOrbit. unlock tgt_pitch. lock tgtPitch to 0. unlock steering. CircularizeBrute(targetOrbit). unlock steering. unlock throttle. } local function Circularize{ parameter targetOrbit. lock throttle to 0. lock steering to heading(90, 0, 270). local warpTime is eta:apoapsis. local burnDv is CalculateCircularizationDV(). local burnDuration is CalculateMultiStageBurnDuration(burnDv). print "Warping to Circularization. " + round(burnDv) + "m/s. T: " + round(burnDuration, 2) + "s" at(0, 4). set warpTime to warpTime - burnDuration. if warpTime > 0 { wait until throttle = 0. wait 0.01. //Wait for accelleration to stop warpTo(time:seconds + warpTime). } wait until eta:apoapsis <= burnDuration. lock throttle to 1. wait until periapsis >= targetOrbit. lock throttle to 0. } local function CircularizeBrute{ parameter targetOrbit. lock throttle to 1. lock steering to heading(90, 0, 270). wait until periapsis >= targetOrbit. lock throttle to 0. }