Initial import
This commit is contained in:
85
lib/stage/agena.ks
Normal file
85
lib/stage/agena.ks
Normal file
@@ -0,0 +1,85 @@
|
||||
@lazyglobal off.
|
||||
|
||||
runoncepath("0:/lib/common.ks").
|
||||
|
||||
global agena is lex(
|
||||
"orbit", do_orbit@,
|
||||
"power_down", power_down@,
|
||||
"power_up", power_up@,
|
||||
"low_power", low_power@,
|
||||
"separate", separate@,
|
||||
"transfer_burn", transfer_burn@
|
||||
).
|
||||
|
||||
local function do_orbit {
|
||||
parameter hdg.
|
||||
|
||||
print "Agena startup".
|
||||
print "Warping to burn".
|
||||
set warpmode to "physics".
|
||||
set warp to 3.
|
||||
wait until eta:apoapsis < 140.
|
||||
set warp to 0.
|
||||
wait until kuniverse:timewarp:issettled.
|
||||
|
||||
print "RCS On. Locking heading".
|
||||
rcs on.
|
||||
local target is heading(hdg, ship:obt:trueanomaly - 180, -hdg).
|
||||
lock steering to target.
|
||||
wait until eta:apoapsis < 120.
|
||||
|
||||
print "Throttle up".
|
||||
lock throttle to 1.0.
|
||||
wait 3.
|
||||
stage.
|
||||
print "GO GO GO".
|
||||
wait until ship:velocity:orbit:mag > circular_vel() and ship:obt:periapsis > 140000.
|
||||
rcs off.
|
||||
lock throttle to 0.0.
|
||||
unlock steering.
|
||||
wait 0.
|
||||
print "Agena done".
|
||||
}
|
||||
|
||||
local function power_down {
|
||||
local avionics is ship:partsdubbed("agena-avionics")[0].
|
||||
local avi_mod is avionics:getmodule("ModuleProceduralAvionics").
|
||||
avi_mod:doaction("shutdown avionics", true).
|
||||
}
|
||||
|
||||
local function power_up {
|
||||
local avionics is ship:partsdubbed("agena-avionics")[0].
|
||||
local avi_mod is avionics:getmodule("ModuleProceduralAvionics").
|
||||
avi_mod:doaction("activate avionics", true).
|
||||
}
|
||||
|
||||
local function low_power {
|
||||
local avionics is ship:partsdubbed("agena-avionics")[0].
|
||||
local power is avionics:resources[0].
|
||||
return power:amount / power:capacity < 0.1.
|
||||
}
|
||||
|
||||
local function separate {
|
||||
rcs on.
|
||||
lock steering to prograde.
|
||||
lock throttle to 1.0.
|
||||
wait 5.
|
||||
lock throttle to 0.0.
|
||||
unlock steering.
|
||||
rcs off.
|
||||
}
|
||||
|
||||
local function transfer_burn {
|
||||
parameter target_vel.
|
||||
|
||||
// Shutdown engine for ullage
|
||||
local engine is ship:partsdubbed("ROE-Agena")[0].
|
||||
engine:shutdown().
|
||||
lock throttle to 1.0.
|
||||
wait 3.
|
||||
// Engine on
|
||||
engine:activate().
|
||||
wait until ship:velocity:orbit:mag >= target_vel.
|
||||
lock throttle to 0.0.
|
||||
wait 0.
|
||||
}
|
||||
Reference in New Issue
Block a user