Advertisement
hubin162577

fivekm

Oct 21st, 2021
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Approaching from 5km beneath station
  2. clearscreen.
  3. set pi to 3.1415926535897932384626433832795028841971693993751058209749445923.
  4. set mu to 3.986*(10^14).
  5. ag1 off.
  6. set target to "LIESS".
  7. set lateraloffset to 0.
  8. set verticaloffset to -5000.
  9. rcs on.
  10. sas off.
  11. gear off.
  12. lock steering to prograde + r(0,0,180).
  13.  
  14. set maneuverSpeed to 1.
  15.  
  16. //functions
  17. function verticaldist {
  18. set vdist to target:altitude-ship:altitude.
  19. return vdist.
  20. }.
  21. function verticalinputFunction {
  22. if abs(verticalDistance2+extraH) > 10 {
  23. set vver to (verticalDistance2-verticalDistance1)/(dt).
  24. if verticaldistance2+extraH > 0 {
  25. set ms to -maneuverSpeed.
  26. }. else {
  27. set ms to maneuverSpeed.
  28. }
  29. set vverError to ms-vver.
  30. set vertinput to kpv*vverError.
  31. ///////////////////////////////////////////
  32. }. else {
  33. set sverError to (verticaldistance2+extraH).
  34. set vver to (verticalDistance2-verticalDistance1)/(dt).
  35. set vertinput to -((kps*sverError)+(kds*vver)).
  36. }.
  37. return vertinput.
  38. }.
  39.  
  40. ////////////////////////////////////////////////////////////////////////////////
  41. //defining values and gains
  42. set kpv to 1.
  43. set kps to .1.
  44. set kds to 2.
  45.  
  46. set latinput to 0.
  47. set verticalinput to 0.
  48. set extraH to verticaloffset.
  49. set vver to 0.
  50.  
  51. set desireSMA to target:orbit:semimajoraxis-5000.
  52. set desiredT to 2*pi*sqrt((desireSMA^3)/mu).
  53.  
  54. //Sub 5 KM station keeping
  55. until ag1 {
  56. if 2 > 1 {
  57. set verticalDistance1 to verticaldist().
  58. set t1 to time:seconds.
  59. print "Vertical Difference "+round(verticalDistance1)+" m".
  60. print " ".
  61. print "Vertical Input "+round(100*verticalinput).
  62. wait 0.2.
  63. clearscreen.
  64. set verticalDistance2 to verticaldist().
  65. set t2 to time:seconds.
  66. set dt to t2-t1.
  67. }. //this is just so i can hide it easily
  68. ////////////////////////////////////////////
  69. set verticalinput to verticalinputfunction().
  70. ///////////////////////////////////////////
  71. set ship:control:top to verticalinput.
  72. set foreinput to 0.1*(desiredT-ship:orbit:period).
  73. set ship:control:fore to foreinput.
  74. print "Foreward Input "+(100*round(foreinput)).
  75. }.
  76. ag1 off.
  77.  
  78. unlock steering.
  79. sas on.
  80. set ang to 2. //between ship and target positions
  81. set theta to 1.
  82. until ang < theta {
  83. set targpos to target:position+ship:body:position.
  84. set ang to vang(ship:body:position,targpos).
  85. set dist to 1000*13.8.//m. value obtained from space mech notes
  86. set theta to (180/pi)*(dist/ship:body:position:mag).
  87. print "Awaiting Burn".
  88. print "Loop ends at zero: "+round(1000*(ang-theta)).
  89. wait 0.1.
  90. clearscreen.
  91. }
  92. set warp to 0.
  93. sas off.
  94. lock steering to prograde + r(0,0,180).
  95.  
  96. //this is about 1.4 m/s dv prograde
  97. //foreward acceleration averages .4 m/s2
  98. set v0 to ship:velocity:orbit:mag.
  99. set ship:control:fore to 1.
  100. wait until ship:velocity:orbit:mag>(v0+3.4).
  101. set ship:control:neutralize to true.
  102. unlock steering.
  103. sas on.
  104. until ag1 {
  105. print "Altitude Difference: "+round(target:altitude-ship:altitude)+" meters".
  106. wait 0.1.
  107. clearscreen.
  108. }
  109. ag1 off.
  110. run twokmclosing.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement