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