From 75a7dfec223a8f871a7b9efc92fa2d20579b42de Mon Sep 17 00:00:00 2001 From: annabunches Date: Fri, 6 Aug 2021 01:36:26 -0400 Subject: [PATCH] Stage during ascent, if needed. --- lib/launch_rocket.ks | 10 ++++++++++ lib/node.ks | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/launch_rocket.ks b/lib/launch_rocket.ks index 87b5b83..106b3eb 100644 --- a/lib/launch_rocket.ks +++ b/lib/launch_rocket.ks @@ -21,6 +21,16 @@ function Launch { wait 0.5. } + // staging logic. Stage as many times as needed until we finish ascent. + // Once Apo target is attained just drop this trigger. + when FlameOut() or SHIP:ORBIT:APOAPSIS > APOAPSIS_TARGET then { + if SHIP:ORBIT:APOAPSIS > APOAPSIS_TARGET { + return false. + } + stage. + return true. + } + // Hold throttle to maintain 1.5 TWR. // We do *not* use a PID Loop here because we can // calculate the correct value discretely. diff --git a/lib/node.ks b/lib/node.ks index f9cf43b..79fba51 100644 --- a/lib/node.ks +++ b/lib/node.ks @@ -13,7 +13,7 @@ function ExecNode { if WillStage(NEXTNODE:DELTAV:MAG) { print "WARNING: kOS will stage during this node execution. Safe cancellation requires reboot.". - when flameOut() then { + when FlameOut() then { print "Flameout detected. Staging.". stage. } @@ -156,7 +156,7 @@ function stageMass { return m. } -function flameOut { +function FlameOut { local ens is List(). list engines in ens. for en in ens {