Compare commits
7 Commits
b636d4baa2
...
2b268e5e52
Author | SHA1 | Date |
---|---|---|
|
2b268e5e52 | |
|
253c9afca5 | |
|
6b5b88286b | |
|
88250d0170 | |
|
2648a543c8 | |
|
8bde14b93c | |
|
b2eb0188ea |
|
@ -15,23 +15,21 @@ FUNCTION NOTIFY {
|
|||
PRINT message.
|
||||
}
|
||||
|
||||
// This section from latest docs.
|
||||
WAIT UNTIL ship:unpacked.
|
||||
CLEARSCREEN.
|
||||
|
||||
NOTIFY("Boot sequence complete, prepare to load and compile the flight scripts.").
|
||||
|
||||
IF true { // Set this to false to avoid compiling ascent code.
|
||||
COMPILE "0:/RadarrSeries/radarr.kerbin.ks" to "1:/ascent.ksm". // Compile the flight code into a ksm object.
|
||||
COMPILE "0:/RadarrSeries/radarr_kerbin.ks" TO "1:/ascent.ksm". // Compile the flight code into a ksm object.
|
||||
} ELSE {
|
||||
COPYPATH("0:/RadarrSeries/radarr.kerbin.ks", "1:/ascent.ks"). // Copy over our launch script from the archive at ksc
|
||||
COPYPATH("0:/RadarrSeries/radarr_kerbin.ks", "1:/ascent.ks"). // Copy over our launch script from the archive at ksc
|
||||
}
|
||||
|
||||
// I changed this!
|
||||
|
||||
NOTIFY("Program compiled and ready to run.").
|
||||
|
||||
IF ALT:RADAR < 100 { // If our radar alt is lower than 10
|
||||
IF alt:radar < 100 { // If our radar alt is lower than 10
|
||||
WAIT 5.
|
||||
RUN ascent.ks. // Run the ascent stage!
|
||||
} else {
|
||||
RUN ascent. // Run the ascent stage!
|
||||
} ELSE {
|
||||
NOTIFY("System booted but did not pass pre-flight checks, aborting excecution!").
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
// This file is the 'mission' or 'payload' script
|
||||
// When excecuted, it should do the 'mission' whatever
|
||||
// that means in the context of the craft.
|
||||
// Specificly for this craft, it means activate the radar, solar
|
||||
// and steer to face the planet.
|
|
@ -1,42 +0,0 @@
|
|||
CLEARSCREEN. // Clear the screen
|
||||
|
||||
NOTIFY("Ascent software ready.").
|
||||
|
||||
// Lock throttle to 1, (throttle up)
|
||||
LOCK THROTTLE TO 1.0. // 1.0 is the max, 0.0 is idle.
|
||||
|
||||
// Countdown from 10!
|
||||
NOTIFY("Counting down:").
|
||||
FROM {local countdown is 10.} UNTIL countdown = 0 STEP {SET countdown to countdown - 1.} DO {
|
||||
NOTIFY(countdown, 1). // Notify the countdown number and keep the number for 1 second.
|
||||
WAIT 1. // pauses the script here for 1 second.
|
||||
}
|
||||
|
||||
// First goal should be to get into space,
|
||||
// I found this rule of thumb expression "
|
||||
// (altitude*23.3/body:atm:height)^0.7*15.
|
||||
// on reddit. It looks good enough!
|
||||
|
||||
CLEARSCREEN. // Clear the screen.
|
||||
|
||||
SET MYSTEER TO HEADING(90,90). // Default to up
|
||||
LOCK STEERING TO MYSTEER. // Set steering to the value of MYSTEER, when it updates so will our steering.
|
||||
|
||||
UNTIL false { // Run forever
|
||||
|
||||
SET MYSTEER TO HEADING(90,(altitude*23.3/body:atm:height)^0.7*15).
|
||||
|
||||
// One of these conditions must be met to call a break in this ascent!
|
||||
IF SHIP:APOAPSIS > 100000 // This is good! We made it to space!
|
||||
OR SHIP:VERTICALSPEED > 0 // This is bad, we've started to fall down.
|
||||
{
|
||||
BREAK.
|
||||
}
|
||||
|
||||
WAIT 0.5. // Run this loop every half second.
|
||||
}
|
||||
|
||||
NOTIFY("We broke out of the ascent loop! If thats a good thing you'ld know.").
|
||||
|
||||
LOCK THROTTLE TO 0. // Throttle back
|
||||
SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0. // Protects the throttle from "jumping" when we hand control back to the pilot
|
|
@ -0,0 +1,45 @@
|
|||
CLEARSCREEN. // Clear the screen
|
||||
|
||||
NOTIFY("Ascent software ready.").
|
||||
|
||||
FUNCTION getAscentAngle {
|
||||
PARAMETER targetHeight.
|
||||
|
||||
RETURN 90 - ((altitude / targetHeight) * 90).
|
||||
}
|
||||
|
||||
// Lock throttle to 1, (throttle up)
|
||||
LOCK THROTTLE TO 1.0. // 1.0 is the max, 0.0 is idle.
|
||||
|
||||
// First goal should be to get into space,
|
||||
// I found this rule of thumb expression "
|
||||
// (altitude*23.3/body:atm:height)^0.7*15.
|
||||
// on reddit. It looks good enough!
|
||||
|
||||
CLEARSCREEN. // Clear the screen.
|
||||
|
||||
//SET MYSTEER TO HEADING(90,90). // Default to up
|
||||
//LOCK STEERING TO MYSTEER. // Set steering to the value of MYSTEER, when it updates so will our steering.
|
||||
|
||||
// One of these conditions must be met to call a break in this ascent!
|
||||
IF SHIP:APOAPSIS > 100000 // This is good! We made it to space!
|
||||
OR SHIP:VERTICALSPEED > 20 // This is bad, we've started to fall down.
|
||||
{
|
||||
PRINT NOTIFY("We broke out of the ascent loop! If thats a good thing you'ld know.").
|
||||
} ELSE {
|
||||
LOCK STEERING TO HEADING(90,(getAscentAngle(100000))).
|
||||
STAGE.
|
||||
}
|
||||
|
||||
|
||||
PRINT "Waiting for ship to reach 100000".
|
||||
UNTIL SHIP:APOAPSIS >= 100000 {
|
||||
WAIT 0.5.
|
||||
}
|
||||
|
||||
WAIT 0.5. // Run this loop every half second.
|
||||
|
||||
|
||||
|
||||
LOCK THROTTLE TO 0. // Throttle back
|
||||
SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0. // Protects the throttle from "jumping" when we hand control back to the pilot
|
|
@ -1,18 +0,0 @@
|
|||
// Written based off CheersKevin's youtube series
|
||||
// On programming in KOS
|
||||
|
||||
FUNCTION NOTIFY {
|
||||
PARAMETER message.
|
||||
HUDTEXT("kOS: " + message, 5, 2, 50, WHITE, false).
|
||||
}
|
||||
|
||||
NOTIFY("Program booted!").
|
||||
|
||||
IF ALT:RADAR < 100 { // If our radar alt is lower than 10
|
||||
WAIT 10.
|
||||
COPY proto.proto1.ks FROM 0. // Copy in a prototyping script
|
||||
RUN proto.proto1.ks. // Run the script we coppied over
|
||||
} else {
|
||||
NOTIFY("System booted but did not pass pre-flight checks, aborting excecution!").
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
// Idea from JonnyOThan#0171
|
||||
// On the kOS discord.
|
||||
|
||||
WAIT UNTIL ship:unpacked.
|
||||
CLEARSCREEN.
|
||||
|
||||
// This line from CheersKevin on youtube
|
||||
core:part:getmodule("kOSProcessor"):doevent("Open Terminal"). // Open the terminal on boot!
|
||||
|
||||
PRINT "Using TagBoot ver 1.0".
|
||||
WAIT 0.1.
|
||||
PRINT "Booting with tag " + core:part:tag + "...".
|
||||
WAIT 0.5.
|
||||
|
||||
// reddit says the path cant be fully qualified (no 0:/)
|
||||
COPYPATH("0:/" + core:part:tag + "/boot.ks", "1:/boot/boot.ks").
|
||||
set core:bootfilename to "/boot/boot.ks".
|
||||
reboot. // Reboot the FC
|
|
@ -0,0 +1,6 @@
|
|||
// A general abort script that prepares kOS to give up control of the rocket, and excecute the abort script.
|
||||
|
||||
PRINT "Program tried to abort but we dident write code to do that!".
|
||||
|
||||
LOCK THROTTLE TO 0. // Throttle back
|
||||
SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0. // Protects the throttle from "jumping" when we hand control back to the pilot
|
Loading…
Reference in New Issue