Advertisement
KSA_MissionCtrl

sndRocket.ks 5/18

May 17th, 2015
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. function LogData {
  2. parameter text.
  3.  
  4. // print to both the console and log
  5. print "[" + time:clock + "] " + text.
  6. log "[" + time:clock + "] " + text to missionlog.
  7.  
  8. // make a copy on the local KSC archive
  9. copy missionlog to 0.
  10. }.
  11.  
  12. clearscreen.
  13. LogData("Sounding Rocket Flight Program initiating...").
  14.  
  15. // find all our parts
  16. set sep to ship:partstagged("sep")[0].
  17. set exp to ship:partstagged("exp")[0].
  18. set srb to ship:partstagged("srb")[0].
  19. set chute to ship:partstagged("chute")[0].
  20. set clamp to ship:partstagged("clamp")[0].
  21. set probe to ship:partstitled("Avionics Package")[0].
  22. set fairings to ship:partstagged("fairing").
  23.  
  24. // all good, begin the countdown
  25. LogData("GO for launch!").
  26. wait 1.
  27. LogData("T-10").
  28. wait 1.
  29. LogData("T-9").
  30. wait 1.
  31. LogData("T-8").
  32. wait 1.
  33. LogData("T-7").
  34. wait 1.
  35. LogData("T-6").
  36. wait 1.
  37. LogData("T-5").
  38. wait 1.
  39. LogData("T-4").
  40. wait 1.
  41. LogData("T-3").
  42. wait 1.
  43. LogData("T-2").
  44. wait 1.
  45. LogData("T-1").
  46. wait 1.
  47.  
  48. // fire the engine and detach from the launch stick
  49. srb:getmodule("ModuleEngines"):doevent("activate engine").
  50. clamp:getmodule("ModuleAnchoredDecoupler"):doevent("decouple").
  51. LogData("Liftoff!!").
  52.  
  53. // wait until engine expires
  54. until srb:getmodule("ModuleEngines"):getfield("status") = "flame-out!" {}.
  55. LogData("SRB flame out detected. Decoupling").
  56.  
  57. // ditch the SRB and then await negative vertical velocity
  58. sep:getmodule("ModuleDecouple"):doevent("decouple").
  59. LogData("Awaiting apoapsis for chute deployment").
  60. until ship:verticalspeed <= 0 {}.
  61.  
  62. // pop the chute and dump the fairings
  63. // TODO: Change to wait until ship speed is below supersonic
  64. LogData("Deploying chute, releasing payload fairings").
  65. chute:getmodule("ModuleParachute"):doevent("deploy chute").
  66. for fairing in fairings {
  67. fairing:getmodule("ModuleDecouple"):doevent("decouple").
  68. }
  69.  
  70. // confirm chute is open and run science experiments
  71. until chute:getmodule("ModuleParachute"):hasevent("cut chute") {}.
  72. LogData("Chute deployed, running experiments").
  73. exp:getmodule("moduleScienceExperiment"):doevent("record aeronomical data").
  74. probe:getmodule("moduleScienceExperiment"):doevent("collect data").
  75.  
  76. // done! All data will be stored for retrieval, as battery power will not last until landing
  77. LogData("All events have executed. Awaiting landing & retrieval").
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement