Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Settings
- clearscreen.
- set preset to "My Mum Wonders About Me".
- lock alt to ship:altitude - 23.
- set landingZone to vessel("My Mum Wonders About Me"):geoposition.
- set entryburnalt to 35000.
- lock lngoff to (landingZone:LNG - ADDONS:TR:IMPACTPOS:LNG)*10472.
- lock latoff to (landingZone:LAT - ADDONS:TR:IMPACTPOS:LAT)*10472.
- lock myvel to ship:velocity:surface:mag.
- lock g to constant:g * body:mass / body:radius^2.
- lock maxDecel to (ship:availablethrust / ship:mass) - g.
- lock stopDist to ship:verticalspeed^2 / (2 * maxDecel).
- lock idealThrottle to stopDist / alt.
- lock impactTime to alt / abs(ship:verticalspeed).
- set errorScaling to 1.
- lock steering to heading(90, 90).
- sas off.
- rcs on.
- set rm to 1.
- set done to false.
- until done {
- //Ascent to Apoapsis and orient for entry burn
- if rm = 1 {
- print "Welcome to Falcon 9 Landing Software V4".
- print "Your preset is " + preset.
- wait until ship:verticalspeed < -200.
- lock steering to srfretrograde.
- set rm to 2.
- }
- //Entry burn performing
- if rm = 2 {
- wait until alt < entryburnalt + 7000.
- set ship:control:fore to 1.
- wait 4.
- set ship:control:fore to 0.
- wait until alt < entryburnalt + 50.
- set targetspeedonentry to ship:velocity:surface:mag - 275.
- lock throttle to 1.
- lock aoa to -10.
- lock steering to getSteering().
- wait 2.
- toggle ag6.
- wait until myvel < targetspeedonentry.
- lock throttle to 0.
- lock aoa to 45.
- lock steering to getSteering().
- wait until alt < 6000.
- lock aoa to 35.
- wait until alt < 3500.
- set rm to 3.
- }
- //Hoverslam
- wait 0.
- if rm = 3 {
- wait 0.
- wait until alt < stopDist.
- lock throttle to idealThrottle.
- lock aoa to -10.
- wait until alt < 140.
- lock steering to ship:srfretrograde.
- wait until alt < 90.
- lock steering to up.
- toggle gear.
- set rm to 4.
- wait 0.
- }
- wait 0.
- if rm = 4 {
- wait 0.
- wait until ship:verticalspeed > -1.
- lock throttle to 0.01.
- wait 4.
- lock throttle to 0.
- print "Landing confirmed!".
- print landingZone.
- print ship:geoposition.
- wait 20.
- unlock steering.
- unlock throttle.
- sas off.
- rcs off.
- toggle brakes.
- set done to true.
- }
- }
- //Functions
- function getImpact {
- if addons:tr:hasimpact { return addons:tr:impactpos. }
- return ship:geoposition.
- }
- function lngError {
- return getImpact():lng - landingZone:lng.
- }
- function latError {
- return getImpact():lat - landingZone:lat.
- }
- function errorVector {
- return getImpact():position - landingZone:position.
- }
- function getSteering {
- local errorVector is errorVector().
- local velVector is -ship:velocity:surface.
- local result is velVector + errorVector*errorScaling.
- if vang(result, velVector) > aoa
- {
- set result to velVector:normalized + tan(aoa)*errorVector:normalized.
- }
- return lookdirup(result, facing:topvector).
- }
Advertisement
Add Comment
Please, Sign In to add comment