HvrdlS

Starhopper 10M Hop

Nov 14th, 2021 (edited)
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.46 KB | None | 0 0
  1. clearscreen.
  2. on ag10 {
  3. aborttest().
  4. }
  5.  
  6. prep().
  7. fuel().
  8. hop().
  9. detanking().
  10.  
  11.  
  12. function prep {
  13. print "Welcome to Starhopper Test Software V4!".
  14. wait 2.
  15. print "Running hardware, preparings for software...".
  16. wait 5.
  17. set teststatus to "Preparations".
  18. wait until teststatus = "Preparations".
  19. wait 1.
  20. set goal to "Hop".
  21. set h to alt:radar.
  22. lock altit to alt:radar-h.
  23. set targetalt to 10+altit.
  24. set northPole to latlng(90,0).
  25. set head to mod(360-northpole:bearing,360).
  26. set landingZone to latlng(-5.46634004,-54.0389159).
  27. lock steering to heading(0,90).
  28. set lenght to 2.
  29. set eng to ship:partstagged("Vector1")[0].
  30. eng:activate.
  31. print "Goal: " + goal.
  32. print "Press 9".
  33. wait 1.
  34. wait until ag9.
  35. set now to time:seconds.
  36. lock testtime to time:seconds - now.
  37. wait 1.
  38. toggle ag9.
  39. set teststatus to "Fueling".
  40. print "Go for test".
  41. }
  42.  
  43. function fuel {
  44. print "Beginning fueling".
  45. wait 1.
  46. print "Awaiting for fueling end, press 9 to end".
  47. until ag9 {
  48. printing().
  49. }
  50.  
  51. set teststatus to goal + " preparing".
  52. wait 1.
  53. toggle ag3.
  54. toggle ag2.
  55. toggle ag1.
  56. wait 1.
  57. toggle ag9.
  58. print "Fueling finished, press 9".
  59. wait 1.
  60. until ag9 {
  61. printing().
  62. }
  63.  
  64. set teststatus to goal + " go".
  65. }
  66.  
  67. function hop {
  68. set maxthr to ship:maxthrust.
  69. set g to body:mu/(body:radius)^2.
  70. set twr to ship:mass * g / ship:availablethrust.
  71. lock curthr to eng:thrust.
  72. wait 1.
  73. rcs on.
  74. sas off.
  75. lock steering to heading(0,90).
  76. lock throttle to 0.1.
  77. toggle ag2.
  78. toggle ag3.
  79. toggle ag1.
  80. wait 1.5.
  81. set n to time:seconds.
  82. lock t to time:seconds - n.
  83. eng:activate.
  84. lock throttle to min(1, t/2.5).
  85. print "Test began".
  86. wait until altit>0.8.
  87. lock latoff to (landingZone:lat-addons:tr:impactpos:lat)*10472.
  88. until ship:verticalspeed > 1.25 {
  89. hopprinting().
  90. }
  91.  
  92. lock throttle to twr * 0.994.
  93. lock steering to heading(0,p).
  94. until latoff < 3 {
  95. hopprinting().
  96. }
  97.  
  98. lock steering to heading(0,90).
  99. until altit >= targetalt {
  100. hopprinting().
  101. }
  102.  
  103. lock throttle to twr * 0.92.
  104. lock steering to heading(0,p).
  105. until ship:verticalspeed < -1.2 {
  106. hopprinting().
  107. }
  108.  
  109. lock throttle to twr * 0.996.
  110. until altit < 3 {
  111. hopprinting().
  112. }
  113.  
  114. lock throttle to twr*1.05.
  115. until ship:verticalspeed < 0.5 {
  116. hopprinting().
  117. }
  118.  
  119. lock throttle to twr*0.996.
  120. until altit<0.15 {
  121. hopprinting().
  122. }
  123.  
  124. set latoff to 0.
  125. lock throttle to 0.1.
  126. print "Test completed".
  127. wait 4.
  128. lock throttle to 0.
  129. eng:shutdown.
  130. set teststatus to "Completed".
  131. }
  132.  
  133. function hopprinting {
  134. clearscreen.
  135. set twr to ship:mass * g / ship:availablethrust.
  136. print "Test lenght: " + t + " Seconds".
  137. print "Current throttle: " + curthr + "kn".
  138. print "Maximum throttle: " + maxthr + "kn".
  139. steer().
  140. print ang.
  141. print latoff.
  142. log t + ";" + maxthr + ";" + curthr + ";" + altit + ";" + latoff + ";" + p to starhopper10hop.txt.
  143. wait 0.01.
  144. }
  145.  
  146. function detanking {
  147. print "Test status: " + teststatus.
  148. ag2 on.
  149. ag3 on.
  150. ag1 on.
  151. wait 1.
  152. toggle ag9.
  153. unlock steering.
  154. unlock throttle.
  155. wait 300.
  156. toggle ag2.
  157. toggle ag3.
  158. toggle ag1.
  159. print 3/0.
  160. }
  161.  
  162. function printing {
  163. clearscreen.
  164. print "Time from test beginning: " + testtime + " Seconds".
  165. print "Test status: " + teststatus.
  166. print "Goal: " + goal.
  167. print "Time(KSC): " + time:clock.
  168. wait 0.1.
  169. }
  170.  
  171. function aborttest {
  172. lock latoff to 0.
  173. print "Abort".
  174. eng:shutdown.
  175. lock throttle to 0.
  176. wait 1.
  177. unlock throttle.
  178. unlock steering.
  179. set eng2 to ship:partstagged("s")[0].
  180. eng2:activate.
  181. set t to 5.
  182. set s to 0.
  183. until s>t {
  184. lock throttle to 1.
  185. wait 1.
  186. lock throttle to 0.
  187. set s to s+1.
  188. wait 1.
  189. }
  190.  
  191. eng2:shutdown.
  192. wait 1.
  193. set teststatus to "Detanking".
  194. detanking().
  195. }
  196.  
  197. function steer {
  198. wait 0.
  199. set pid to pidloop(1, 1, 1, -1,1).
  200. set pid:setpoint to 0.
  201. set ang to pid:update(time:seconds,latoff).
  202. if ang < 0 {
  203. set p to 90-abs(ang).
  204. } else if ang > 0 {
  205. set p to ang+90.
  206. }
  207. }
Add Comment
Please, Sign In to add comment