Advertisement
blorgon

kOS Geosync Circularization Script

Jun 9th, 2016
1,010
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. clearscreen.
  2. set throt to 0.
  3. lock throttle to throt.
  4. lock steering to prograde.
  5. wait until eta:apoapsis < 10.       //because of the way the sigmoid function works, you should wait till this time. Otherwise you might start thrusting before you want to. This is a way to guarantee that no matter when you jettison the satellite and start the script, all your satellites will start their circularization burn at the exact same time. This helps ensure that all the satellites will be perfectly syncrhonized.
  6. until ship:orbit:period >= 21540.0000 {     //this until loop is a little complicated. It uses a sigmoid function to raise the periapsis to a point where the orbital period is 5.97 hours. The 5.97 is arbitrary, I just picked a value very close to the actual target orbital period, because this function only works while the time to apoapsis is < 10 seconds. So if you pass apoapsis before circularizing, then it will just wait until the next time it's approaching apoapsis, so it could potentially take forever to circularize. Anyway, this gets it close, then breaks and moves to a different kind of function that finishes the job.
  7.     set tta to -1 * eta:apoapsis.
  8.     set x to max(0.0001,((21549.4 - ship:orbit:period)/500)).
  9.     set throt to max(0.00001,(-1/(1+5^(tta+x))+1)).     //sigmoid function. I recommend typing this into Google, but replace x with (-)x, and tta with a number between 1 and 15. The input into the function is your time to apoapsis. As it nears 0, the ship will throttle up to try to keep apoapsis from actually reaching 0. At the same time, it will also throttle down to keep the time to apoapsis < ~10s. The number you replace tta with is your 'mean' value, that is, the time to apoapsis the function will try to keep you at by throttling the engines correspondingly. In the script, tta is also a variable, which is the target orbital period minus your actual orbital period. I divided by 500, because this gives a smaller "target time to apoapsis", which shrinks as your orbital period approaches your target orbital period. For example, if your current orbital period were 20150, tta would be ~1399s, which is obviously an unreasonable time to apoapsis. Dividing it by 500 gives a value around 2.7s, which is much better, as at that point we're close to circularization, and want to keep our time to apoapsis small. The 'max(0.00001' portion just ensures that we don't throttle down to utterly infinitesimal amounts. Otherwise this loop would take a prohibitively long time to run.
  10.     wait 0.
  11. }
  12. until ship:orbit:period >= 21549.4 {        //this until loop just finishes the circularization, for the aforementioned reasons.
  13.     set throt to max(0.00001,(-(0.000046405 * ship:orbit:period)^18+1)).
  14.     wait 0.
  15. }
  16. set throt to 0.
  17. print "Program Ended." at (0,3).
  18. print "Orbital Period: " + round(ship:orbit:period,8) at (0,5).
  19. wait until false.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement