Initial commit.
This commit is contained in:
commit
c3ab101f8b
4
boot/rocket.ks
Normal file
4
boot/rocket.ks
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
COPYPATH("0:/noop", "").
|
||||||
|
COMPILE "0:/launch" to "1:/launch".
|
||||||
|
|
||||||
|
SET core:bootfilename to "noop".
|
6
dbgparts.ks
Normal file
6
dbgparts.ks
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
set outfile to "0:/parts.txt".
|
||||||
|
log "======== New run ========" to outfile.
|
||||||
|
for i in range(0,ship:parts:length) {
|
||||||
|
log "___Modules for ship:parts[" + i + "]____" to outfile.
|
||||||
|
log ship:parts[i]:allmodules to outfile.
|
||||||
|
}
|
93
launch.ks
Normal file
93
launch.ks
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
DECLARE FUNCTION throttle_to_twr {
|
||||||
|
declare parameter x is 1.5.
|
||||||
|
|
||||||
|
local m is ship:mass.
|
||||||
|
local g is 9.81.
|
||||||
|
if has_grav_sensor = true {
|
||||||
|
set g to ship:sensors:grav:mag.
|
||||||
|
}
|
||||||
|
print "Locking throttle to: " + min((x*m*g)/ship:availablethrust, 1.0).
|
||||||
|
lock throttle to min((x*m*g)/ship:availablethrust, 1.0).
|
||||||
|
}
|
||||||
|
|
||||||
|
DECLARE FUNCTION twr {
|
||||||
|
local m is ship:mass.
|
||||||
|
local g is 9.81. // fallback to this approximation that doesn't deal with
|
||||||
|
// altitude change.
|
||||||
|
if has_grav_sensor = true {
|
||||||
|
set g to ship:sensors:grav:mag.
|
||||||
|
}
|
||||||
|
local t is throttle * ship:availablethrust.
|
||||||
|
print "Mass: " + ship:mass.
|
||||||
|
print "Throttle: " + throttle.
|
||||||
|
print "Thrust (max): " + ship:availablethrust.
|
||||||
|
print "TWR = " + t/(m*g).
|
||||||
|
return t/(m*g).
|
||||||
|
}
|
||||||
|
|
||||||
|
LOCAL has_grav_sensor is false.
|
||||||
|
DECLARE FUNCTION sensor_check {
|
||||||
|
list sensors in senselist.
|
||||||
|
for s in senselist {
|
||||||
|
if s:type = "grav" {
|
||||||
|
print "Gravometric sensor detected".
|
||||||
|
set has_grav_sensor to true.
|
||||||
|
return.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set has_grav_sensor to false.
|
||||||
|
}
|
||||||
|
|
||||||
|
// countdown
|
||||||
|
sensor_check().
|
||||||
|
LOCAL done is false.
|
||||||
|
PRINT "Initiating automated launch sequence".
|
||||||
|
FROM { local x is 5. } UNTIL x = 0 STEP { set x to x - 1. } DO {
|
||||||
|
PRINT "..." + x.
|
||||||
|
WAIT 1.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logic for initial ascent.
|
||||||
|
SAS OFF.
|
||||||
|
LOCK throttle to 1.0.
|
||||||
|
LOCK steering to up.
|
||||||
|
STAGE.
|
||||||
|
|
||||||
|
WHEN ship:altitude > 1000 THEN {
|
||||||
|
PRINT "Vectoring away from launchpad".
|
||||||
|
LOCK steering to HEADING(90, 88).
|
||||||
|
WHEN ship:altitude > 8000 THEN {
|
||||||
|
// begin "gravity" curve
|
||||||
|
PRINT "Beginning orbital insertion turn".
|
||||||
|
LOCK steering to HEADING(90,80).
|
||||||
|
WAIT 1.
|
||||||
|
LOCK steering to HEADING(90,70).
|
||||||
|
WAIT 1.
|
||||||
|
LOCK steering to HEADING(90,60).
|
||||||
|
WAIT 3.
|
||||||
|
LOCK steering to ship:prograde.
|
||||||
|
|
||||||
|
WHEN ship:apoapsis > 70000 THEN {
|
||||||
|
LOCK throttle to 0.0.
|
||||||
|
// todo: automate orbital insertion.
|
||||||
|
PRINT "Initial ascent complete. Manually perform orbital insertion. Good luck, Kerman!".
|
||||||
|
SET done to true.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Control rate of ascent to reduce drag.
|
||||||
|
UNTIL ship:altitude > 32000 {
|
||||||
|
if twr() > 1.5 {
|
||||||
|
throttle_to_twr(1.5).
|
||||||
|
}
|
||||||
|
wait 0.001.
|
||||||
|
}
|
||||||
|
lock throttle to 1.0.
|
||||||
|
|
||||||
|
// throttle_to_twr(1.5).
|
||||||
|
// WHEN ship:altitude > 32000 THEN {
|
||||||
|
// lock throttle to 1.0.
|
||||||
|
// }
|
||||||
|
|
||||||
|
WAIT UNTIL done.
|
Loading…
Reference in New Issue
Block a user