kOS/launch.ks

87 lines
1.9 KiB
Plaintext
Raw Normal View History

run once "lib/throttle".
run once "lib/navigation".
2021-07-18 08:07:00 +00:00
parameter APOAPSIS_TARGET is 80000.
parameter GRAVITY_TURN_START is 8000.
parameter GRAVITY_PITCH is 75.
parameter INITIAL_PITCH is 85.
SensorCheck().
2021-07-18 08:07:00 +00:00
// Configure subsystems.
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Open Terminal").
RCS off.
SAS off.
// Countdowns are cute.
print "Initiating automated launch sequence".
from { local x is 5. } until x = 0 step { set x to x - 1. } do {
print "..." + x.
wait 0.5.
2021-07-18 08:07:00 +00:00
}
// throttle controls
when TWR() > 1.5 then {
if SHIP:ALTITUDE > 32000 {
lock THROTTLE to 1.0.
return false.
2021-07-18 08:07:00 +00:00
}
lock THROTTLE to ThrottleToTWR(1.5).
return true.
2021-07-18 08:07:00 +00:00
}
// Main ascent control.
lock THROTTLE to 1.0.
lock STEERING to heading(90,90,270).
stage.
2021-07-18 08:07:00 +00:00
// // DEBUG
// until false {
// lock STEERING to heading(90,90,-90).
// wait 3.
// lock STEERING to SHIP:SRFPROGRADE.
// wait 3.
// }
wait until SHIP:ALTITUDE > 200.
lock STEERING to heading(90, GRAVITY_PITCH, 270).
2021-07-18 08:07:00 +00:00
wait until SHIP:ALTITUDE > GRAVITY_TURN_START.
print "Pitching for gravity turn".
// Perform initial pitch...
lock STEERING to heading(90, GRAVITY_PITCH, 270).
// Wait until we have rotated to that pitch...
wait until vectorangle(
SHIP:FACING:FOREVECTOR,
STEERINGMANAGER:TARGET:FOREVECTOR)
< 0.5.
// then wait until Prograde catches up.
wait until vectorangle(
SHIP:SRFPROGRADE:FOREVECTOR,
STEERINGMANAGER:TARGET:FOREVECTOR)
< 0.5.
print "Locking to prograde".
until SHIP:ORBIT:APOAPSIS > 80000 {
// todo: we may need different values for bodies other than Kerbin.
local newHeading is lookdirup(SHIP:SRFPROGRADE:FOREVECTOR,
heading(90, 0, 270):TOPVECTOR).
if GetPitch(newHeading:FOREVECTOR) < 40 {
set newHeading to heading(90, 40, 270).
}
lock STEERING to newHeading.
2021-07-18 08:07:00 +00:00
wait 0.001.
}
print "Releasing controls. Good luck, Kerman!".
lock THROTTLE to 0.0.
wait 0.001.
unlock THROTTLE.
unlock STEERING.
SAS on.
wait 5.
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Close Terminal").