Modify launch code to be smoother.
This commit is contained in:
parent
fcf93c4106
commit
2e7b904216
|
@ -1,15 +1,14 @@
|
|||
runoncepath("lib/throttle").
|
||||
runoncepath("lib/navigation").
|
||||
runoncepath("lib/node").
|
||||
|
||||
// Calculate the vector at which to ascend.
|
||||
// This is basically prograde plus some anti-rotation logic and a lower bound.
|
||||
function getAscentVector {
|
||||
parameter minPitch.
|
||||
// face prograde, but hold a solid eastern heading and don't
|
||||
// Calculate the direction to lock during ascent.
|
||||
function getAscentDir {
|
||||
parameter leadAngle is 5.
|
||||
parameter minPitch is 5.
|
||||
// face just beneath prograde, but hold a solid eastern heading and don't
|
||||
// rotate the ship
|
||||
local newHeading is lookdirup(SHIP:SRFPROGRADE:FOREVECTOR,
|
||||
heading(90, 0, 270):TOPVECTOR).
|
||||
local newHeading is lookdirup(SHIP:SRFPROGRADE:FOREVECTOR, heading(90, 0, 270):TOPVECTOR).
|
||||
set newHeading to angleaxis(leadAngle, newHeading:TOPVECTOR)*newHeading.
|
||||
if getPitch(newHeading:FOREVECTOR) < minPitch {
|
||||
set newHeading to heading(90, minPitch, 270).
|
||||
}
|
||||
|
@ -26,7 +25,7 @@ function Launch {
|
|||
parameter APOAPSIS_TARGET is 80000.
|
||||
parameter ATMO_TWR is 1.6.
|
||||
parameter GRAVITY_TURN_START is 8000.
|
||||
parameter GRAVITY_PITCH is 75.
|
||||
parameter LEAD_ANGLE is 5.
|
||||
// parameter INITIAL_PITCH is 85.
|
||||
parameter MINIMUM_PITCH is 5.
|
||||
|
||||
|
@ -51,7 +50,7 @@ function Launch {
|
|||
return true.
|
||||
}
|
||||
|
||||
// Hold throttle to maintain 1.5 TWR.
|
||||
// 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(ATMO_TWR).
|
||||
|
@ -61,26 +60,10 @@ function Launch {
|
|||
lock STEERING to heading(90,90,270).
|
||||
stage.
|
||||
|
||||
// wait until SHIP:ALTITUDE > 200.
|
||||
// print "Vectoring away from launchpad.".
|
||||
// lock STEERING to heading(90, INITIAL_PITCH, 270).
|
||||
wait until SHIP:ALTITUDE > GRAVITY_TURN_START.
|
||||
|
||||
print "Pitching for gravity turn.".
|
||||
// Pitch over...
|
||||
lock STEERING to heading(90, GRAVITY_PITCH, 270).
|
||||
// Wait until we have rotated to (approximately) that pitch...
|
||||
wait until vectorangle(
|
||||
SHIP:FACING:FOREVECTOR,
|
||||
STEERINGMANAGER:TARGET:FOREVECTOR)
|
||||
< 0.5.
|
||||
|
||||
// then wait until Prograde catches up (or passes us).
|
||||
local targetPitch is GetPitch(STEERINGMANAGER:TARGET:FOREVECTOR).
|
||||
wait until GetPitch(SHIP:SRFPROGRADE:FOREVECTOR) <= targetPitch.
|
||||
|
||||
print "Locking to prograde, letting gravity do the hard work.".
|
||||
lock STEERING to getAscentVector(MINIMUM_PITCH).
|
||||
print "Turning gravity...".
|
||||
lock STEERING to getAscentDir(LEAD_ANGLE, MINIMUM_PITCH).
|
||||
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.
|
||||
|
||||
lock THROTTLE to 1.0.
|
||||
|
|
|
@ -80,10 +80,9 @@ MakeMenu(
|
|||
List(
|
||||
List("Target Apoapsis", "SCALAR", "80000"),
|
||||
List("Atmo TWR", "SCALAR", "1.8"),
|
||||
// List("Initial Pitch", "SCALAR", "85"),
|
||||
List("Minimum Pitch", "SCALAR", "5"),
|
||||
List("Gravity Turn Alt", "SCALAR", "8000"),
|
||||
List("Gravity Turn Pitch", "SCALAR", "75")
|
||||
List("Lead Angle", "SCALAR", "5"),
|
||||
List("Minimum Pitch", "SCALAR", "5")
|
||||
),
|
||||
"Execute",
|
||||
{
|
||||
|
@ -92,8 +91,7 @@ MakeMenu(
|
|||
options["Target Apoapsis"]:TEXT:ToNumber(),
|
||||
options["Atmo TWR"]:TEXT:ToNumber(),
|
||||
options["Gravity Turn Alt"]:TEXT:ToNumber(),
|
||||
options["Gravity Turn Pitch"]:TEXT:ToNumber(),
|
||||
// options["Initial Pitch"]:TEXT:ToNumber(),
|
||||
options["Lead Angle"]:TEXT:ToNumber(),
|
||||
options["Minimum Pitch"]:TEXT:ToNumber()
|
||||
).
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user