Add aircraft automation code, including flap control and stable autopilot flight.

This commit is contained in:
Anna Rose Wiggins 2021-08-24 06:10:21 -04:00
parent a99912e3ae
commit 376629354b
9 changed files with 204 additions and 19 deletions

View file

@ -1,5 +1,6 @@
RunOncePath("lib/throttle").
RunOncePath("lib/navigation").
RunOncePath("lib/navball").
// Calculate the direction to lock during ascent.
function getClampedDir {
@ -8,18 +9,12 @@ function getClampedDir {
// face just beneath prograde, but hold a solid eastern heading and don't
// rotate the ship
local newHeading is lookdirup(SHIP:SRFPROGRADE:FOREVECTOR, heading(90, 0, 270):TOPVECTOR).
if getPitch(newHeading:FOREVECTOR) < minPitch {
if GetPitch(newHeading:FOREVECTOR) < minPitch {
set newHeading to heading(90, minPitch, 270).
}
return newHeading.
}
// Returns the navball pitch of a given vector.
function getPitch {
parameter v is SHIP:FACING:FOREVECTOR.
return 90 - vectorangle(SHIP:UP:FOREVECTOR, v).
}
// Given a target (end) pitch, a target duration, and a start time,
// returns the correct current heading.
function pitchProgram {