Fix staging and burn angle.
This commit is contained in:
parent
d353181cf9
commit
d44ed775df
|
@ -108,6 +108,8 @@ function Launch {
|
||||||
// serves the specific needs of launch.
|
// serves the specific needs of launch.
|
||||||
// It also makes automated launches possible before maneuver nodes are unlocked.
|
// It also makes automated launches possible before maneuver nodes are unlocked.
|
||||||
//
|
//
|
||||||
|
// TODO: Refactor code reuse between this function and ExecNode().
|
||||||
|
//
|
||||||
// prerequisites:
|
// prerequisites:
|
||||||
// * Vessel is still behind the Apoapsis
|
// * Vessel is still behind the Apoapsis
|
||||||
// * Apoapsis is at the target height
|
// * Apoapsis is at the target height
|
||||||
|
@ -116,7 +118,7 @@ function insertionBurn {
|
||||||
|
|
||||||
// vector is prograde but only on the horizonal plane
|
// vector is prograde but only on the horizonal plane
|
||||||
print "Adjusting heading.".
|
print "Adjusting heading.".
|
||||||
local horizon is Vxcl(SHIP:UP:FOREVECTOR, SHIP:PROGRADE:FOREVECTOR).
|
local lock horizon is Vxcl(SHIP:UP:FOREVECTOR, SHIP:PROGRADE:FOREVECTOR).
|
||||||
lock STEERING to LookDirUp(horizon, SHIP:FACING:TOPVECTOR).
|
lock STEERING to LookDirUp(horizon, SHIP:FACING:TOPVECTOR).
|
||||||
|
|
||||||
// calculate the deltaV to get us to the target velocity, for calculating burn start time.
|
// calculate the deltaV to get us to the target velocity, for calculating burn start time.
|
||||||
|
@ -124,15 +126,22 @@ function insertionBurn {
|
||||||
local Vc is sqrt(SHIP:BODY:MU/(PositionAt(SHIP, t) - SHIP:BODY:POSITION):MAG).
|
local Vc is sqrt(SHIP:BODY:MU/(PositionAt(SHIP, t) - SHIP:BODY:POSITION):MAG).
|
||||||
local dV is Vc - VelocityAt(SHIP, t):ORBIT: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)
|
// calculate the total burn time (Tb) and the burn start time (Ts)
|
||||||
local Tb is BurnTime(dV).
|
local Tb is BurnTime(dV).
|
||||||
local Ts is TIME + SHIP:OBT:ETA:APOAPSIS - BurnTime(dV / 2).
|
local Ts is TIME + SHIP:OBT:ETA:APOAPSIS - BurnTime(dV / 2).
|
||||||
|
|
||||||
// warp to the burn point
|
// warp to the burn point
|
||||||
print "Waiting for burn window.".
|
print "Waiting for burn window.".
|
||||||
wait until (VAng(SHIP:FACING:FOREVECTOR, STEERINGMANAGER:TARGET:FOREVECTOR) <= 1) OR (TIME > Ts).
|
wait until (VAng(SHIP:FACING:FOREVECTOR, STEERINGMANAGER:TARGET:FOREVECTOR) <= 0.5) OR (TIME > Ts).
|
||||||
if TIME < Ts - 2 {
|
if TIME < Ts - 2 {
|
||||||
KUNIVERSE:TIMEWARP:WarpTo(Ts - 2).
|
KUNIVERSE:TIMEWARP:WarpTo(Ts:SECONDS - 2).
|
||||||
}
|
}
|
||||||
wait until SHIP:UNPACKED.
|
wait until SHIP:UNPACKED.
|
||||||
wait until TIME > Ts.
|
wait until TIME > Ts.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user