Add autostage option, fix bugs, tune things.
This commit is contained in:
parent
0481123487
commit
bbf1d118e3
|
@ -28,6 +28,7 @@ function Launch {
|
|||
parameter LEAD_ANGLE is 5.
|
||||
// parameter INITIAL_PITCH is 85.
|
||||
parameter MINIMUM_PITCH is 5.
|
||||
parameter AUTOSTAGE is true.
|
||||
|
||||
// Configure subsystems.
|
||||
RCS off.
|
||||
|
@ -42,6 +43,7 @@ function Launch {
|
|||
|
||||
// staging logic. Stage as many times as needed until we finish ascent.
|
||||
// Once Apo target is attained just drop this trigger.
|
||||
if AUTOSTAGE {
|
||||
when FlameOut() or SHIP:ORBIT:APOAPSIS > APOAPSIS_TARGET then {
|
||||
if SHIP:ORBIT:APOAPSIS > APOAPSIS_TARGET {
|
||||
return false.
|
||||
|
@ -49,6 +51,7 @@ function Launch {
|
|||
stage.
|
||||
return true.
|
||||
}
|
||||
}
|
||||
|
||||
// Hold throttle to maintain target TWR.
|
||||
// We do *not* use a PID Loop here because we can
|
||||
|
|
|
@ -13,6 +13,10 @@ function Land {
|
|||
|
||||
assumeControl().
|
||||
alignForHover().
|
||||
if done {
|
||||
restoreControl().
|
||||
return.
|
||||
}
|
||||
local pid is PIDLoop(0.1, 0.01, 0.01, 0, 1).
|
||||
|
||||
lock THROTTLE to pid:Update(TIME:SECONDS, SHIP:VERTICALSPEED).
|
||||
|
@ -34,6 +38,10 @@ function Hover {
|
|||
|
||||
assumeControl().
|
||||
alignForHover().
|
||||
if done {
|
||||
restoreControl().
|
||||
return.
|
||||
}
|
||||
local throttlePID is PIDLoop(0.1, 0.1, 0.001, 0, 1).
|
||||
set throttlePID:SETPOINT to vertSpeed.
|
||||
lock THROTTLE to throttlePID:Update(TIME:SECONDS, SHIP:VERTICALSPEED).
|
||||
|
@ -43,24 +51,30 @@ function Hover {
|
|||
restoreControl().
|
||||
}
|
||||
|
||||
function hoverVectorVac {
|
||||
parameter top.
|
||||
if SHIP:VERTICALSPEED > 0 {
|
||||
return SHIP:UP.
|
||||
}
|
||||
return LookDirUp(SHIP:SRFRETROGRADE:FOREVECTOR, top).
|
||||
}
|
||||
|
||||
function alignForHover {
|
||||
set cRot to SHIP:FACING:FOREVECTOR.
|
||||
set top to SHIP:FACING:FOREVECTOR.
|
||||
if ReadSensor("PRES") = 0 {
|
||||
// if we're in a vacuum, align with retrograde for smoother horizontal control.
|
||||
lock STEERING to LookDirUp(SHIP:SRFRETROGRADE:FOREVECTOR, cRot).
|
||||
lock STEERING to hoverDirVac(top).
|
||||
print "Aligning with retrograde.".
|
||||
wait until done or VAng(SHIP:FACING:FOREVECTOR, SHIP:SRFRETROGRADE:FOREVECTOR) < 1.
|
||||
wait until done or VAng(SHIP:FACING:FOREVECTOR, hoverDirVac():FOREVECTOR) < 1.
|
||||
if done {
|
||||
restoreControl().
|
||||
return.
|
||||
}
|
||||
} else {
|
||||
// ... otherwise just align vertically.
|
||||
lock STEERING to LookDirUp(SHIP:UP:FOREVECTOR, cRot).
|
||||
lock STEERING to LookDirUp(SHIP:UP:FOREVECTOR, top).
|
||||
print "Aligning vertical.".
|
||||
wait until done or VAng(SHIP:FACING:FOREVECTOR, SHIP:UP:FOREVECTOR) < 1.
|
||||
if done {
|
||||
restoreControl().
|
||||
return.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,8 @@ MakeMenu(
|
|||
List("Atmo TWR", "SCALAR", "1.8"),
|
||||
List("Gravity Turn Alt", "SCALAR", "8000"),
|
||||
List("Lead Angle", "SCALAR", "5"),
|
||||
List("Minimum Pitch", "SCALAR", "5")
|
||||
List("Minimum Pitch", "SCALAR", "5"),
|
||||
List("Autostage", "BOOL", true)
|
||||
),
|
||||
"Execute",
|
||||
{
|
||||
|
@ -92,7 +93,8 @@ MakeMenu(
|
|||
options["Atmo TWR"]:TEXT:ToNumber(),
|
||||
options["Gravity Turn Alt"]:TEXT:ToNumber(),
|
||||
options["Lead Angle"]:TEXT:ToNumber(),
|
||||
options["Minimum Pitch"]:TEXT:ToNumber()
|
||||
options["Minimum Pitch"]:TEXT:ToNumber(),
|
||||
options["Autostage"]:PRESSED
|
||||
).
|
||||
}
|
||||
).
|
||||
|
|
Loading…
Reference in New Issue
Block a user