Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- -- Shuttle Autopilot Library by olex
- -- Version 1.0
- --
- -- for MechJeb 1.9.1
- --
- --------------------------------------------------------
- -- Usage: * save to KSP/PluginData/mumechlib/Shuttle.lua
- -- * in game, open autom8
- -- * enter: dofile("Shuttle.lua")
- -- * and follow the instructions.
- --
- -- Quicksave before using any of the functions.
- -- If an "coroutine out of sync" error pops up, load the save and try again.
- --
- -- No guarantees, but it should work :) Have fun!
- --------------------------------------------------------
- function PlaneLandingDriver(slope, offset)
- -- KSP coordinates
- lat = -0.103
- lon = -74.575
- -- "undershoot" offset and glide slope
- if (offset == nil) then
- offset = 40 -- default offset of 40km
- end
- lon = lon - (offset / 10) -- 1° ~= 10km near the KSP
- if (slope == nil) then
- slope = 3 -- default ILS glide slope of 3°
- end
- -- start re-entry sequence
- print "Deorbiting..."
- mechjeb.landAt(lat, lon, false)
- -- at 75km: cancel powered landing sequence, set attitude for aerodymanic flight, wings level
- wait(function() return (vessel.altitudeASL <= 75000) end )
- print "Beginning re-entry, hold onto something..."
- mechjeb.controlRelease()
- wait(3)
- mechjeb.attitudeTo({0,0,0,0}, "ORBIT")
- -- at 15km: engage the ILS
- wait(function() return (vessel.altitudeASL <= 15000) end )
- print "Initiating ILS approach, please lower landing gear manually."
- ils = mechjeb.getModule("ils")
- ils.glideslope = slope
- mechjeb.ilsLand()
- -- at 2m (immediately before touchdown)
- wait(function() return (vessel.altitudeTrue <= 2.5) end )
- print "Touching down, deploying braking parachutes (if you have any)..."
- mechjeb.controlRelease() -- stop ILS sequence
- mechjeb.attitudeTo({1,0,0,0}, "SURFACE_NORTH")
- mechjeb.stage() -- in case there actually are braking chutes
- -- at <5 m/s, we're done
- wait(function() return (vessel.speedSurface < 5) end )
- print "Welcome home. You can hit the brakes now."
- mechjeb.controlRelease()
- end
- function Land(slope)
- local co = coroutine.create(PlaneLandingDriver)
- coroutine.resume(co, slope)
- end
- print "Usage: Land(<glideslope, default 3°>, <glide distance offset, default 40km>)"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement