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

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

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).