Improvements to auto-launch script, inspired partially by the discussion at https://amyparent.com/blog/automating-rocket-launches.html
This commit is contained in:
@ -24,10 +24,10 @@ function getPitch {
|
||||
|
||||
function Launch {
|
||||
parameter apoapsisTarget is 80000.
|
||||
parameter atmoTWR is 1.8.
|
||||
parameter gravityTurnStart is 8000.
|
||||
parameter leadAngle is 5.
|
||||
parameter atmoTWR is 2.0.
|
||||
parameter leadAngle is 2.
|
||||
parameter minPitch is 5.
|
||||
parameter initialPitch is 10.
|
||||
parameter autoStage is true.
|
||||
|
||||
// Configure subsystems.
|
||||
@ -53,33 +53,40 @@ function Launch {
|
||||
}
|
||||
}
|
||||
|
||||
// Hold throttle to maintain target TWR.
|
||||
// We do *not* use a PID Loop here because we can
|
||||
// calculate the correct value discretely.
|
||||
lock THROTTLE to ThrottleToTWR(atmoTWR).
|
||||
print "Throttling to maintain a TWR of " + atmoTWR.
|
||||
// Drag controls
|
||||
when SHIP:VERTICALSPEED > 340 then {
|
||||
print "Throttling for drag control.".
|
||||
lock THROTTLE to ThrottleToTWR(atmoTWR).
|
||||
// TODO: if we have a pressure sensor we can use it to decide when to kick the throttle up instead, neat solution for e.g. Duna and Eve.
|
||||
when SHIP:ALTITUDE > 32000 then {
|
||||
lock THROTTLE to 1.0.
|
||||
}
|
||||
}
|
||||
|
||||
// Main ascent control.
|
||||
|
||||
print "Phase 1: Vertical Ascent.".
|
||||
lock THROTTLE to 1.0.
|
||||
lock STEERING to Heading(90,90,270).
|
||||
stage.
|
||||
|
||||
wait until SHIP:ALTITUDE > gravityTurnStart.
|
||||
|
||||
print "Turning gravity...".
|
||||
wait until SHIP:VERTICALSPEED > 100.
|
||||
|
||||
print "Phase 2: Initial Pitch.".
|
||||
lock STEERING to getAscentDir(leadAngle, minPitch).
|
||||
wait until SHIP:ALTITUDE > 32000. // todo: if we have a pressure sensor we can use it to decide when to kick the throttle up instead, neat solution for e.g. Duna and Eve.
|
||||
wait until getPitch(SHIP:SRFPROGRADE:FOREVECTOR) <= 90-initialPitch.
|
||||
|
||||
lock THROTTLE to 1.0.
|
||||
print "Phase 3: Stable Prograde Boost.".
|
||||
lock STEERING to getAscentDir(0, minPitch).
|
||||
wait until SHIP:ORBIT:APOAPSIS > apoapsisTarget.
|
||||
|
||||
// TODO: A smoother approach based on target orbital velocity should be considered.
|
||||
print "Phase 4: Circularization Maneuver.".
|
||||
lock THROTTLE to 0.0.
|
||||
set SHIP:CONTROL:PILOTMAINTHROTTLE to 0.
|
||||
wait 0.001. // make sure these control updates get applied
|
||||
|
||||
print "Target apoapsis acquired. Creating maneuver node.".
|
||||
add CreateCircularizationNode().
|
||||
ExecNode().
|
||||
print "Orbit acquired. Releasing controls. Good luck, Kerman.".
|
||||
|
||||
print "Ascent Complete.".
|
||||
unlock THROTTLE.
|
||||
unlock STEERING.
|
||||
SAS on.
|
||||
|
Reference in New Issue
Block a user