Guest User

Utop_circularisation

a guest
May 3rd, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1. declare PARAMETER aimvalue.
  2. //how precise do you want to be? 1.01 = 1% difference.
  3.  
  4. //BOOT PROCESS - STAGE FUNCTION COPIED.
  5. DECLARE FUNCTION STAGEPROCESS {
  6. LIST ENGINES IN SHIPENG.
  7. SET numOut TO 0.
  8.  
  9. if stage:number > 0 AND THROTTLE > 0.01 {
  10. FOR eng IN SHIPENG {
  11. IF eng:FLAMEOUT {
  12. SET numOut TO numOut + 1.
  13. }
  14. }
  15. IF MAXTHRUST = 0 {
  16. PRINT "...STAGING." + STAGE:NUMBER. //AT (0,20)
  17. SET numOut TO numOut + 1.
  18. }
  19. }
  20.  
  21. if numOut >0 {stage.
  22. wait 1.}
  23. }
  24.  
  25. //BASE DATA (from orbit script)
  26. LOCK DIR to 90.
  27. LOCK DIRPLAN7 to HEADING (DIR,90).
  28. LOCK DIRPLAN8 to HEADING (DIR,-90).
  29.  
  30. //MARGIN DESIGN - how much time before and after the manoeuver is acceptable.
  31.  
  32. LOCK MARGalt to MIN((22500*(aimvalue-1.01)+100),1000).
  33.  
  34. //CIRCULARISATION VALUES.
  35.  
  36. SET BASECIRCA to (alt:apoapsis/alt:periapsis).
  37. LOCK CIRCA to (alt:apoapsis/alt:periapsis).
  38. set MIDALTMAX to (((alt:apoapsis+alt:periapsis)/2) + MARGalt).
  39. set midalt to ((alt:apoapsis+alt:periapsis)/2).
  40. set MIDALTMIN to (((alt:apoapsis+alt:periapsis)/2) - MARGalt).
  41.  
  42. LOCK doradup to false.
  43. LOCK doradown to false.
  44.  
  45. //DECLARE CONDITIONS TO RADUP AND RADDOWN
  46. declare function RADUPCONDITIONS {
  47. if ( circa > aimvalue AND
  48. ship:verticalspeed < 0 AND
  49. ship:altitude < MIDALTMAX AND
  50. ship:altitude > MIDALT
  51. ) {
  52. set doradup TO true.
  53. //RADUP.
  54. }
  55. wait 0.001.
  56. }
  57.  
  58. declare function RADOWNCONDITIONS {
  59. if ( circa > aimvalue AND
  60. ship:verticalspeed > 0 AND
  61. ship:altitude > MIDALTMIN AND
  62. ship:altitude < MIDALT
  63. ) {
  64. set doradown TO true.
  65. // RADOWN.
  66. }
  67. wait 0.001.
  68. }
  69.  
  70. //this is the problem. I want to say IF CIRCA INCREASE THEN .....
  71. declare function failsafe {
  72. if basecirca < circa {
  73. set doradown to false.
  74. set doradup to false.
  75.  
  76.  
  77. SET BASECIRCA to (alt:apoapsis/alt:periapsis).
  78. set MIDALTMAX to (((alt:apoapsis+alt:periapsis)/2)+1000).
  79. set midalt to ((alt:apoapsis+alt:periapsis)/2).
  80. set MIDALTMIN to (((alt:apoapsis+alt:periapsis)/2)-1000).
  81. }
  82. }
  83.  
  84. //DECLARE MANOEUVERS FOR RADUP AND RADDOWN
  85. declare function RADUP {
  86. rcs on.
  87. PRINT "1A-ADJUSTING RADIALup" at (0,33).
  88. LOCK STEERING to DIRPLAN7.
  89. wait 1.
  90. PRINT "GO!"at (0,33).
  91. lock throttle to 0.5.
  92.  
  93. wait 0.01.
  94. }
  95.  
  96. declare function RADOWN {
  97. rcs on.
  98. PRINT "1B-ADJUSTING RADIALdown" at (0,33).
  99. LOCK STEERING to DIRPLAN8.
  100. wait 1.
  101. PRINT "GO!"at (0,33).
  102. lock throttle to 0.5.
  103.  
  104. wait 0.01.
  105. }
  106.  
  107. //CIRCULARIZE
  108. until circa < aimvalue {
  109. STAGEPROCESS.
  110.  
  111. PRINT "basecirca " + ROUND (circa,3) + " " AT (0,26).
  112.  
  113. PRINT "circa " + ROUND (circa,3) + " " AT (0,27).
  114. PRINT "midaltMIN " + ROUND (midaltMIN,3) + " " AT (0,28).
  115. PRINT "midaltMAX " + ROUND (midaltMAX,3) + " " AT (0,29).
  116. PRINT "target altitude " + ROUND (midalt,3) + " " AT (0,30).
  117.  
  118. failsafe.
  119. RADOWNCONDITIONS.
  120. RADUPCONDITIONS.
  121.  
  122. if doradup {radup.}
  123. else if doradown {radown.}
  124. else if ( doradup = false AND
  125. doradown = false
  126. ) {set throttle to 0.
  127. SET BASECIRCA to (alt:apoapsis/alt:periapsis).}
  128.  
  129. wait 0.01.
  130. }
  131.  
  132. //CLOSING PROGRAM
  133. if CIRCA < aimvalue {
  134. LOCK THROTTLE TO 0.0.
  135. LOCK STEERING TO PROGRADE.
  136. PRINT " ".
  137. PRINT "--CIRCULARIZATION SUCCESS--".
  138. PRINT "NEW DIFFERENTIAL DATA:" + ROUND (circa,3).
  139. SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0.
  140. RCS OFF.
  141. }
Advertisement
Add Comment
Please, Sign In to add comment