Compare commits
3 Commits
main
...
nodeless-l
Author | SHA1 | Date | |
---|---|---|---|
d44ed775df | |||
d353181cf9 | |||
82e456be70 |
|
@ -92,8 +92,8 @@ function Launch {
|
||||||
lock THROTTLE to 0.0.
|
lock THROTTLE to 0.0.
|
||||||
set SHIP:CONTROL:PILOTMAINTHROTTLE to 0.
|
set SHIP:CONTROL:PILOTMAINTHROTTLE to 0.
|
||||||
wait 0.001. // make sure these control updates get applied
|
wait 0.001. // make sure these control updates get applied
|
||||||
add CreateCircularizationNode().
|
|
||||||
ExecNode().
|
insertionBurn(apoapsisTarget).
|
||||||
|
|
||||||
print "Ascent Complete.".
|
print "Ascent Complete.".
|
||||||
set SHIP:CONTROL:PILOTMAINTHROTTLE to 0.
|
set SHIP:CONTROL:PILOTMAINTHROTTLE to 0.
|
||||||
|
@ -101,3 +101,54 @@ function Launch {
|
||||||
unlock STEERING.
|
unlock STEERING.
|
||||||
SAS on.
|
SAS on.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calculate and perform the insertion burn for orbit.
|
||||||
|
// The reason to prefer this over CreateCircularizationNode() and ExecNode() is that the amount of RCS needed
|
||||||
|
// to vector into position during launch adjusts our orbit significantly. This gives us a "wait until" that
|
||||||
|
// serves the specific needs of launch.
|
||||||
|
// It also makes automated launches possible before maneuver nodes are unlocked.
|
||||||
|
//
|
||||||
|
// TODO: Refactor code reuse between this function and ExecNode().
|
||||||
|
//
|
||||||
|
// prerequisites:
|
||||||
|
// * Vessel is still behind the Apoapsis
|
||||||
|
// * Apoapsis is at the target height
|
||||||
|
function insertionBurn {
|
||||||
|
parameter apoapsisTarget.
|
||||||
|
|
||||||
|
// vector is prograde but only on the horizonal plane
|
||||||
|
print "Adjusting heading.".
|
||||||
|
local lock horizon is Vxcl(SHIP:UP:FOREVECTOR, SHIP:PROGRADE:FOREVECTOR).
|
||||||
|
lock STEERING to LookDirUp(horizon, SHIP:FACING:TOPVECTOR).
|
||||||
|
|
||||||
|
// calculate the deltaV to get us to the target velocity, for calculating burn start time.
|
||||||
|
local t is TIME + SHIP:ORBIT:ETA:APOAPSIS.
|
||||||
|
local Vc is sqrt(SHIP:BODY:MU/(PositionAt(SHIP, t) - SHIP:BODY:POSITION):MAG).
|
||||||
|
local dV is Vc - VelocityAt(SHIP, t):ORBIT:MAG.
|
||||||
|
|
||||||
|
if WillStage(dV) {
|
||||||
|
when FlameOut() then {
|
||||||
|
print "Flameout detected. Staging.".
|
||||||
|
stage.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculate the total burn time (Tb) and the burn start time (Ts)
|
||||||
|
local Tb is BurnTime(dV).
|
||||||
|
local Ts is TIME + SHIP:OBT:ETA:APOAPSIS - BurnTime(dV / 2).
|
||||||
|
|
||||||
|
// warp to the burn point
|
||||||
|
print "Waiting for burn window.".
|
||||||
|
wait until (VAng(SHIP:FACING:FOREVECTOR, STEERINGMANAGER:TARGET:FOREVECTOR) <= 0.5) OR (TIME > Ts).
|
||||||
|
if TIME < Ts - 2 {
|
||||||
|
KUNIVERSE:TIMEWARP:WarpTo(Ts:SECONDS - 2).
|
||||||
|
}
|
||||||
|
wait until SHIP:UNPACKED.
|
||||||
|
wait until TIME > Ts.
|
||||||
|
|
||||||
|
// burn until periapsis is clear
|
||||||
|
print "Circularizing orbit.".
|
||||||
|
lock THROTTLE to 1.0.
|
||||||
|
wait until SHIP:OBT:PERIAPSIS > apoapsisTarget.
|
||||||
|
lock THROTTLE to 0.0.
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user