Use a time-based approach for the pitch instead of just a lead angle and a prayer.

This commit is contained in:
Anna Rose 2021-08-21 01:46:53 -04:00
parent d659889b82
commit 15c479cd18
3 changed files with 20 additions and 6 deletions

View File

@ -53,6 +53,7 @@ function compileFile {
if debug {
CopyPath("0:" + src + ".ks", "1:" + dest + ".ks").
return.
}
compile "0:" + src.

View File

@ -22,12 +22,24 @@ function getPitch {
return 90 - vectorangle(SHIP:UP:FOREVECTOR, v).
}
// Given a target (end) pitch, a target duration, and a start time,
// returns the correct current heading.
function pitchProgram {
parameter endPitch, duration, startTime.
// what percent through the duration are we?
local elapsedP is (TIME:SECONDS - startTime) / duration.
local p is endPitch * elapsedP.
return Heading(90, 90 - p, 270).
}
function Launch {
parameter apoapsisTarget is 80000.
parameter atmoTWR is 2.0.
parameter leadAngle is 2.
// parameter leadAngle is 2.
parameter minPitch is 5.
parameter initialPitch is 10.
parameter initialPitch is 20.
parameter pitchTime is 30.
parameter autoStage is true.
// Configure subsystems.
@ -71,8 +83,9 @@ function Launch {
wait until SHIP:VERTICALSPEED > 100.
print "Phase 2: Initial Pitch.".
lock STEERING to getAscentDir(leadAngle, minPitch).
wait until getPitch(SHIP:SRFPROGRADE:FOREVECTOR) <= 90-initialPitch.
local startTime is TIME:SECONDS.
lock STEERING to pitchProgram(initialPitch, pitchTime, startTime).
wait pitchTime.
print "Phase 3: Stable Prograde Boost.".
lock STEERING to getAscentDir(0, minPitch).

View File

@ -94,7 +94,7 @@ MakeMenu(
List(
List("Target Apoapsis", "SCALAR", "80000"),
List("Initial Pitch", "SCALAR", "20"),
List("Lead Angle", "SCALAR", "2"),
List("Pitch Time", "SCALAR", "45"),
List("Atmo TWR", "SCALAR", "2.0"),
List("Minimum Pitch", "SCALAR", "5"),
List("Autostage", "BOOL", true)
@ -105,9 +105,9 @@ MakeMenu(
Launch(
options["Target Apoapsis"]:TEXT:ToNumber(),
options["Atmo TWR"]:TEXT:ToNumber(),
options["Lead Angle"]:TEXT:ToNumber(),
options["Minimum Pitch"]:TEXT:ToNumber(),
options["Initial Pitch"]:TEXT:ToNumber(),
options["Pitch Time"]:TEXT:ToNumber(),
options["Autostage"]:PRESSED
).
}