Advertisement
Guest User

orbit profile

a guest
Jul 17th, 2015
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.41 KB | None | 0 0
  1. clearscreen.
  2.  
  3. set Kputsnis to SHIP.
  4. set firststage to Kputsnis:PARTSTAGGED("firststage").
  5. set secondstage to Kputsnis:PARTSTAGGED("secondstage").
  6. set counter to 1.
  7. set TARGET_APO to 80000.
  8. set TARGET_PER to 80000.
  9. set TARGET_SMA to (TARGET_APO + TARGET_PER)/2.
  10. lock SMA to (apoapsis + periapsis)/2.
  11. set thr to 0.
  12.  
  13. set tick to 0.01.
  14.  
  15. set taim to 0.
  16. set captabel to false.
  17. set incl to 90.
  18. set direction to heading(incl,90).
  19. set pitch to 90.
  20. set stage_1_complete to false.
  21. set stage_2_complete to false.
  22. set orbital to false.
  23. set orbit_reached to false.
  24. lock steering to direction.
  25. lock throttle to thr.
  26. function clearmessages
  27. {
  28. print " " at (3,30).
  29. print " " at (3,31).
  30. print " " at (3,32).
  31. }.
  32. until counter = 50
  33.  
  34. {
  35.  
  36. print "=" at (counter,0).
  37.  
  38. print "=" at (counter,34).
  39.  
  40. print "-" at (counter,28).
  41.  
  42. print "-" at (counter,6).
  43.  
  44. set counter to counter + 1.
  45.  
  46. }.
  47.  
  48. set counter to 1.
  49.  
  50. until counter = 33
  51.  
  52. {
  53.  
  54. print "|" at (0,counter).
  55.  
  56. print "|" at (50,counter).
  57.  
  58. set counter to counter +1.
  59.  
  60. }.
  61.  
  62. set counter to 1.
  63.  
  64. until counter = 28
  65.  
  66. {
  67.  
  68. print "|" at (25,counter).
  69.  
  70. set counter to counter +1.
  71.  
  72. }.
  73.  
  74. print " FLIGHT DATA " at (5,0).
  75.  
  76. print " System messages: " at (5,28).
  77.  
  78. print " TELEMETRY " at (8,3).
  79.  
  80. print " PROJECTIONS " at (32,3).
  81.  
  82. until 0 = 1
  83.  
  84. {
  85. print ship:body at (6,8).
  86.  
  87. if altitude < 1000 print " Altitude(km): 0" at (5,11).
  88. if altitude > 1000
  89. print " Altitude(km): " + (altitude - mod(altitude,1000))/1000 at (5,11).
  90.  
  91. print " Speed(m/s): " + ((ship:airspeed - mod(ship:airspeed,1)) + " ") at (5,14).
  92.  
  93. print " Throttle: " + throttle / 0.01 + "% " at (5,17).
  94.  
  95. print " Mass (t): " + (ship:mass - mod(ship:mass,1)) at (5,20).
  96.  
  97. print " Apoapsis(km):" + ((apoapsis - mod(apoapsis,1000))/1000 + " ") at (29,8).
  98.  
  99. if periapsis < 0 print " Periapsis(km): 0" at (29,11).
  100.  
  101. if periapsis > 0 print " Periapsis(km):" + (periapsis - mod(periapsis,1000))/1000 + " " at (29,11).
  102.  
  103.  
  104.  
  105. // staging controls
  106.  
  107. if (ship:airspeed < 0.1) and (altitude < 100)
  108. {
  109. print " " at (3,30).
  110. print "Initialising flight parameters" at (3,30).
  111. set direction to heading(incl,85).
  112. set thr to 0.1.
  113. print " " at (3,31).
  114. print "Setting up flight log" at (3,31).
  115. set skipl0g to ship:name.
  116. set skipl0g to skipl0g + ".csv".
  117. switch to archive.
  118. delete skipl0g.
  119. if captabel = false
  120. {
  121. log "Time,Altitude,Speed (x10),Throttle,Apoapsis,Periapsis" to skipl0g.
  122. set captabel to true.
  123. }.
  124. switch to 1.
  125. set pitch to 80.
  126. stage.
  127. print "Booster ignition" at (3,32).
  128. wait 3.
  129. set taim to taim + 3.
  130. }.
  131.  
  132. if stage_1_complete = false
  133. {
  134. clearmessages().
  135. print "Stage 1 Commencing..." at (3,30).
  136. if firststage[0]:flameout
  137. {
  138. print "Stage 1 completed: discarding booster" at (3,31).
  139. wait 1.
  140. set taim to taim + 1.
  141. stage.
  142. wait 1.
  143. set taim to taim + 1.
  144. stage.
  145. set stage_1_complete to true.
  146. clearmessages().
  147. print "Stage 2 Commencing..." at (3,30).
  148. }.
  149. }.
  150.  
  151. if stage_1_complete and (stage_2_complete = false)
  152. {
  153. if secondstage[0]:flameout and (stage_2_complete = false)
  154. {
  155. print "Second stage completed: staging..." at (3,32).
  156. set stage_2_complete to true.
  157. stage.
  158. wait 1.
  159. set taim to taim + 1.
  160. stage.
  161. }.
  162. }.
  163.  
  164. // navigational controls
  165.  
  166. // nav 1. - maneuvres if suborbital or on decaying orbit
  167.  
  168. if (orbital = false) and (orbit_reached = false)
  169. {
  170. if (apoapsis/TARGET_APO < 0.9) and (apoapsis < TARGET_APO) set thr to 1.
  171. if ((apoapsis/TARGET_APO > 0.9) and (altitude < TARGET_APO)) and (apoapsis < TARGET_APO) set thr to 0.5.
  172. if (altitude < TARGET_APO) and (apoapsis > TARGET_APO)
  173. {
  174. print "Adjusting pitch angle to:" + pitch + " degrees "at (3,31).
  175. set pitch to (85 - ((85*apoapsis)/TARGET_APO - mod((85*apoapsis)/TARGET_APO,1))).
  176. set direction to heading(incl,pitch).
  177. }.
  178. if (apoapsis > TARGET_APO) and ((eta:apoapsis > 10) and (eta:apoapsis < eta:periapsis)) set thr to 0.
  179. if (apoapsis < TARGET_APO)
  180. {
  181. print "Adjusting pitch angle to:" + pitch + " degrees "at (3,31).
  182. set pitch to (85 - ((85*apoapsis)/TARGET_APO - mod((85*apoapsis)/TARGET_APO,1))).
  183. set direction to heading(incl,pitch).
  184. }.
  185.  
  186. if (apoapsis > TARGET_APO) and ((eta:apoapsis < 10) and (eta:apoapsis < eta:periapsis)) and (periapsis < TARGET_PER)
  187. {
  188. unlock steering.
  189. lock steering to prograde.
  190. if periapsis < 0 set thr to 1.
  191. if periapsis > 0 set thr to (1 - periapsis/TARGET_PER).
  192.  
  193. }.
  194. }.
  195.  
  196. // check if orbital
  197.  
  198. if (apoapsis > 70000) and (periapsis > 70000) and (SMA > TARGET_SMA)
  199. {
  200. clearmessages().
  201. print "ORBIT ACHIEVED" at (3,31).
  202. set orbital to true.
  203. unlock steering.
  204. set thr to 0.
  205. }.
  206.  
  207. // adjust orbit
  208.  
  209. // flight recorder below this point
  210.  
  211. switch to archive.
  212. set spid to ship:airspeed.
  213. set apogeu to apoapsis.
  214. set perigeu to periapsis.
  215. if periapsis < 0 set perigeu to 0.
  216. log taim + "," + altitude + "," + spid*10 + "," + (thr/(1/100)) + "," + apogeu + "," + perigeu + "," to skipl0g.
  217. switch to 1.
  218. wait tick.
  219. set taim to taim + tick.
  220.  
  221. }.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement