Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // manual abort procedure
- on abort {
- LogData("ABORT ABORT ABORT!!").
- // we can't kill engine thrust
- // detach the payload, fairings and deploy the chute when able
- sep:getmodule("ModuleDecouple"):doevent("decouple").
- for fairing in fairings {
- fairing:getmodule("ModuleDecouple"):doevent("decouple").
- }
- LogData("Payload free, awaiting safe chute deployment").
- // this line below was missing!! Copy and past fail :(
- // Runtime error thrown when the variable could not be found by the following line
- set minDeployAlt to chute:getmodule("moduleparachute"):getfield("altitude").
- until ship:altitude < minDeployAlt and chute:getmodule("moduleparachute"):getfield("safe to deploy?") = "safe" {}.
- // pop the chute
- LogData("Deploying chute").
- chute:getmodule("ModuleParachute"):doevent("deploy chute").
- // confirm chute is open and run science experiments
- until chute:getmodule("ModuleParachute"):hasevent("cut parachute") {}.
- LogData("Chute deployment successful, running experiments...").
- toggle AG1.
- until avionics:hasevent("review telemetry") and science:hasevent("reset meteorological data") {}.
- LogData("Experiment run complete!").
- }
- function LogData {
- parameter text.
- // print to both the console and log
- print "[" + time:clock + "] " + text.
- log "[" + time:clock + "] " + text to missionlog.
- copy missionlog to 0.
- }.
- function Launch {
- clearscreen.
- LogData("Sounding Rocket Flight Program initiating...").
- // find all our parts
- set sre1 to ship:partstagged("sre1")[0].
- set sre2 to ship:partstagged("sre2")[0].
- set chute to ship:partstagged("chute")[0].
- set clamp to ship:partstagged("clamp")[0].
- set sep to ship:partstagged("sep")[0].
- set avionics to ship:partstagged("avionics")[0].
- set science to ship:partstagged("science")[0].
- set fairings to ship:partstagged("fairing").
- // perform pre-launch checks
- if fairings:length < 2 {
- LogData("ERR: Fairing parts missing, only found " + fairings:length).
- return false.
- }.
- wait 1.
- LogData("All systems nominal").
- // check engine thrust
- list engines in englist.
- for eng in englist {
- if eng:tag = "sre1" {
- if eng:thrustlimit <> 46.5 {
- LogData("ERR: Improper thrust limiter set for SRE1. Thrust set to " + eng:thrustlimit + "%").
- return false.
- }
- }
- if eng:tag = "sre2" {
- if eng:thrustlimit <> 48 {
- LogData("ERR: Improper thrust limiter set for SRE2. Thrust set to " + eng:thrustlimit + "%").
- return false.
- }
- }
- }
- wait 1.
- LogData("All engines nominal").
- // all good, begin the countdown
- LogData("GO for launch!").
- wait 1.
- LogData("T-10").
- wait 1.
- LogData("T-9").
- wait 1.
- LogData("T-8").
- wait 1.
- LogData("T-7").
- wait 1.
- LogData("T-6").
- wait 1.
- LogData("T-5").
- wait 1.
- LogData("T-4").
- wait 1.
- LogData("T-3").
- wait 1.
- LogData("T-2").
- wait 1.
- LogData("T-1").
- wait 1.
- // fire the engine and detach from the launch stick
- // direct commands replaced by stage command to trigger data loggers
- // sre1:getmodule("ModuleEngines"):doevent("activate engine").
- // clamp:getmodule("ModuleAnchoredDecoupler"):doevent("decouple").
- stage.
- LogData("Liftoff!!").
- // wait until engine expires then stage
- until sre1:getmodule("ModuleEngines"):getfield("status") = "flame-out!" {
- if abort { return false. }.
- }.
- wait 0.5.
- sre2:getmodule("ModuleEngines"):doevent("activate engine").
- LogData("Stage 1 flame out detected. Stage 2 activated").
- // wait until engine expires then stage
- until sre2:getmodule("ModuleEngines"):getfield("status") = "flame-out!" {
- if abort { return false. }.
- }.
- LogData("Stage 2 flame out detected").
- // wait until apokee (with a litte fudge)
- until ship:altitude >= (ship:obt:apoapsis - 5) {}.
- LogData("Apokee achieved - releasing payload fairings").
- for fairing in fairings {
- fairing:getmodule("ModuleDecouple"):doevent("decouple").
- }
- toggle AG1.
- LogData("Experiments running...").
- until avionics:hasevent("review telemetry") and science:hasevent("Reset meteorological data") {}.
- LogData("Experiment run complete! Awaiting safe conditions for chute deployment").
- set minDeployAlt to chute:getmodule("moduleparachute"):getfield("altitude").
- until ship:altitude < minDeployAlt and chute:getmodule("moduleparachute"):getfield("safe to deploy?") = "safe" {}.
- // pop the chute
- LogData("Deploying chute").
- chute:getmodule("ModuleParachute"):doevent("deploy chute").
- // confirm chute is open and run science experiments
- until chute:getmodule("ModuleParachute"):hasevent("cut parachute") {}.
- LogData("Chute deployment successful").
- return true.
- }
- // done! All data will be stored for retrieval, as battery power may not last until landing
- if Launch() {
- LogData("All events have executed. Awaiting landing & retrieval").
- }.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement