f08a34d221
- lander.ks: Replace fixed suicide burn with dynamic throttle control using vertical fraction, gateRatio, and finalPhase logic; simplify post-land sequence to SAS stabilityassist - transfer.ks: Replace hardcoded Mun target with GUI popup menu populated from body:orbitingchildren - ascent.ks: Change fairing jettison trigger from dynamic pressure to altitude > atm height; guard antenna extension with hasmodule check - basic.ks: Append stayRunner invocation at end of script - boot/boot.ks: Remove commented RT connection block; add newline before runPath - boot/testing.ks: Switch to volume 0 and use relative paths for transfer and doManeuver scripts - boot/heloBoot.ks: Delete unused boot file
86 lines
2.5 KiB
Plaintext
86 lines
2.5 KiB
Plaintext
run once maneuver.
|
|
|
|
function groundSlope {
|
|
parameter xOffset is 0, yOffset is 0.
|
|
local east is vCrs(north:vector, up:vector).
|
|
|
|
local center is (
|
|
ship:position +
|
|
(yOffset * north:vector) +
|
|
(xOffset * east)
|
|
).
|
|
|
|
local a is body:geopositionof(center + 5 * north:vector).
|
|
local b is body:geopositionof(center - 3 * north:vector + 4 * east).
|
|
local c is body:geopositionof(center - 3 * north:vector - 4 * east).
|
|
|
|
local aVec is a:altitudeposition(a:terrainheight).
|
|
local bVec is b:altitudeposition(b:terrainheight).
|
|
local cVec is c:altitudeposition(c:terrainheight).
|
|
|
|
local slope is vCrs(cVec - aVec, bVec - aVec):normalized.
|
|
// local centerPos is body:geopositionof(center).
|
|
// set slopeDraw to vecDraw(
|
|
// centerPos:altitudeposition(centerPos:terrainheight),
|
|
// slope,
|
|
// green,
|
|
// "",
|
|
// 10,
|
|
// true
|
|
// ).
|
|
|
|
return slope.
|
|
}
|
|
|
|
lock h to ship:bounds:bottomaltradar.
|
|
lock velVec to ship:velocity:surface.
|
|
lock speed to velVec:mag.
|
|
lock vSpeed to ship:verticalspeed.
|
|
lock g to body:mu / ((body:radius + ship:altitude)^2).
|
|
lock maxA to ship:maxthrust / ship:mass.
|
|
lock vertFrac to max(abs(vSpeed) / max(speed, 0.001), 0.05).
|
|
|
|
set margin to 30. // safety buffer, meters
|
|
set gateRatio to 0.9. // start burn when required decel hits this fraction of max
|
|
set targetV to -3. // final drift speed, m/s
|
|
set burning to false.
|
|
set finalPhase to false.
|
|
|
|
lock maxDecel to max(maxA * vertFrac - g, 0.01).
|
|
lock requiredDecel to vSpeed^2 / (2 * max(h - margin, 0.1)).
|
|
lock neededA to (requiredDecel / vertFrac) + g.
|
|
lock hoverA to g / vertFrac. // accel needed to hold current vertical speed constant
|
|
|
|
set tval to 0.
|
|
lock throttle to tval.
|
|
lock steering to srfretrograde.
|
|
|
|
until h < 1 {
|
|
if not burning and requiredDecel >= gateRatio * maxDecel {
|
|
set burning to true.
|
|
}
|
|
|
|
if burning and not finalPhase and vSpeed >= targetV {
|
|
set finalPhase to true.
|
|
}
|
|
|
|
if finalPhase {
|
|
set tval to max(0, min(1, hoverA / maxA)).
|
|
} else if burning {
|
|
set tval to max(0, min(1, neededA / maxA)).
|
|
}
|
|
|
|
clearscreen.
|
|
print "Alt AGL : " + round(h, 1) at (4, 0).
|
|
print "VSpeed : " + round(vSpeed, 1) at (4, 1).
|
|
print "Burning : " + burning at (4, 2).
|
|
print "Final phase : " + finalPhase at (4, 3).
|
|
print "Throttle : " + round(tval * 100) at (4, 4).
|
|
wait 0.
|
|
}
|
|
|
|
lock throttle to 0.
|
|
unlock throttle.
|
|
unlock steering.
|
|
sas on.
|
|
set sasMode to "STABILITYASSIST". |