Advertisement
Guest User

Landing Burn

a guest
Dec 24th, 2016
2,634
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Landing Burn
  2.  
  3. // Configuration
  4. set radarOffset to 27.977.                                  // Measure "alt:radar" of the vehicle when landed
  5.  
  6. // Physics
  7. lock trueRadar to alt:radar - radarOffset.                  // Distance from the bottom of vehicle to the ground
  8. lock g to constant:g * body:mass / body:radius^2.           // Gravitational acceleration
  9. lock maxDecel to (ship:availablethrust / ship:mass) - g.    // Maximum achievable deceleration of the vehicle
  10. lock stopDist to ship:verticalspeed^2 / (2 * maxDecel).     // Distance to kill all the velocity
  11. lock idealThrottle to stopDist / trueRadar.                 // Hoverslam throttling setting
  12. lock impactTime to trueRadar / abs(ship:verticalspeed).     // Time to impact with the current velocity
  13.  
  14. // State variables
  15. set burnStarted to 0.                                       // 1 if landing burn has started
  16.  
  17. clearscreen.
  18.  
  19. wait until ship:verticalspeed < -1.
  20.     print "Preparing for landing burn...".
  21.     rcs on.
  22.     brakes on.
  23.     lock steering to srfretrograde.
  24.  
  25. wait until trueRadar < stopDist.
  26.     print "Landing burn has begun!".
  27.     set burnStarted to 1.
  28.     lock throttle to idealThrottle.
  29.  
  30. wait until burnStarted = 1.
  31.     until impactTime < 4.
  32.         print "Deploying landing legs...".
  33.         gear on.
  34.  
  35. wait until ship:verticalspeed > -0.01.
  36.     print "Landed!".
  37.     set ship:control:pilotmainthrottle to 0.
  38.     wait 5.
  39.     rcs off.
  40.     sas off.
  41.     brakes off.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement