Advertisement
sumguytwitches

partial hathi landatmo

Oct 2nd, 2023 (edited)
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. //partial firmware testing
  2.  
  3.  
  4. set x to target:heading.
  5. lock p to 11.
  6. lock steering to heading(x,p).
  7. set steeringmanager:rollcontrolanglerange to 180.
  8.  
  9.  
  10. lock ralt to altitude - ship:geoposition:terrainheight.
  11.  
  12. set vectors to ship:partsdubbedpattern("vector").
  13. set nukes to ship:partsdubbedpattern("nuc").
  14. set turbos to ship:partsdubbedpattern("turbofan").
  15. set servos to ship:modulesnamed("ModuleRoboticRotationServo").
  16.  
  17. for rap in ship:partsdubbedpattern("rapier") turbos:add(rap).
  18. set rotormods to ship:modulesnamed("ModuleRoboticServoRotor").
  19.  
  20. function SetEngines {
  21. parameter targetMode to "Activate Engine".
  22. parameter engines to ship:partsdubbedpattern("vector").
  23. for engine in engines {
  24. if engine:hasmodule("ModuleEnginesFx") set m to engine:getmodule("ModuleEnginesFx").
  25. if engine:hasmodule("ModuleEngines") set m to engine:getmodule("ModuleEngines").
  26. if m:hasaction(targetMode) m:doaction(targetMode, true).
  27. }
  28. }
  29.  
  30. function shutoff {
  31. parameter engines to ship:partsdubbedpattern("vector").
  32. SetEngines("Shutdown Engine", engines).
  33. }
  34.  
  35. function startup {
  36. parameter engines to ship:partsdubbedpattern("vector").
  37. SetEngines("Activate Engine", engines).
  38. }
  39.  
  40.  
  41. function ThrustLimit {
  42. parameter targetEngines.
  43. parameter targetThrust.
  44. for eng in targetEngines set eng:thrustlimit to targetThrust.
  45. }
  46.  
  47. function SetAngle {
  48. parameter targetangle.
  49. for s in servos if s:hasfield("target angle") s:setfield("target angle", targetangle).
  50. }
  51.  
  52.  
  53. function powerlandatmo {
  54. set navmode to "surface".
  55. props off.
  56. lock steering to srfprograde.
  57. set x to body:geopositionof(srfprograde:vector):heading.
  58. set p to 0.
  59. ship:partsdubbedpattern("cockpit")[0]:controlfrom().
  60. shutoff(ship:engines).
  61. thrustlimit(vectors, 0).
  62. startup(vectors).
  63. lock throttle to 1.
  64. set landing to true.
  65.  
  66. on time:seconds {
  67.  
  68. set vthrottle to 100*(-verticalspeed-1)-sqrt(2*max(1,(max(0.1,vdot(up:vector,vectors[0]:facing:vector))* availablethrust*0.75)/mass-body:mu/(body:radius^2))*max(altitude-geoposition:terrainheight-100+verticalspeed*0.5,0.1)).
  69. thrustlimit(vectors, vthrottle).
  70. print (" Thrust Limit:" + round(vthrottle)):padright(terminal:width) at (0,0).
  71.  
  72. set vangle to max(-45,min(45,-groundspeed*vdot(ship:facing:vector, velocity:surface))).
  73. setangle(vangle).
  74. print (" Angle:" + round(vangle)):padright(terminal:width) at (0,1).
  75.  
  76. print ("Alt above Ground:" + round(altitude - ship:geoposition:terrainheight)):padright(terminal:width) at (0,2).
  77. return landing.
  78. }
  79.  
  80. when airspeed < 10 then {
  81. lock steering to heading(x,p).
  82. gear on.
  83. brakes on.
  84. }
  85.  
  86. when ship:verticalspeed > 0 and altitude - ship:geoposition:terrainheight < 1000 and groundspeed < 10 then
  87. {
  88. lock throttle to 0.
  89.  
  90. set landing to false.
  91. }
  92. }
  93.  
  94.  
  95.  
  96.  
  97.  
  98. function info {
  99. parameter message.
  100. parameter withtime to true.
  101. set logmessage to "".
  102. if withtime {
  103. set logmessage to round(missionTime,1):ToString():padleft(6) + ": ".
  104. }
  105. set logmessage to logmessage + message.
  106. print logmessage.
  107. }
  108.  
  109. gear on.
  110. brakes on.
  111. lock throttle to (120-airspeed)/10.
  112. when ralt < 100 then powerlandatmo().
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement