Add autostage option, fix bugs, tune things.
This commit is contained in:
@ -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,12 +43,14 @@ function Launch {
|
||||
|
||||
// staging logic. Stage as many times as needed until we finish ascent.
|
||||
// Once Apo target is attained just drop this trigger.
|
||||
when FlameOut() or SHIP:ORBIT:APOAPSIS > APOAPSIS_TARGET then {
|
||||
if SHIP:ORBIT:APOAPSIS > APOAPSIS_TARGET {
|
||||
return false.
|
||||
if AUTOSTAGE {
|
||||
when FlameOut() or SHIP:ORBIT:APOAPSIS > APOAPSIS_TARGET then {
|
||||
if SHIP:ORBIT:APOAPSIS > APOAPSIS_TARGET {
|
||||
return false.
|
||||
}
|
||||
stage.
|
||||
return true.
|
||||
}
|
||||
stage.
|
||||
return true.
|
||||
}
|
||||
|
||||
// Hold throttle to maintain target TWR.
|
||||
|
@ -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.
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user