From ef8ae9e9cc113ad5546380cd79f09ec153ab5e91 Mon Sep 17 00:00:00 2001 From: kcjennin Date: Sun, 7 Jun 2026 01:41:03 -0700 Subject: [PATCH] Remove RT and tweaked ascent profile --- boot/boot.ks | 10 +++--- scripts/ascent.ks | 81 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 66 insertions(+), 25 deletions(-) diff --git a/boot/boot.ks b/boot/boot.ks index f3d852f..363e702 100644 --- a/boot/boot.ks +++ b/boot/boot.ks @@ -1,6 +1,6 @@ wait until ship:unpacked. -if addons:RT:hasKSCConnection(ship) { - runPath("0:/scripts/basic.ks"). -} else { - print "No connection to the KSC". -} +runPath("0:/scripts/basic.ks"). +//if addons:RT:hasKSCConnection(ship) { +//} else { +// print "No connection to the KSC". +//} diff --git a/scripts/ascent.ks b/scripts/ascent.ks index 99ceb5e..94afc04 100644 --- a/scripts/ascent.ks +++ b/scripts/ascent.ks @@ -13,6 +13,47 @@ function signedHeading { return mod(hdg + 360, 360). } +function gravityTurn { + parameter targetHeading. + + set tarSteer to heading(targetHeading, 90). + lock steering to tarSteer. + until ship:velocity:surface:mag >= 100 { + set tarSteer to heading(targetHeading, 90 - (ship:velocity:surface:mag / 20)). + wait 0. + } + + // lock steering to the target heading, but account for drift, and the pitch + // of the surface normal vector + lock calculatedHeading to mod(targetHeading + 2 * (targetHeading - signedHeading()) + 360, 360). + lock steering to heading( + calculatedHeading, + max(5, 90 - vAng(up:vector, ship:srfprograde:vector)) + ). + print "Locked steering to surface prograde pitch and target heading". + +} + +// function structuredAscent { +// parameter targetHeading. + +// set tarSteer to heading(targetHeading, 90). +// lock steering to tarSteer. +// until ship:velocity:surface:mag >= 100 { +// set tarSteer to heading(targetHeading, 90 - (ship:velocity:surface:mag / 10)). +// wait 0. +// } + +// // lock steering to the target heading, but account for drift, and the pitch +// // of the surface normal vector +// lock calculatedHeading to mod(targetHeading + 2 * (targetHeading - signedHeading()) + 360, 360). +// lock steering to heading( +// calculatedHeading, +// max(5, 90 - vAng(up:vector, ship:srfprograde:vector)) +// ). +// print "Locked steering to surface prograde pitch and target heading". +// } + function basicAscent { parameter targetHeading is 90, targetAltitude is 80000. @@ -40,22 +81,7 @@ function basicAscent { return true. }. - // initial pitch-over - set tarSteer to heading(targetHeading, 90). - lock steering to tarSteer. - until ship:velocity:surface:mag >= 100 { - set tarSteer to heading(targetHeading, 90 - (ship:velocity:surface:mag / 10)). - wait 0. - } - - // lock steering to the target heading, but account for drift, and the pitch - // of the surface normal vector - lock calculatedHeading to mod(targetHeading + 2 * (targetHeading - signedHeading()) + 360, 360). - lock steering to heading( - calculatedHeading, - max(5, 90 - vAng(up:vector, ship:srfprograde:vector)) - ). - print "Locked steering to surface prograde pitch and target heading". + gravityTurn(targetHeading). when ship:q < 0.01 then { for f in fairings { @@ -69,16 +95,31 @@ function basicAscent { panels on. radiators on. for a in antennas { - set m to a:getmodule("ModuleRTAntenna"). - if m:hasevent("activate") m:doevent("activate"). - if m:getfield("target") = "no-target" m:setfield("target", "Mission Control"). + set m to a:getmodule("ModuleDeployableAntenna"). + if m:hasevent("extend antenna") m:doevent("extend antenna"). } } + // try to limit the throttle to get a good ascent + set ascentPID to pidLoop(1/30, 0, 0, 0.1, 1). + set ascentPID:setpoint to 60. + set ascentThrottle to 1. + lock throttle to ascentThrottle. + lock pitchAngle to 90 - vAng(up:vector, ship:prograde:vector). + until ship:apoapsis >= targetAltitude or pitchAngle < 10 { + set ascentThrottle to ascentPID:update(time:seconds, eta:apoapsis). + } + + // we're pitched down so much we might as well just burn + if ship:apoapsis < targetAltitude { + lock throttle to 1. + wait until ship:apoapsis >= targetAltitude. + } + // coast to apoapsis - wait until ship:apoapsis >= targetAltitude. unlock calculatedHeading. + unlock pitchAngle. lock steering to ship:prograde. lock throttle to 0.