Advertisement
blorgon

kOS Single-Launch Geosynchronous Satellite Network

Jun 9th, 2016
1,354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //kOS Script for Single-Launch Multi-Satellite Geostationary Constellation by kickpuncher (blorgon on KSP forum).
  2.  
  3. parameter num.      //to run, type 'run scriptName(x)' into terminal. 'x' is number of satellites carried by rocket.
  4. set sats to max(2,num).     //limits *minimum* number of satellites you can launch with this script to two.
  5. set topd to (21549.4 - (21549.4 / sats)).   //takes number of satellites you're launching and figures out how to space them evenly.
  6. set tgain to ((1/topd)^(1/18))^18//determines the orbital period that when reached will turn the throttle off. See line 37.
  7. clearscreen.
  8. when stage:liquidfuel < 0.1 then {
  9.     stage.
  10.     wait 3.
  11.     stage.
  12.     return true.
  13. }
  14. when ship:altitude > 70000 then {
  15.     toggle AG10.    //I usually set my payload fairing to action group 10. This will deploy the fairing once out of atmo.
  16. }
  17. set pitch to 90.
  18. lock steering to heading(-90,pitch).
  19. set m to ship:mass.     //lines 19-24 force the rocket to launch at 1.45 TWR, if the rocket is capable of matching or exceeding it.
  20. set w to m * 9.81.
  21. stage.
  22. set t to ship:availablethrust.
  23. set throt to (1.45 * w) / t.
  24. lock throttle to throt.
  25. wait until ship:altitude > 147.     //see 'pfunc' below.
  26. until ship:apoapsis >= 2863330 {
  27.     set pfunc to sqrt(0.170283 * ship:altitude) - 5.    //pitch @ altitude function. Starts at 147m above sea level.
  28.     set pitch to min(180,(90 + pfunc)).     //'min' makes sure that once the rocket is horizontal, it will stay that way.
  29.     set throt to max(0.00005,(-(3.49243713e-7 * ship:apoapsis)^18+1))//full throttle til approaching target apo. Graph it to see!
  30.     wait 0.
  31. }
  32. set throt to 0.
  33. wait 1.
  34. warpto(time:seconds + (eta:apoapsis - 40)).     //easy enough, time warps to 40 seconds before apoapsis.
  35. wait 10.        //craft needs to repoint after warping. May have to tweak to work for your craft!
  36. until ship:orbit:period >= topd {       //'topd' is 'target orbital period', and is the GTO period that will space sats evenly.
  37.     set throt to max(0.00005,(-(tgain * ship:orbit:period)^18+1)).      //just another throttle function.
  38.     wait 0.
  39. }
  40. set throt to 0.
  41. toggle AG1.
  42. warpto(time:seconds + 120).     //warps past apoapsis. This is necessary so that you can jettison your first satellite, and run the script that will circularize it into GSO. If you try to run the circularization script right after reaching the transfer orbit, the satellite might not have enough time to reach GSO while still keeping the eccentricity low. Let the satellite carrier warp past apoapsis, and take a full orbit before starting the satellite scripts. See circularization script for more details.
  43. print "Program Ended.".
  44. wait until false.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement