From 0f76fb50c15853f7abfe7eff8a1078b75feda796 Mon Sep 17 00:00:00 2001 From: Amatsugu Date: Sat, 10 Jan 2026 15:59:42 -0500 Subject: [PATCH] beeg sana --- beegSana.ks | 28 ++++++++++++++++++++++++++++ boot/beegSanaBoot.ks | 5 +++++ boot/radenBoot9.ks | 7 +++++++ library/lib_vessel_utils.ks | 28 +++------------------------- poweredLanding.ks | 35 +++++++++++++++++++++-------------- radenLaunch.ks | 31 +++++++++++++++++++++++-------- 6 files changed, 87 insertions(+), 47 deletions(-) create mode 100644 beegSana.ks create mode 100644 boot/beegSanaBoot.ks create mode 100644 boot/radenBoot9.ks diff --git a/beegSana.ks b/beegSana.ks new file mode 100644 index 0000000..2b9884c --- /dev/null +++ b/beegSana.ks @@ -0,0 +1,28 @@ +run "defaults". + +run "poweredLanding". + +declare function Reentry{ + print "Re-entry.". + lock steering to heading(90, 60, 0). + ag1 on. + rcs off. + + wait until (groundSpeed < 500 and altitude < 11000). + print "Flipping.". + rcs on. + lock steering to srfRetrograde. +} + +wait until (periapsis < 0 and throttle = 0). +print "Prep for re-entry". +sas off. +CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Open Terminal"). +lock steering to heading(90, 60, 0). +wait until (altitude < 70000). +Reentry(). +brakes on. +Descent(200, 20). +Landing(0, -20). + + diff --git a/boot/beegSanaBoot.ks b/boot/beegSanaBoot.ks new file mode 100644 index 0000000..c29ddcf --- /dev/null +++ b/boot/beegSanaBoot.ks @@ -0,0 +1,5 @@ +wait until ship:unpacked. +clearscreen. +switch to 0. + +run beegSana. \ No newline at end of file diff --git a/boot/radenBoot9.ks b/boot/radenBoot9.ks new file mode 100644 index 0000000..acecb09 --- /dev/null +++ b/boot/radenBoot9.ks @@ -0,0 +1,7 @@ +wait until ship:unpacked. +set rotateSpeed to 100. +if ship:status = "LANDED" or ship:status = "PRELAUNCH" { + clearscreen. + switch to 0. + run radenLaunch. +} \ No newline at end of file diff --git a/library/lib_vessel_utils.ks b/library/lib_vessel_utils.ks index eb55d52..3940bd4 100644 --- a/library/lib_vessel_utils.ks +++ b/library/lib_vessel_utils.ks @@ -89,41 +89,19 @@ declare function CalculateSuicideBurnAltitude parameter tgtAltitude is 0.0. parameter drag is 0.0. - local vertAcc is CalculateAverageDecceleration(localGravity). + local vertAcc is CalculateAverageDecceleration(localGravity, drag). local burnAltitude is ((vertSpeed^2) / (2 * (vertAcc))). return burnAltitude + tgtAltitude. } -declare function CalculateSuicideBurnAltitudeV2 -{ - - parameter vertSpeed. - parameter localGravity. - parameter tgtAltitude is 0.0. - - - local vs is vertSpeed * -1. - local a is CalculateAverageDecceleration(localGravity). - local dt is 0.05. - local result is 0.0. - local h is alt:radar. - - until vs <= 0 { - set vs to vs + a * dt. - set result to result + vs * dt. - - if result > h { return result. } - } - - return result. -} declare function CalculateAverageDecceleration{ parameter localGravity. + parameter drag is 0. local maxVertAcc is (ship:availablethrust / ship:mass) - localGravity. - return maxVertAcc + localGravity. + return maxVertAcc + drag. } declare function GetLocalGravity{ diff --git a/poweredLanding.ks b/poweredLanding.ks index 9d55e3a..2822ffb 100644 --- a/poweredLanding.ks +++ b/poweredLanding.ks @@ -3,10 +3,19 @@ run "library/lib_math". run "library/lib_location_constants". run "defaults". -CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Open Terminal"). +function Test{ + TestSetup(10000). + WaitFalling(100). + Descent(). + Landing(). +} + function TestSetup{ + + print "Launch to start.". + WaitForEngineStart(). parameter tgt is 5000. if altitude > 100 { return. @@ -21,7 +30,8 @@ function TestSetup{ unlock throttle. } -function Landing{ +declare function Landing{ + parameter altitudeOffset is 0.0. print "Starting Landing". gear on. set pad to location_constants:kerbin:launchpad:position. @@ -61,14 +71,14 @@ function Landing{ until landed { set landingThrottle to hoverPid:update(time:seconds, verticalSpeed). - set hoverPid:setpoint to Map(alt:radar, 0, 100, -0.5, -30). + set hoverPid:setpoint to Map(alt:radar + altitudeOffset, 0, 100, -0.5, -20). wait 0.001. } print "Landed". lock throttle to 0. } -function WaitFalling{ +declare function WaitFalling{ parameter targetSpeed is 100. sas off. wait until altitude < 10000. @@ -84,20 +94,24 @@ function WaitFalling{ } -function Descent { +declare function Descent { + parameter margin is 100.0. + parameter speedTarget is 30. + local lock curAlt to alt:radar. local lock vertSpeed to verticalSpeed. local lock localGravity to GetLocalGravity(altitude). local lock drag to GetDragDir(localGravity, ship:up:vector). - local lock burnDist to CalculateSuicideBurnAltitude(vertSpeed, localGravity, 100, drag). + local lock burnDist to CalculateSuicideBurnAltitude(vertSpeed, localGravity, margin, drag). wait until burnDist >= curAlt. + print "Gravity " + localGravity + "| Drag " + drag. print "Starting Burn". print burnDist. gear on. - until abs(verticalSpeed) < 30{ + until abs(verticalSpeed) < speedTarget{ lock throttle to 1. } lock throttle to 0. @@ -107,10 +121,3 @@ function Descent { } -print "Launch to start.". -WaitForEngineStart(). -TestSetup(10000). -WaitFalling(100). -Descent(). -Landing(). - diff --git a/radenLaunch.ks b/radenLaunch.ks index 2b1d264..4d3736b 100644 --- a/radenLaunch.ks +++ b/radenLaunch.ks @@ -9,39 +9,54 @@ clearScreen. BRAKES on. print "Waiting for engine ignition". WaitForEngineStart(). +if not (defined rotateSpeed){ + set rotateSpeed to 140. +} print "Preparing to launch". from { local c is 5.} until c = 0 step {set c to c - 1.} do { print c. wait 1. } +set runwayPitch to (90 - vectorangle(UP:FOREVECTOR, FACING:FOREVECTOR)). clearScreen. print "Launching!". // stage. lock throttle to 1. -lock steering to heading(90, 1). +lock steering to heading(90, runwayPitch). brakes off. sas off. print "Phase: Takeoff". - -wait until groundspeed > 120. +print "Waiting for rotate speed: " + rotateSpeed. +wait until groundspeed > rotateSpeed. print "Phase: Rotate". -lock steering to heading(90, 4). +lock steering to heading(90, runwayPitch + 4). wait until altitude > 80. print "Gear up". gear off. +wait until altitude > 150. + +set accelPitch to runwayPitch + 4. +local accelPitchLoop is PIDLoop(1.0, 0.06, 0.3, runwayPitch, 15). +set accelPitchLoop:setpoint to 4. print "Phase: Athmospheric Acceleration". -lock steering to heading(90, 3, 0). -wait until groundspeed > athmoAccelTarget. +lock steering to heading(90, accelPitch, 0). +until groundspeed > athmoAccelTarget { + set accelPitch to accelPitchLoop:update(time:seconds, verticalSpeed). + wait 0.001. +} print "Phase: Athmospheric Climb". -lock tgtPitch to Map(groundSpeed, athmoAccelTarget, 1600, 3, 15). +lock tgtPitch to Map(groundSpeed, athmoAccelTarget, 1600, 5, 15). lock steering to heading(90, tgtPitch, 0). +until altitude > 20000 { + print tgtPitch. +} -wait until altitude > 25000. +wait until altitude > 20000. print "Phase: Mode Switch". ag1 on. //Switch engine mode