Created
December 30, 2014 22:45
-
-
Save edvardm/a58a426a27d2acb1e128 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET g TO 0.05 * 9.81. // minmus | |
// SET g TO 0.166 * 9.81. // mun | |
SET f TO 50. | |
LOCK m TO SHIP:MASS. | |
LOCK aTot TO g - F/m. | |
LOCK tThrottle TO v0 / aTot. | |
SET LANDED_ALTITUDE TO 10.0. | |
LOCK v0 TO SHIP:VERTICALSPEED. | |
LOCK alt to ALT:RADAR. | |
LOCK landed TO alt <= LANDED_ALTITUDE. | |
LOCK dbr TO m*v0*v0 / 2 / (f - m*g). | |
// Main | |
CLEARSCREEN. | |
GEAR OFF. | |
PRINT "Initiating landing sequence program.". | |
PRINT "Kill horizontal velocity". | |
SET STEERING to RETROGRADE. | |
WAIT 10.0. | |
SAS ON. | |
RCS ON. | |
UNTIL SURFACESPEED < 1.0 { | |
LOCK THROTTLE to 1.0. | |
} | |
RCS OFF. | |
SAS OFF. | |
LOCK THROTTLE to 0.0. | |
// ROTATE to upward position | |
LOCK STEERING to HEADING(90, 90). | |
WAIT 10.0. | |
GEAR ON. | |
PRINT "Measuring fuel consumption rate". | |
lock throttle to 1.0. | |
set m0 to m. | |
wait 1.0. | |
lock throttle to 0. | |
set rM to m - m0. | |
print "rM: " + round(rM, 3). | |
LOCK m2 TO m + tThrottle*rM. | |
LOCK dbr2 TO m2*v0*v0 / 2 / (f - m2*g). | |
LOCK dbrAvg TO (dbr + dbr2)/2. | |
WHEN alt < dbr2 THEN { | |
PRINT "Altitude smaller than breaking distance => throttle on.". | |
LOCK THROTTLE to 1.0. | |
LIGHTS ON. | |
}. | |
WHEN landed THEN { | |
PRINT "Ready for landing, throttle and aux systems off.". | |
LOCK THROTTLE to 0. | |
SET msg TO "landed: " + landed. | |
PRINT msg AT (0, 15). | |
SET msg TO "status: " + status. | |
PRINT msg AT (0, 16). | |
RCS OFF. | |
}. | |
WHEN v0 >= -3.0 THEN { | |
lock throttle to m*g/f. | |
} | |
UNTIL landed { | |
SET msg TO "alt: " + round(alt, 3). | |
PRINT msg AT (0, 10). | |
SET msg TO "dbr: " + round(dbr, 3). | |
PRINT msg AT (0, 11). | |
SET msg TO "v: " + round(v0, 3). | |
PRINT msg AT (0, 12). | |
SET msg TO "deltaD: " + round((alt - dbrAvg), 3). | |
PRINT msg AT (0, 13). | |
SET msg TO "mass: " + round(m, 3). | |
PRINT msg AT (0, 14). | |
SET msg TO "landed: " + landed. | |
PRINT msg AT (0, 15). | |
SET msg TO "status: " + status. | |
PRINT msg AT (0, 16). | |
SET msg TO "dbrAvg: " + round(dbrAvg, 3). | |
PRINT msg AT (0, 20). | |
}. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment