Pin down more of the logic for flight control.
This commit is contained in:
parent
5b9da6f0f1
commit
34ddc42b37
|
@ -2,7 +2,8 @@
|
|||
|
||||
// Install software.
|
||||
compile "0:/os/rocketos" to "1:/boot/rocketos".
|
||||
compile "0:/lib/guidance" to "1:/lib/guidance".
|
||||
compile "0:/lib/navigation" to "1:/lib/navigation".
|
||||
compile "0:/lib/throttle" to "1:/lib/throttle".
|
||||
compile "0:/launch" to "1:/launch".
|
||||
|
||||
// Set OS to boot and restart.
|
||||
|
|
59
launch.ks
59
launch.ks
|
@ -1,7 +1,10 @@
|
|||
run once "lib/guidance".
|
||||
run once "lib/throttle".
|
||||
run once "lib/navigation".
|
||||
|
||||
local APOAPSIS_TARGET is 80000.
|
||||
local GRAVITY_TURN_START is 5000.
|
||||
parameter APOAPSIS_TARGET is 80000.
|
||||
parameter GRAVITY_TURN_START is 8000.
|
||||
parameter GRAVITY_PITCH is 75.
|
||||
parameter INITIAL_PITCH is 85.
|
||||
SensorCheck().
|
||||
|
||||
// Configure subsystems.
|
||||
|
@ -13,9 +16,8 @@ SAS off.
|
|||
print "Initiating automated launch sequence".
|
||||
from { local x is 5. } until x = 0 step { set x to x - 1. } do {
|
||||
print "..." + x.
|
||||
wait 1.
|
||||
wait 0.5.
|
||||
}
|
||||
print "Launching".
|
||||
|
||||
// throttle controls
|
||||
when TWR() > 1.5 then {
|
||||
|
@ -30,26 +32,55 @@ when TWR() > 1.5 then {
|
|||
|
||||
// Main ascent control.
|
||||
lock THROTTLE to 1.0.
|
||||
lock STEERING to heading(90,90,-90).
|
||||
lock STEERING to heading(90,90,270).
|
||||
stage.
|
||||
|
||||
// // DEBUG
|
||||
// until false {
|
||||
// lock STEERING to heading(90,90,-90).
|
||||
// wait 3.
|
||||
// lock STEERING to SHIP:SRFPROGRADE.
|
||||
// wait 3.
|
||||
// }
|
||||
|
||||
wait until SHIP:ALTITUDE > 200.
|
||||
lock STEERING to heading(90, 85, -90).
|
||||
lock STEERING to heading(90, GRAVITY_PITCH, 270).
|
||||
|
||||
wait until SHIP:ALTITUDE > GRAVITY_TURN_START.
|
||||
print "Beginning gravity turn".
|
||||
|
||||
print "Pitching for gravity turn".
|
||||
|
||||
// Perform initial pitch...
|
||||
lock STEERING to heading(90, GRAVITY_PITCH, 270).
|
||||
// Wait until we have rotated to that pitch...
|
||||
wait until vectorangle(
|
||||
SHIP:FACING:FOREVECTOR,
|
||||
STEERINGMANAGER:TARGET:FOREVECTOR)
|
||||
< 0.5.
|
||||
// then wait until Prograde catches up.
|
||||
wait until vectorangle(
|
||||
SHIP:SRFPROGRADE:FOREVECTOR,
|
||||
STEERINGMANAGER:TARGET:FOREVECTOR)
|
||||
< 0.5.
|
||||
|
||||
print "Locking to prograde".
|
||||
|
||||
until SHIP:ORBIT:APOAPSIS > 80000 {
|
||||
local adjustedPrograde is SHIP:ORBIT:PROGRADE * NORTH.
|
||||
local angle is max(30, adjustedPrograde:pitch).
|
||||
print "Adjusted Prograde = " + adjustedPrograde.
|
||||
print "Angle = " + angle.
|
||||
lock STEERING to heading(90, angle, -90).
|
||||
// todo: we may need different values for bodies other than Kerbin.
|
||||
local newHeading is lookdirup(SHIP:SRFPROGRADE:FOREVECTOR,
|
||||
heading(90, 0, 270):TOPVECTOR).
|
||||
if GetPitch(newHeading:FOREVECTOR) < 40 {
|
||||
set newHeading to heading(90, 40, 270).
|
||||
}
|
||||
lock STEERING to newHeading.
|
||||
wait 0.001.
|
||||
}
|
||||
|
||||
print "Releasing controls. Good luck, Kerman!".
|
||||
set THROTTLE to 0.0.
|
||||
lock THROTTLE to 0.0.
|
||||
wait 0.001.
|
||||
unlock THROTTLE.
|
||||
unlock STEERING.
|
||||
SAS on.
|
||||
wait 5.
|
||||
CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Close Terminal").
|
||||
|
|
6
lib/navigation.ks
Normal file
6
lib/navigation.ks
Normal file
|
@ -0,0 +1,6 @@
|
|||
@lazyglobal off.
|
||||
|
||||
function GetPitch {
|
||||
parameter v is SHIP:FACING:FOREVECTOR.
|
||||
return 90 - vectorangle(SHIP:UP:FOREVECTOR, v).
|
||||
}
|
|
@ -1,13 +1,36 @@
|
|||
function launchButtonPressed {
|
||||
run "launch".
|
||||
run "launch"(
|
||||
targetApo:TEXT:ToNumber(),
|
||||
gravTurnStart:TEXT:ToNumber(),
|
||||
initialPitch:TEXT:ToNumber()
|
||||
).
|
||||
}
|
||||
|
||||
// Button panel
|
||||
local interface is gui(200).
|
||||
set interface:X to 150.
|
||||
set interface:Y to 900.
|
||||
|
||||
// Launch button
|
||||
local launchButton is interface:addbutton("Launch").
|
||||
local hBox is interface:AddHBox().
|
||||
hBox:AddLabel("Initial Pitch").
|
||||
local initialPitch is hBox:AddTextField("85").
|
||||
|
||||
local hBox is interface:AddHBox().
|
||||
hBox:AddLabel("Gravity Turn @").
|
||||
local gravTurnStart is hBox:AddTextField("8000").
|
||||
|
||||
local hBox is interface:AddHBox().
|
||||
hBox:AddLabel("Gravity Pitch").
|
||||
local gravPitch is hBox:AddTextField("75").
|
||||
|
||||
local hBox is interface:AddHBox().
|
||||
hBox:AddLabel("Target Apoapsis").
|
||||
local targetApo is hBox:AddTextField("80000").
|
||||
|
||||
local launchButton is interface:AddButton("Launch").
|
||||
set launchButton:onClick to launchButtonPressed@.
|
||||
|
||||
interface:show().
|
||||
|
||||
wait until false.
|
||||
|
|
Loading…
Reference in New Issue
Block a user