TheThunder92

Falcon Landing Script

Nov 5th, 2025 (edited)
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.86 KB | Gaming | 0 0
  1. // Elixer Space Company - ASDS Script [version 0.3.1]
  2. // Customised Version
  3.  
  4.  
  5.  
  6. // Landing Parameters
  7.  
  8. //set impactPos to ADDONS:TR:IMPACTPOS.
  9. //if ABS(impactPos:lng - 49) < ABS(impactPos:lng - 44) {
  10. // set TARGET to vessel("Of Course I Still Love You").
  11. //}
  12. //else {
  13. // set TARGET to vessel("Just Read The Instructions").
  14. //}
  15. // North pad is 29.9445367992489, -74.537571128941
  16.  
  17. set landingZone to LatLng(29.96, -74.534).
  18. ADDONS:TR:SETTARGET (landingZone).
  19.  
  20.  
  21. // Initialization
  22.  
  23.  
  24. rcs on.
  25. set currentFacing to facing.
  26. lock steering to currentFacing.
  27. wait 2.
  28.  
  29.  
  30. // Grid Fins Parameter
  31.  
  32.  
  33.  
  34. print "Falcon Booster - Landing Software Initialized" at (0,0).
  35. print "" at (0,1).
  36. print SHIP:DELTAV:CURRENT + " m/s" at (0,2).
  37. print landingZone:lat at (0,3).
  38. print landingZone:lng at (0,4).
  39. print "" at (0,5).
  40. print "- - - - - - - - - - - - - - - - - - - - - - - - - " at (0,6).
  41. print " Booster Coasting " at (0,7).
  42. print " Awaiting Burn " at (0,8).
  43. print "- - - - - - - - - - - - - - - - - - - - - - - - - " at (0,9).
  44.  
  45. //if ship:partstagged("gridFins")[moduleNum]:GETMODULE("ModuleControlSurface"):GETFIELD("authority limiter") <> 40{print "Grid fins issue. Verify authority limiter".}
  46. //else {print "Grid fins set correctly".}
  47.  
  48. wait 1.
  49.  
  50. set steeringManager:maxstoppingtime to 5.
  51. set steeringManager:rollts to 20.
  52. wait 1.
  53.  
  54. set moduleNum to 0.
  55. until moduleNum = 4 {
  56. ship:partstagged("gridFins")[moduleNum]:GETMODULE("ModuleControlSurface"):SETFIELD("authority limiter", 30).
  57. ship:partstagged("gridFins")[moduleNum]:GETMODULE("ModuleControlSurface"):SETFIELD("deploy angle", 50).
  58. set moduleNum to (moduleNum + 1).
  59. }
  60.  
  61. // Landing Variables
  62.  
  63.  
  64. set radarOffset to 28. // This must be changed to the height of the landing vehicle (on gear)
  65. lock trueRadar to alt:radar - radarOffset.
  66. set g to constant:g * body:mass / body:radius^2.
  67. lock stopDist to (ship:verticalspeed^2) / (2 * (ship:availablethrust / ship:mass - g)).
  68. lock idealThrottle to (stopDist / trueRadar) * 6.
  69. lock impactTime to trueRadar / abs(ship:verticalspeed).
  70. lock aoa to 30.
  71. lock errorScaling to 1.
  72.  
  73.  
  74. // Guidance Functions
  75.  
  76.  
  77. function getImpact {
  78. if addons:tr:hasimpact { return addons:tr:impactpos. }
  79. return ship:geoposition.
  80. }
  81.  
  82. function lngError {
  83. return getImpact():lng - landingZone:lng.
  84. }
  85.  
  86. function latError {
  87. return getImpact():lat - landingZone:lat.
  88. }
  89.  
  90. function errorVector {
  91. return getImpact():position - landingZone:position.
  92. }
  93.  
  94. function getSteering {
  95. local errorVector is errorVector().
  96. local velVector is -ship:velocity:surface.
  97. local result is velVector + errorVector*errorScaling.
  98.  
  99. if vang(result, velVector) > aoa{
  100. set result to velVector:normalized
  101. + tan(aoa)*errorVector:normalized.
  102. }
  103.  
  104. return lookdirup(result, facing:topvector).
  105. }
  106.  
  107. rcs on.
  108. lock steering to srfretrograde.
  109. brakes on.
  110. wait until ship:verticalspeed <-700.
  111. lock throttle to 1.
  112. lock aoa to -5.
  113. lock steering to getSteering().
  114. rcs off.
  115. print " First Burn " at (0,7).
  116. print " Pad targeting burn " at (0,8).
  117. print "- - - - - - - - - - - - - - - - - - - - - - - - - " at (0,9).
  118.  
  119. when alt:radar <= 5000 then {
  120. set landingZone to LatLng(29.9445367992489, -74.537571128941).
  121. ADDONS:TR:SETTARGET (landingZone).
  122. }
  123.  
  124. wait until ship:verticalspeed > -200.
  125. lock throttle to 0.
  126. lock aoa to 17.5.
  127. lock steering to getSteering().
  128. steeringManager:resettodefault().
  129. rcs off.
  130. print " Booster Coasting " at (0,7).
  131. print " Impact correction " at (0,8).
  132. print "- - - - - - - - - - - - - - - - - - - - - - - - - " at (0,9).
  133.  
  134. wait until alt:radar < 12000.
  135. lock aoa to 10.
  136.  
  137. wait until alt:radar < 7000.
  138. lock aoa to 5.
  139. rcs on.
  140.  
  141. wait until trueRadar < (stopDist).
  142. lock throttle to 1.
  143. lock aoa to -3.
  144. lock steering to getSteering().
  145. rcs on.
  146. print " Booster Landing " at (0,7).
  147. print " Landing burn " at (0,8).
  148. print "- - - - - - - - - - - - - - - - - - - - - - - - - " at (0,9).
  149.  
  150. wait until ship:verticalspeed > -35.
  151. toggle ag1.
  152. gear on.
  153. lock throttle to idealThrottle.
  154. lock aoa to -2.
  155. lock steering to heading(90, 90, 180).
  156.  
  157. wait 2.
  158.  
  159. wait until ship:verticalspeed > -0.1.
  160. set ship:control:pilotmainthrottle to 0.
  161. unlock steering.
  162. RCS on.
  163. sas on.
  164. print " Booster Landed " at (0,7).
  165. print " Engines Off " at (0,8).
  166. print "- - - - - - - - - - - - - - - - - - - - - - - - - " at (0,9).
  167. wait 5.
  168. rcs off.
Tags: KSP KOS Kerbal
Advertisement
Add Comment
Please, Sign In to add comment