HvrdlS

f9b5

Jun 7th, 2023 (edited)
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.97 KB | None | 0 0
  1. //Settings
  2. clearscreen.
  3. set TargetAp to 300000.
  4. set Azimuth to 190.
  5. lock g to constant:g * body:mass / body:radius^2.
  6. lock twr to ship:mass * g / ship:availablethrust.
  7. set startsteer to lookDirUp(up:forevector, ship:facing:topvector).
  8. set PitchKickAlt to 100.
  9. set sec to 50.
  10. set min to 20.
  11. set hour to 4.
  12. set clock to "04:20:50".
  13. set rm to 1.
  14. print "Running hardware...".
  15. wait 5.
  16. set n to time:seconds + ((hour-time:hour)*60+min-time:minute)*60+(sec-time:second).
  17. lock t to (n - time:seconds)+10.
  18. lock rclock to time:clock.
  19. until rclock >= clock and rclock <= clock {
  20. clearscreen.
  21. print "Left: " + t + " Seconds".
  22. wait 0.1.
  23. }
  24.  
  25. set done to False.
  26. until false {
  27. //Liftoff
  28. print "Ready for launch".
  29. wait 0.
  30. sas off.
  31. wait 4.
  32. stage.
  33. print "Water Deluge System Activated!".
  34. wait 3.
  35. stage.
  36. lock throttle to 0.05.
  37. wait 1.
  38. set now to time:seconds.
  39. lock t to time:seconds - now.
  40. lock throttle to min(1, t/1).
  41. print "Ignition!".
  42. wait 2.
  43. stage.
  44. lock steering to startsteer.
  45. print "Liftoff!".
  46. set rm to 2.
  47. wait 0.
  48.  
  49. //Ascent
  50. wait 0.
  51. if rm = 2 {
  52. wait 5.
  53. print "Falcon 9 is cleared the towers...".
  54. wait until ship:altitude > PitchKickAlt - 50.
  55. lock steering to heading(Azimuth, 90).
  56.  
  57. wait until ship:altitude > PitchKickAlt.
  58. lock gravityturn to 90-(((ship:apoapsis/TargetAp)^0.6)*100).
  59. lock steering to heading(Azimuth, gravityturn).
  60. print "Gravity Turn".
  61.  
  62. wait until ship:altitude > 2150.
  63. lock throttle to 1.55 * twr.
  64.  
  65. set oldq to ship:q.
  66. wait 0.1.
  67. set newq to ship:q.
  68. until newq < oldq {
  69. set oldq to ship:q.
  70. wait 0.1.
  71. set newq to ship:q.
  72. }
  73.  
  74. print "Max-Q".
  75. wait 24.
  76. lock throttle to 2.5*twr.
  77.  
  78. //Stage separation
  79. wait until ship:altitude > 33200.
  80. set now to time:seconds.
  81. lock t to time:seconds - now.
  82. set thr to throttle.
  83. lock throttle to max(0, thr-t/2).
  84. print "MECO".
  85. rcs on.
  86. wait 1.
  87. toggle ag2.
  88. wait 1.5.
  89. stage.
  90. set ship:control:fore to 1.
  91. wait 3.
  92. lock throttle to 0.01.
  93. stage.
  94. wait 1.
  95. set now to time:seconds.
  96. lock t to time:seconds - now.
  97. lock throttle to min(0.5, t/1).
  98. set ship:control:fore to 0.
  99. print "SES-1".
  100. wait 3.
  101. stage.
  102.  
  103. //Fairing separation
  104. wait until ship:altitude > 72000.
  105. stage.
  106. print "Fairing Separation Confirmed!".
  107. wait 3.
  108. set thr to 0.5.
  109. lock throttle to thr.
  110. set pitch to 35.
  111. lock steering to heading(Azimuth, pitch).
  112. set targeteta1 to 180.
  113. set pid1 to pidloop(0.4,0.02,0.02, 0.05,1).
  114. set pid1:setpoint to targeteta1.
  115. set pid2 to pidloop(0.08,0.05,0.05, -55,65).
  116. set pid2:setpoint to TargetAp.
  117. until ship:apoapsis > TargetAp*0.98 {
  118. set thr to pid1:update(time:seconds,eta:apoapsis).
  119. set pitch to pid2:update(time:seconds,ship:apoapsis).
  120. wait 0.01.
  121. }
  122.  
  123. set targeteta2 to 15.
  124. set pid1:setpoint to targeteta2.
  125. until ship:apoapsis > TargetAp and ship:periapsis > TargetAp*0.98 {
  126. set thr to pid1:update(time:seconds,eta:apoapsis).
  127. set pitch to pid2:update(time:seconds,ship:apoapsis).
  128. set targeteta2 to (((TargetAp-ship:periapsis)/targeteta1)/targeteta1)+10.
  129. if ship:verticalspeed < 1 {
  130. set pid1 to pidloop(0.1,0.05,0.05, 0.05,1).
  131. set pid2 to pidloop(0.75,0.1,0.02, -10,15).
  132. set pid1:setpoint to 1.
  133. set pid2:setpoint to 1.
  134. set pitch to pid2:update(time:seconds, ship:verticalspeed).
  135. set thr to pid1:update(time:seconds,ship:verticalspeed).
  136. }
  137. wait 0.01.
  138. }
  139.  
  140. set rm to 3.
  141. }
  142.  
  143. wait 0.
  144. if rm = 3 {
  145. lock throttle to 0.
  146. unlock steering.
  147. wait 0.1.
  148. set ship:control:fore to -1.
  149. wait 1.5.
  150. set ship:control:fore to 0.
  151. run maneuvernode2.ks.
  152. set rm to 4.
  153. }
  154.  
  155. if rm = 4 {
  156. run payloaddeploy.ks.
  157. }
  158.  
  159. set done to True.
  160. break.
  161. }
Advertisement
Add Comment
Please, Sign In to add comment