Compare commits

..

No commits in common. "2b268e5e52e6d0ed09dd0998676f05e6c24a2268" and "b636d4baa28f7f811a31d4b294af95b68196fdae" have entirely different histories.

8 changed files with 69 additions and 81 deletions

View File

@ -1,5 +0,0 @@
// 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.

View File

@ -0,0 +1,42 @@
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

View File

@ -1,45 +0,0 @@
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

View File

@ -15,21 +15,23 @@ FUNCTION NOTIFY {
PRINT message. PRINT message.
} }
// This section from latest docs.
WAIT UNTIL ship:unpacked.
CLEARSCREEN.
NOTIFY("Boot sequence complete, prepare to load and compile the flight scripts."). NOTIFY("Boot sequence complete, prepare to load and compile the flight scripts.").
IF true { // Set this to false to avoid compiling ascent code. 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 { } 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."). 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. WAIT 5.
RUN ascent. // Run the ascent stage! RUN ascent.ks. // Run the ascent stage!
} ELSE { } else {
NOTIFY("System booted but did not pass pre-flight checks, aborting excecution!"). NOTIFY("System booted but did not pass pre-flight checks, aborting excecution!").
} }

18
boot/TutorialBoot.ks Normal file
View File

@ -0,0 +1,18 @@
// 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!").
}

View File

@ -1,18 +0,0 @@
// 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

View File

@ -1,6 +0,0 @@
// 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