diff --git a/boot/rocket.ks b/boot/rocket.ks index 9964333..5d9167f 100644 --- a/boot/rocket.ks +++ b/boot/rocket.ks @@ -7,6 +7,7 @@ local compiled is list( "/lib/navigation", "/lib/stabilize_rocket", "/lib/ui", + "/lib/reentry", "/lib/throttle" ). diff --git a/boot/science.ks b/boot/science.ks index 73bcdde..c0b3c0a 100644 --- a/boot/science.ks +++ b/boot/science.ks @@ -3,7 +3,8 @@ runoncepath("0:/lib/boot"). parameter debug is false. local compiled is List( - "/lib/navigation" + "/lib/navigation", + "/lib/reentry" ). local copied is List( diff --git a/lib/reentry.ks b/lib/reentry.ks new file mode 100644 index 0000000..cfcfc2c --- /dev/null +++ b/lib/reentry.ks @@ -0,0 +1,26 @@ +// Automated reentry. +// Assumes stage 0 contains only parachutes. +// Primarily written for small science payload probes. + +function PerformReentry { + SAS off. + + // stage until only stage 0 remains. + until STAGE:NUMBER <= 1 { + stage. + } + + lock STEERING to SHIP:SRFRETROGRADE. + + for p in SHIP:PARTS { + if p:MODULES:Find("ModuleRTAntenna") > -1 and p:GetModule("ModuleRTAntenna"):ALLEVENTNAMES:Find("Deactivate") > -1 { + p:GetModule("ModuleRTAntenna"):DoEvent("Deactivate"). + } + } + + when SHIP:ALTITUDE - SHIP:GEOPOSITION:TERRAINHEIGHT < 2500 then { + CHUTES on. + } + + wait until false. +} diff --git a/prog/reentry.ks b/prog/reentry.ks index 77383ba..838fc1b 100644 --- a/prog/reentry.ks +++ b/prog/reentry.ks @@ -4,23 +4,5 @@ @lazyglobal off. -SAS off. - -// stage until only stage 0 remains. -until STAGE:NUMBER <= 1 { - stage. -} - -lock STEERING to SHIP:SRFRETROGRADE. - -for p in SHIP:PARTS { - if p:MODULES:Find("ModuleRTAntenna") > -1 and p:GetModule("ModuleRTAntenna"):ALLEVENTNAMES:Find("Deactivate") > -1 { - p:GetModule("ModuleRTAntenna"):DoEvent("Deactivate"). - } -} - -when SHIP:ALTITUDE - SHIP:GEOPOSITION:TERRAINHEIGHT < 2500 then { - CHUTES on. -} - -wait until false. +runoncepath("/lib/reentry"). +PerformReentry(). diff --git a/prog/rocket.ks b/prog/rocket.ks index 41f3d3d..59a29df 100644 --- a/prog/rocket.ks +++ b/prog/rocket.ks @@ -6,6 +6,7 @@ runoncepath("/lib/throttle"). runoncepath("/lib/stabilize_rocket"). runoncepath("/lib/launch_rocket"). runoncepath("/lib/sensors"). +runoncepath("/lib/reentry"). clearguis(). @@ -71,6 +72,17 @@ MakeMenu( } ). +MakeMenu( + stk, + MakeButton(rows[1], "REENTRY"), + List(), + "Execute", + { + parameter options. + PerformReentry(). + } +). + MakeButton(rows[1], "HOVER", { Hover(). }). MakeButton(rows[1], "LAND", { Land(). }).