diff --git a/boot/debug_satellite.ks b/boot/debug_satellite.ks new file mode 100644 index 0000000..32d7d6c --- /dev/null +++ b/boot/debug_satellite.ks @@ -0,0 +1 @@ +runpath("0:/boot/satellite", true). diff --git a/boot/satellite.ks b/boot/satellite.ks index 0994822..3da8f9c 100644 --- a/boot/satellite.ks +++ b/boot/satellite.ks @@ -12,7 +12,8 @@ local compiled is list( local copied is list( "/lib/ui", "/prog/execnode", - "/prog/circ" + "/prog/circ", + "/prog/satdeploy" ). Bootstrap( diff --git a/lib/navigation.ks b/lib/navigation.ks index eb0bc74..a4c33ca 100644 --- a/lib/navigation.ks +++ b/lib/navigation.ks @@ -17,12 +17,32 @@ function GetAscentVector { return newHeading. } +// Create a node that will circularize the orbit. +// 'where' can be one of: +// the special string "APO", for the next Apoapsis. +// the special string "PERI", for the next Periapsis. +// a time value (either a Time struct or a scalar), representing a target time. function CreateCircularizationNode { - parameter nodeAtPeriapsis is false. + parameter where is "APO". - local dt is choose SHIP:ORBIT:ETA:PERIAPSIS if nodeAtPeriapsis else SHIP:ORBIT:ETA:APOAPSIS. - local a is choose SHIP:ORBIT:PERIAPSIS if nodeAtPeriapsis else SHIP:ORBIT:APOAPSIS. - local t is TIME + dt. + local dt is 0. + local a is 0. + local t is 0. + if where:IsType("String") { + if where = "APO" { + set dt to SHIP:ORBIT:ETA:APOAPSIS. + set a to SHIP:ORBIT:APOAPSIS. + } else if where = "PERI" { + set dt to SHIP:ORBIT:ETA:PERIAPSIS. + set a to SHIP:ORBIT:PERIAPSIS. + } else { + print "WARNING: Invalid string passed to CreateCirculazationNode(). Node is invalid.". + } + + set t to TIME + dt. + } else { + set t to where. + } local Vc is sqrt(SHIP:BODY:MU/(SHIP:BODY:RADIUS + a)). local dV is Vc - VelocityAt(SHIP, t):ORBIT:MAG. diff --git a/prog/satdeploy.ks b/prog/satdeploy.ks new file mode 100644 index 0000000..7ec7700 --- /dev/null +++ b/prog/satdeploy.ks @@ -0,0 +1,26 @@ +// Run this program on a staged multi-satellite deploy mission. (e.g. using a fairing with interstage nodes and stack separators) To use: +// +// 1. Make sure the next stage will decouple a satellite and activate its engines. +// 2. Pull up the PAW for the satellite's probe core and "Control from Here". +// 3. Run this program from that satellite's computer. +// +// This program will decouple the satellite and circularize its orbit. Ideally done on a resonant satellite injection orbit. + +@lazyglobal off. + +parameter name is "New Satellite". + +runoncepath("/lib/navigation"). +runoncepath("/lib/node"). + +stage. +PANELS on. +set SHIP:NAME to name. +CreateCircularizationNode(TIME + 2). +ExecNode(). + +for p in SHIP:PARTS { + if p:MODULES:Find("ModuleRTAntenna") > -1 { + p:GetModule("ModuleRTAntenna"):DoEvent("ACTIVATE"). + } +}