Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. // Landing Burn
  2.  
  3.  
  4.  
  5. // Configuration
  6.  
  7. set radarOffset to 26.850. // Measure "alt:radar" of the vehicle when landed 27.977
  8.  
  9.  
  10.  
  11. // Physics
  12.  
  13. lock trueRadar to alt:radar - radarOffset. // Distance from the bottom of vehicle to the ground
  14.  
  15. lock g to constant:g * body:mass / body:radius^2. // Gravitational acceleration
  16.  
  17. lock maxDecel to (ship:availablethrust / ship:mass) - g. // Maximum achievable deceleration of the vehicle
  18.  
  19. lock stopDist to ship:verticalspeed^2 / (2 * maxDecel). // Distance to kill all the velocity
  20.  
  21. lock idealThrottle to stopDist / trueRadar. // Hoverslam throttling setting
  22.  
  23. lock impactTime to trueRadar / abs(ship:verticalspeed). // Time to impact with the current velocity
  24.  
  25.  
  26.  
  27. // State variables
  28.  
  29. set burnStarted to 0. // 1 if landing burn has started
  30.  
  31.  
  32.  
  33. clearscreen.
  34.  
  35.  
  36.  
  37. wait until ship:verticalspeed < -1.
  38.  
  39. print "Preparing for landing burn...".
  40.  
  41. rcs on.
  42.  
  43. print "RCS Online...".
  44.  
  45. brakes on.
  46.  
  47. lock steering to srfretrograde.
  48.  
  49. list engines in elist.
  50.  
  51. for eng in elist
  52.  
  53. {
  54.  
  55. if eng:hasgimbal
  56.  
  57. {
  58.  
  59. set maxrange to eng:gimbal:range.
  60.  
  61. set eng:gimbal:limit to maxrange/2. // this will limit engine gimbal
  62.  
  63. }
  64.  
  65. }
  66.  
  67.  
  68.  
  69. print "Engine gimbal limited...".
  70.  
  71.  
  72.  
  73.  
  74.  
  75. wait until trueRadar < stopDist.
  76.  
  77. print "Landing burn has begun!".
  78.  
  79. set burnStarted to 1.
  80.  
  81. lock throttle to idealThrottle.
  82.  
  83.  
  84.  
  85. wait until burnStarted = 1.
  86.  
  87. until impactTime < 4.
  88.  
  89. print "Deploying landing legs...".
  90.  
  91. gear on.
  92.  
  93.  
  94.  
  95. wait until ship:verticalspeed > -0.01.
  96.  
  97. print "Falcon 9 first stage has landed at LZ-1!".
  98.  
  99. set ship:control:pilotmainthrottle to 0.
  100.  
  101. wait 5.
  102.  
  103. rcs off.
  104.  
  105. sas off.
  106.  
  107. brakes off.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement