HvrdlS

Dragon Deorbit

Jun 17th, 2024 (edited)
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.72 KB | None | 0 0
  1. clearscreen.
  2. settings().
  3. deorbit().
  4. noseconeclose().
  5. reentry().
  6.  
  7.  
  8. function settings {
  9. set missionstatus to "Ready for trunk separation, press 9 to separate".
  10. ag9 off.
  11. set noseconehinge to ship:partsdubbed("nosehinge")[0].
  12. set landingSite to latlng(0, -70.5).
  13. set dlng to landingSite:lng-180.
  14. set shipLatlng to ship:geoposition.
  15. set droguealt to 2750.
  16. set mainalt to 1000.
  17. rcs on.
  18. sas off.
  19. lock steering to retrograde.
  20. }
  21.  
  22.  
  23. function deorbit {
  24. until ag9 {
  25. printing().
  26. }
  27.  
  28. stage.
  29. set missionstatus to "Trunk has been separated, awaiting for targeted longitude for deorbit burn".
  30. until shipLatlng:lng < dlng + 0.5 and shipLatlng:lng > dlng - 0.5 {
  31. printing().
  32. }
  33.  
  34. set missionstatus to "Starting deorbit".
  35. set deg to max(3.4, (min(35, abs(latoff/1000)))*2).
  36. set sign to abs(latoff)/latoff.
  37. set degf to deg*sign.
  38. lock steering to heading(270+degf, 0).
  39. when min(35, abs(latoff/1000))*2 = 0 then {
  40. set sign to 0.
  41. set degf to 0.
  42. preserve.
  43. }
  44.  
  45. set ship:control:fore to 1.
  46. until lngoff > -4000 and periapsis < 55000 {
  47. printing().
  48. set deg to max(1, (min(45, abs(latoff/1000)))*2).
  49. set sign to abs(latoff)/latoff.
  50. set degf to deg*sign.
  51. }
  52.  
  53. set ship:control:fore to 0.
  54. set missionstatus to "Deorbit has ended, maintaining retrograde for reentry".
  55. lock steering to srfretrograde.
  56. print "Final lngoff :" + lngoff + " Meters".
  57. print "Final latoff :" + latoff + " Meters".
  58. until vang(ship:facing:vector, -ship:velocity:surface) < 0.25 {
  59. printing().
  60. }
  61.  
  62. print "Entry orientation is maintained".
  63. wait 5.
  64. }
  65.  
  66.  
  67. function noseconeclose {
  68. set missionstatus to "Nosecone closing in progress, entry orientation is maintained".
  69. noseconehinge:getmodule("ModuleRoboticServoHinge"):setfield("Locked", 0).
  70. wait 0.1.
  71. noseconehinge:getmodule("ModuleRoboticServoHinge"):setfield("Traverse Rate", 5).
  72. noseconehinge:getmodule("ModuleRoboticServoHinge"):setfield("Target Angle", -90).
  73. until noseconehinge:getmodule("ModuleRoboticServoHinge"):getfield("Current Angle") = -90 {
  74. clearscreen.
  75. print("Nosecone Angle is " + noseconehinge:getmodule("ModuleRoboticServoHinge"):getfield("Current Angle") + " Degrees").
  76. print("Difference between deployed and current is " + (-90 - noseconehinge:getmodule("ModuleRoboticServoHinge"):getfield("Current Angle")) + " Degrees").
  77. }
  78.  
  79. print "Nosecone is closed".
  80. set missionstatus to "Nosecone is closed, getting ready for entry".
  81. wait 3.
  82. noseconehinge:getmodule("ModuleRoboticServoHinge"):setfield("Locked", 1).
  83. }
  84.  
  85.  
  86. function reentry {
  87. until altitude < 70000 {
  88. printing().
  89. }
  90.  
  91. set missionstatus to "We have entered the atmosphere, awaiting for drogue chutes deployment".
  92. until altitude < droguealt {
  93. printing().
  94. }
  95.  
  96. stage.
  97. unlock steering.
  98. set missionstatus to "Drogue chutes are deployed, awaiting main chutes deployment".
  99. until altitude < mainalt {
  100. printing().
  101. }
  102.  
  103. stage.
  104. wait 1.
  105. ag8 on.
  106. set missionstatus to "Main chutes are deployed, awaiting for splashdown".
  107. until ship:status = "Landed" or "Splashed" {
  108. printing().
  109. }
  110.  
  111. set missionstatus to "Dragon is splashed down".
  112. rcs off.
  113. sas off.
  114. unlock steering.
  115. unlock throttle.
  116. }
  117.  
  118.  
  119. function abortofscript {
  120. clearscreen.
  121. print "Program aborted".
  122. wait 2.
  123. print 3/0.
  124. }
  125.  
  126.  
  127. function printing {
  128. clearscreen.
  129. print "Mission Status: " + missionstatus.
  130. print "Current Longitude: " + round(shipLatlng:lng, 4) + " Degrees".
  131. print "Current Latitude: " + round(shipLatlng:lat, 4) + " Degrees".
  132. print "Target Longitude: " + tlng + " Degrees".
  133. print "Target Latitude: " + tlat + " Degrees".
  134. print "Impact Longitude: " + round(ImpactPosition:lng, 4) + " Degrees".
  135. print "Impact Latitude: " + round(ImpactPosition:lat, 4) + " Degrees".
  136. print "Impact Longitude Difference: " + round(lngoff, 1) + " Meters".
  137. print "Impact Latitude Difference: " + round(latoff, 1) + " Meters".
  138. print "Drogue chutes deployment altitude: " + droguealt + " Meters".
  139. print "Main chutes deployment altitude: " + mainalt + " Meters".
  140. print "Press 10 to abort current program".
  141. set shipLatlng to ship:geoposition.
  142. set lngoff to 10472*(ImpactPosition():lng - landingSite:lng).
  143. set latoff to 10472*(ImpactPosition():lat - landingSite:lat).
  144. wait 0.1.
  145. }
  146.  
  147.  
  148. function ImpactPosition {
  149. if addons:tr:hasimpact {
  150. return addons:tr:impactpos.
  151. } else {
  152. return ship:geoposition.
  153. }
  154. }
Advertisement
Add Comment
Please, Sign In to add comment