Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clearscreen.
- settings().
- deorbit().
- noseconeclose().
- reentry().
- function settings {
- set missionstatus to "Ready for trunk separation, press 9 to separate".
- ag9 off.
- set noseconehinge to ship:partsdubbed("nosehinge")[0].
- set landingSite to latlng(0, -70.5).
- set dlng to landingSite:lng-180.
- set shipLatlng to ship:geoposition.
- set droguealt to 2750.
- set mainalt to 1000.
- rcs on.
- sas off.
- lock steering to retrograde.
- }
- function deorbit {
- until ag9 {
- printing().
- }
- stage.
- set missionstatus to "Trunk has been separated, awaiting for targeted longitude for deorbit burn".
- until shipLatlng:lng < dlng + 0.5 and shipLatlng:lng > dlng - 0.5 {
- printing().
- }
- set missionstatus to "Starting deorbit".
- set deg to max(3.4, (min(35, abs(latoff/1000)))*2).
- set sign to abs(latoff)/latoff.
- set degf to deg*sign.
- lock steering to heading(270+degf, 0).
- when min(35, abs(latoff/1000))*2 = 0 then {
- set sign to 0.
- set degf to 0.
- preserve.
- }
- set ship:control:fore to 1.
- until lngoff > -4000 and periapsis < 55000 {
- printing().
- set deg to max(1, (min(45, abs(latoff/1000)))*2).
- set sign to abs(latoff)/latoff.
- set degf to deg*sign.
- }
- set ship:control:fore to 0.
- set missionstatus to "Deorbit has ended, maintaining retrograde for reentry".
- lock steering to srfretrograde.
- print "Final lngoff :" + lngoff + " Meters".
- print "Final latoff :" + latoff + " Meters".
- until vang(ship:facing:vector, -ship:velocity:surface) < 0.25 {
- printing().
- }
- print "Entry orientation is maintained".
- wait 5.
- }
- function noseconeclose {
- set missionstatus to "Nosecone closing in progress, entry orientation is maintained".
- noseconehinge:getmodule("ModuleRoboticServoHinge"):setfield("Locked", 0).
- wait 0.1.
- noseconehinge:getmodule("ModuleRoboticServoHinge"):setfield("Traverse Rate", 5).
- noseconehinge:getmodule("ModuleRoboticServoHinge"):setfield("Target Angle", -90).
- until noseconehinge:getmodule("ModuleRoboticServoHinge"):getfield("Current Angle") = -90 {
- clearscreen.
- print("Nosecone Angle is " + noseconehinge:getmodule("ModuleRoboticServoHinge"):getfield("Current Angle") + " Degrees").
- print("Difference between deployed and current is " + (-90 - noseconehinge:getmodule("ModuleRoboticServoHinge"):getfield("Current Angle")) + " Degrees").
- }
- print "Nosecone is closed".
- set missionstatus to "Nosecone is closed, getting ready for entry".
- wait 3.
- noseconehinge:getmodule("ModuleRoboticServoHinge"):setfield("Locked", 1).
- }
- function reentry {
- until altitude < 70000 {
- printing().
- }
- set missionstatus to "We have entered the atmosphere, awaiting for drogue chutes deployment".
- until altitude < droguealt {
- printing().
- }
- stage.
- unlock steering.
- set missionstatus to "Drogue chutes are deployed, awaiting main chutes deployment".
- until altitude < mainalt {
- printing().
- }
- stage.
- wait 1.
- ag8 on.
- set missionstatus to "Main chutes are deployed, awaiting for splashdown".
- until ship:status = "Landed" or "Splashed" {
- printing().
- }
- set missionstatus to "Dragon is splashed down".
- rcs off.
- sas off.
- unlock steering.
- unlock throttle.
- }
- function abortofscript {
- clearscreen.
- print "Program aborted".
- wait 2.
- print 3/0.
- }
- function printing {
- clearscreen.
- print "Mission Status: " + missionstatus.
- print "Current Longitude: " + round(shipLatlng:lng, 4) + " Degrees".
- print "Current Latitude: " + round(shipLatlng:lat, 4) + " Degrees".
- print "Target Longitude: " + tlng + " Degrees".
- print "Target Latitude: " + tlat + " Degrees".
- print "Impact Longitude: " + round(ImpactPosition:lng, 4) + " Degrees".
- print "Impact Latitude: " + round(ImpactPosition:lat, 4) + " Degrees".
- print "Impact Longitude Difference: " + round(lngoff, 1) + " Meters".
- print "Impact Latitude Difference: " + round(latoff, 1) + " Meters".
- print "Drogue chutes deployment altitude: " + droguealt + " Meters".
- print "Main chutes deployment altitude: " + mainalt + " Meters".
- print "Press 10 to abort current program".
- set shipLatlng to ship:geoposition.
- set lngoff to 10472*(ImpactPosition():lng - landingSite:lng).
- set latoff to 10472*(ImpactPosition():lat - landingSite:lat).
- wait 0.1.
- }
- function ImpactPosition {
- if addons:tr:hasimpact {
- return addons:tr:impactpos.
- } else {
- return ship:geoposition.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment