KSP Lalande log 3

// 60101 Mun autolander program test

Second iteration of autoland script for kOS. Script waits until over target within 10 degrees, then executes retro burn followed by pitch control to track onto landing target. Multiple failed iterations. Current script does not auto-throttle for descent phase, but managed to crash directly into the landing target. Success. Image 1, 2, 3, 4.

Full script:

// kOS semi-autoland. (c) 2016 Aaron Lahman
// Source license: http://www.wtfpl.net/txt/copying/

// this script assumes a targeted vessel/object for landing, and the
// ship is already on a flight path over the target.

clearscreen.
print "mode: flyby".

// phase 1: target acquisition
lock shipFuturePosition to ship:position + (ship:velocity:surface * 5.0).
lock dTarget to (shipFuturePosition - target:position).
wait until VECTORANGLE(target:up:vector, dTarget) < 15.

// phace 2: retro burn to enter descent
print "mode: retro burn turn".
lock steering to ship:srfretrograde.
wait until VECTORANGLE(ship:facing:vector, ship:srfretrograde:vector) < 10.

print "mode: retro burn".
SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0. // cancel any old pilot input
lock throttle to 1.0.
wait until ship:velocity:surface:mag < 20.0.

// phase 2: controlled descent 
print "mode: final approach".
unlock throttle.
lock desiredVelocity to ship:altitude / 100.0 + 3.0.
lock dTargetCorrection to ship:up:vector - dTarget:normalized. // orientation correction
lock steering TO ship:up:vector + dTargetCorrection * 0.5.
wait until ship:status = "LANDED".

print "done".
unlock steering.
unlock throttle.

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.