How To Install Kerbal Space Program
Quick Start Tutorial¶
This is a quick start guide for the Kerbal Operating Organization (kOS). It is intended for those who are just starting with using kOS. Information technology does assume you take played Kerbal Infinite Program before and know the nuts of how to wing a rocket nether transmission control. It does Non presume you know a lot about computer programming, and it will walk you lot through some basic start steps.
Contents
- First example: Hullo Earth
- Step 1: Start a new sandbox-mode game
- Pace 2: Make a vessel in the Vehicle Associates Bay
- Step three: Put the vessel on the launchpad
- Step four: Invoke the final
- Step 5: See what an interactive control is like
- Stride 6: Okay that's great, but how can you make that happen in a plan script instead?
- Step seven: Okay, just where is this program?
- Pace viii: I don't like the thought that the program is stored only on this vessel. Can't I relieve information technology somewhere amend? More permanent?
- 2nd Instance: Doing something real
- Step 1: Make a vessel
- Step two: Make the start of the script
- Footstep 3: Brand the script actually do something
- Footstep iv: Make the script actually control steering
- Step 5: Add staging logic
- Step half dozen: Now to brand it turn
- Step 7: Putting it all together
Showtime example: Hullo World¶
In the k tradition of programming tutorials, the first instance will be how to brand a script that does goose egg more than impress the words "Hello World" on the screen. The purpose of this example is to show where yous should put the files, how to move them about, and how to become ane to run on the vessel.
Step 1: Showtime a new sandbox-mode game¶
(You can employ kOS in a career mode game, but it requires a part that you have to enquiry which isn't bachelor at the start of the tech tree, and then this example will just employ sandbox fashion to proceed it unproblematic.)
Stride two: Brand a vessel in the Vehicle Assembly Bay¶
Brand the vessel incorporate whatsoever unmanned control core, a few hundred units of battery power, a means of recharging the battery such as a solar panel array, and the "Comptronix CX-4181 Scriptable Command System". (From this point onward the CX-4181 Scriptable Control Organization part will be referred to past the acronym "SCS".) The SCS role is located in the parts bin under the "Control" tab (the same place where RCS thrusters and Torque Wheels are found.)
Stride 3: Put the vessel on the launchpad¶
Put the vessel on the launchpad. For this beginning example it doesn't affair if the vessel can really liftoff or even has engines at all.
Footstep 4: Invoke the terminal¶
Correct click for the SCS role on the vessel and and so click the button that says "Open Last".
Note that if the last is semi-transparent, this means it'southward not currently selected. If you click on the terminal, and then your keyboard input is directed to the last INSTEAD of to piloting. In other words if you blazon W A S D , you'll actually become the word "wasd" to appear on the last, rather than the W A S D keys steering the send. To switch back to transmission control of the game instead of typing into the final, click outside the terminal window anywhere on the background of the screen.
Step five: See what an interactive control is like¶
Yous should now run into an one-time-school looking text terminal like the i shown beneath. Blazon the line:
CLEARSCREEN . PRINT "==HELLO WORLD==" . into the terminal (make sure to actually type the periods (".") as shown) and hit ENTER . Note that you tin can blazon it in uppercase or lowercase. kOS doesn't intendance.
The terminal will respond by showing you this:
Footstep six: Okay that'southward nifty, but how can you lot make that happen in a program script instead?¶
Like so: Enter this control:
(Don't forget the flow ("."). All commands in kOS are ended with a flow. Again, yous can type information technology in uppercase or lowercase. kOS doesn't intendance.)
You lot should see an editor window announced, looking something like this (without the text within because yous're starting a blank new file):
Type this text into the window:
Print "=========================================" . PRINT " Howdy Earth" . Impress "THIS IS THE Starting time SCRIPT I WROTE IN kOS." . PRINT "=========================================" . Click "Save" then "Exit" in the editor pop-up window.
- Side Note: The editor font - Experienced programmers may take noticed that the editor's font is proportional width rather than monospaced and that this is not ideal for programming piece of work. You are correct, but there is picayune that can be done nearly information technology for a variety of technical reasons that are too circuitous to become into correct now.
And then on the main text final Enter:
And you will encounter the program run, showing the text on the screen like and then.
Annotation
You can also type RUNPATH("hi") instead of RUN HELLO . The commands are slightly unlike but should take the aforementioned issue. You can learn about the specific difference between them later here.
Step seven: Okay, merely where is this program?¶
To encounter where the "Hullo" program has been saved, Issue the command LIST FILES like this:
(Note, that the default for the Listing command is to list FILES , and so you can go out the discussion "FILES" off if you like.)
It should wait similar this, showing you the HELLO programme you lot only wrote:
This is a list of all the files on the currently selected Volume. Past default, when y'all launch a new vessel, the currently selected VOLUME is called "1" and it'due south the book that's stored on THAT SCS office that you are running all these commands in.
This is the local volume of that SCS part. Local volumes such at this tend to accept very small express storage, equally you can come across when y'all wait at the space remaining in the list printout.
If you're wondering where the file is stored physically on your computer, it'south represented by a section inside the persistence file for your saved game, equally a slice of data associated with the SCS office. This is of import because it ways you tin't access the program from some other vessel, and if this vessel ever crashes and the SCS function explodes, then yous've lost the programme.
Step 8: I don't like the idea that the program is stored but on this vessel. Tin't I salvage information technology somewhere better? More permanent?¶
Yes. Yes you tin can.
In that location is another VOLUME that always exists called the Annal, which is besides referred to equally volume 0. (either name can be used in commands). The archive is conceptually stored somewhere dorsum at Kerbin abode base in the Space Center rather than on your vessel. It has infinite storage space, and does not disappear when your vessel is gone. ALSO, it really exists beyond saved games - if you launch one saved game, put a new file in the Annal, and then afterward launch a different saved game, that file will be there in that game also.
To use the Archive, first we'll have to innovate you to a new command, called SWITCH TO . The SWITCH TO command changes which Volume is the one that you are doing your work with.
To work with the archive, and create a 2d "hello globe" file there, y'all outcome these commands and meet what they do:
SWITCH TO 0 . EDIT HELLO2 . // Brand a new file hither that just says: Print "hi again". List FILES . RUN HELLO2 . SWITCH TO ane . LIST FILES . RUN How-do-you-do . But where is it stored backside the scenes? The annal is currently slightly violating the design of KSP mods that puts everything in the GameData folder. The kSP Archive is actually stored in the Ships/Script folder of your Primary KSP dwelling, non inside GameData.
If a file is stored inside the archive, information technology tin can actually be edited by an external text editor of your selection instead of using kOS's in-game editor. This is usually a much better practice once you lot beginning doing more than complex things with kOS. You tin also make new files in the archive folder. Just make sure that all the files end with a .ks file proper noun suffix or kOS won't use them.
Farther reading about files and volumes:
- Volumes
- File Control
- VolumeFile structure
Step 9: But tin I brand it kick automatically when I launch the vessel?¶
Yes. Information technology is possible to create a boot file and have kOS automatically re-create it to the vessel, and then run it, when the vessel is first put on the launchpad. Y'all don't take to do so right at present to follow this tutorial, only be aware that this feature exists and it's one y'all will probably want to make use of eventually. It's described in more than particular hither.
Second Case: Doing something real¶
Okay that's all basic setup stuff just you're probably clamoring for a existent example that actually does something cracking.
This example will show the crudest, well-nigh basic use of kOS but to get started. In this case we'll brand a program that will launch a vessel using progressively more and more circuitous checks. kOS tin can be used at any phase of a vessel's flight - launching, circularizing, docking, landing,... and in fact launching is one of the simpler piloting tasks that you can do without much demand of automation. Where kOS actually shines is for writing scripts to exercise touchy sensitive tasks like landing or docking or hovering. These are the areas that tin can benefit from the faster reaction speed that a computer script tin can handle.
Only in order to give you an example that you can starting time with from scratch, that's easy to reload and retry from an initial bespeak, we'll use an instance of launching.
Footstep 1: Make a vessel¶
This tutorial is designed to work with a very specific rocket design. You need to make the vessel you lot see here:
If you prefer, you lot can instead download the .arts and crafts file here
Stride two: Make the start of the script¶
Okay, so type the lines below in an external text editor of your choice (i.due east. Notepad on Windows, or TextEdit on Mac, or whatever you fancy):
//hellolaunch //Start, we'll articulate the terminal screen to make it look nice CLEARSCREEN . //This is our countdown loop, which cycles from ten to 0 Print "Counting downwards:" . FROM { local countdown is 10 .} UNTIL countdown = 0 STEP { Fix countdown to countdown - 1 .} Practise { PRINT "..." + countdown . WAIT 1 . // pauses the script here for i second. } Come across those things with the 2 slashes ("//")? Those are comments in the Kerboscript language and they're simply means to write things in the program that don't exercise anything - they're there for humans similar you to read then you understand what's going on. In these examples y'all never actually have to blazon in the things you see later the slashes. They're there for your do good when reading this document but you lot tin leave them out if you wish.
Save the file in your Ships/Script folder of your KSP installation nether the filename "hellolaunch.ks". Practise NOT salve information technology anywhere under GameData/kOS/ . Practice NOT. According to the KSP standard, normally KSP mods should put their files in GameData/[modernistic proper name] , but kOS puts the archive outside the GameData folder considering it represents content owned past you, the player, not content owned by the kOS modern.
By saving the file in Ships/Script , you take actually put it in your annal volume of kOS. kOS will see information technology there immediately without delay. You practise not need to restart the game. If you practice:
after saving the file from your external text editor programme, you lot volition see a listing of your file "hellolaunch" right abroad. Okay, now copy it to your local bulldoze and requite it a effort running information technology from there:
SWITCH TO ane . COPYPATH ( "0:/HELLOLAUNCH" , "" ). // copies from 0 (archive) to current default location (local drive (ane)). RUN HELLOLAUNCH .
Okay so the program doesn't actually Do anything yet other than just countdown from 10 to 0. A bit of a thwarting, but we haven't written the remainder of the program nevertheless.
You'll note that what you've done is switch to the local volume (ane) and and then re-create the program from the annal (0) to the local volume (i) and then run it from the local book. Technically yous didn't need to do this. Y'all could have only run information technology direct from the archive. For those looking at the KSP game as a flake of a function-play experience, it makes sense to never run programs direct from the archive, and instead alive with the limitation that software should be copied to the arts and crafts for information technology to be able to run it.
Stride 3: Make the script actually do something¶
Okay now go dorsum into your text editor of choice and suspend a few more than lines to the hellolaunch.ks file so it now looks like this:
//hellolaunch //Offset, nosotros'll clear the final screen to make it look prissy CLEARSCREEN . //Next, nosotros'll lock our throttle to 100%. LOCK THROTTLE TO i . 0 . // ane.0 is the max, 0.0 is idle. //This is our inaugural loop, which cycles from ten to 0 PRINT "Counting downwards:" . FROM { local countdown is 10 .} UNTIL countdown = 0 STEP { SET countdown to countdown - one .} DO { PRINT "..." + countdown . Wait 1 . // pauses the script here for 1 2d. } UNTIL SHIP : MAXTHRUST > 0 { WAIT 0 . five . // suspension half a 2nd between phase attempts. PRINT "Stage activated." . Phase . // same as hitting the spacebar. } Await UNTIL SHIP : ALTITUDE > 70000 . // Annotation that it is vital to non merely allow the script stop correct abroad // hither. Once a kOS script simply ends, it releases all the controls // dorsum to transmission piloting so that yous can fly the ship by hand again. // If the program just ended here, so that would crusade the throttle // to plough dorsum off over again right away and nothing would happen. Save this file to hellolaunch.ks again, and re-copy it to your vessel that should still be sitting on the launchpad, then run it, like so:
COPYPATH ( "0:/HELLOLAUNCH" , "" ). RUN HELLOLAUNCH . // You could also say RUNPATH("hellolaunch") here.
Hey! It does something at present! It fires the first stage engine and launches!
But.. but wait... It doesn't control the steering and it simply lets information technology go where e'er it will.
Most likely y'all had a crash with this script because it didn't practice anything to affect the steering at all, so it probably allowed the rocket to tilt over.
Step 4: Make the script actually control steering¶
Then to fix that trouble, let'south add steering control to the script.
The like shooting fish in a barrel manner to control steering is to employ the LOCK STEERING control.
In one case you have mastered the basics of kOS, you should go and read the documentation on ship steering techniques, but that'southward a more advanced topic for later.
The mode to use the LOCK STEERING command is to fix it to a thing called a Vector or a Direction . In that location are several Directions born to kOS, one of which is called "Up". "UP" is a Direction that always aims directly toward the sky (the center of the blue office of the navball).
So to steer always Upwards, just do this:
Then if you just add this i line to your script, you'll get something that should keep the craft aimed directly upward and not permit it tip over. Add the line just later the line that sets the THROTTLE, like so:
//hellolaunch //First, we'll clear the terminal screen to make it expect squeamish CLEARSCREEN . //Side by side, nosotros'll lock our throttle to 100%. LOCK THROTTLE TO one . 0 . // ane.0 is the max, 0.0 is idle. //This is our inaugural loop, which cycles from 10 to 0 PRINT "Counting down:" . FROM { local inaugural is x .} UNTIL countdown = 0 Footstep { SET countdown to countdown - 1 .} Do { PRINT "..." + countdown . WAIT i . // pauses the script here for 1 2d. } //This is the line we added LOCK STEERING TO UP . UNTIL Send : MAXTHRUST > 0 { Wait 0 . 5 . // pause half a second between stage attempts. PRINT "Stage activated." . STAGE . // same as striking the spacebar. } Wait UNTIL SHIP : Distance > 70000 . // NOTE that information technology is vital to not just let the script end right away // here. One time a kOS script just ends, it releases all the controls // back to manual piloting so that yous can fly the ship by mitt once more. // If the program just concluded here, then that would crusade the throttle // to plow back off again correct away and nothing would happen. Again, copy this and run information technology, like before. If your arts and crafts crashed in the previous stride, which it probably did, then revert to the VAB and re-launch it.:
SWITCH TO 1 . // should be the default already, merely merely in instance. COPYPATH ( "0:/HELLOLAUNCH" , "" ). RUN HELLOLAUNCH . // You could also say RUNPATH("hellolaunch") here.
Now you should run across the same thing as before, but now your craft will stay pointed upward.
Only wait - it only does the first stage and then information technology stops without doing the adjacent phase? how do I fix that?
Footstep 5: Add together staging logic¶
The logic for how and when to stage can exist an interesting and fun thing to write yourself. This example will proceed it very simple, and this is the part where it's important that you are using a vessel that only contains liquidfuel engines. If your vessel has some booster engines, and so it would require a more than sophisticated script to launch it correctly than this tutorial gives you lot.
To add the logic to check when to phase, we introduce a new concept chosen the WHEN trigger. To see full documentation on it when you cease the tutorial, expect for it on the Flow Control page
The quick and dirty explanation is that a WHEN section is a short department of lawmaking that y'all set up to run Afterward rather than right at present. It creates a check in the background that will constantly expect for some condition to occur, and when it happens, information technology interrupts any else the code is doing, and it will run the body of the WHEN code earlier standing from where information technology left off in the main script.
There are some complex dangers with writing WHEN triggers that tin crusade KSP itself to hang or stutter if y'all are non careful, merely explaining them is beyond the scope of this tutorial. But when you desire to start using WHEN triggers yourself, you really should read the section on WHEN in the Menstruum Control page earlier you lot do and so.
The WHEN trigger we are going to add to the launch script looks similar this:
WHEN MAXTHRUST = 0 THEN { Impress "Staging" . Stage . PRESERVE . }. It says, "Whenever the maximum thrust of our vehicle is aught, then activate the side by side stage." The PRESERVE keyword says, "don't finish checking this condition just because it's been triggered once. It should still go on checking for it again in the future." If this block of code is inserted into the script, so it will ready a constant background bank check that volition always hitting the next stage as soon as the electric current stage has no thrust. Dissimilar with all the previous edits this tutorial has asked you to make to the script, this time you're going to exist asked to delete something and replace it. The new WHEN section above should really Supervene upon the existing "UNTIL Ship:MAXTHRUST > 0" loop that you had before.
Now your script should look similar this:
//hellolaunch //First, nosotros'll articulate the terminal screen to make it look overnice CLEARSCREEN . //Next, we'll lock our throttle to 100%. LOCK THROTTLE TO 1 . 0 . // 1.0 is the max, 0.0 is idle. //This is our countdown loop, which cycles from 10 to 0 Print "Counting down:" . FROM { local inaugural is 10 .} UNTIL countdown = 0 Step { Gear up countdown to countdown - one .} Practise { Print "..." + countdown . WAIT 1 . // pauses the script here for 1 second. } //This is a trigger that constantly checks to meet if our thrust is nil. //If it is, it will attempt to stage and so return to where the script //left off. The PRESERVE keyword keeps the trigger active even after information technology //has been triggered. WHEN MAXTHRUST = 0 THEN { Impress "Staging" . Stage . PRESERVE . }. LOCK STEERING TO Upwardly . Await UNTIL Distance > 70000 . // NOTE that it is vital to not only let the script cease right away // here. One time a kOS script only ends, information technology releases all the controls // back to manual piloting so that you can fly the ship by paw once more. // If the programme but concluded here, then that would crusade the throttle // to turn back off again right away and nothing would happen. Again, relaunch the ship, copy the script equally earlier, and run it again. This time yous should come across it activate your later upper stages correctly.
Step 6: Now to make it turn¶
Okay that's fine just it still just goes straight up! What about a gravity turn?
Well, a true and proper gravity turn is a very circuitous fleck of math that is best left every bit an practise for the reader, given that the goal of kOS is to permit you write your Own autopilot, not to write it for you. But to give some basic examples of commands, lets just make a crude gravity turn approximation that merely flies the ship like a lot of new KSP pilots acquire to exercise it for the get-go fourth dimension:
- Fly directly up until your velocity is 100m/s.
- Pitch 10 degrees towards the East.
- Continue to pitch 10 degrees downwards for each 100m/s of velocity.
To brand this piece of work, we innovate a new manner to brand a Direction, called the HEADING function. Whenever yous phone call the function HEADING(a,b), it makes a Direction oriented as follows on the navball:
- Point at the compass heading A.
- Pitch up a number of degrees from the horizon = to B.
So for example, HEADING(45,ten) would aim northeast, 10 degrees above the horizon. We can use this to easily set our orientation. For example:
//This locks our steering to due eastward, pitched 45 degrees in a higher place the horizon. LOCK STEERING TO HEADING ( xc , 45 ). Instead of using WAIT UNTIL to pause the script and keep it from exiting, we can use an UNTIL loop to constantly perform deportment until a certain status is met. For case:
Ready MYSTEER TO HEADING ( 90 , ninety ). //xc degrees due east and pitched upwards ninety degrees (directly up) LOCK STEERING TO MYSTEER . // from now on we'll exist able to change steering by just assigning a new value to MYSTEER UNTIL APOAPSIS > 100000 { SET MYSTEER TO HEADING ( 90 , xc ). //90 degrees east and pitched upwardly xc degrees (straight upwardly) Print ROUND ( SHIP : APOAPSIS , 0 ) AT ( 0 , 16 ). // prints new number, rounded to the nearest integer. //Nosotros use the Print AT() control here to go along from press the same thing over and //over on a new line every time the loop iterates. Instead, this volition always impress //the apoapsis at the same betoken on the screen. }. This loop volition continue to execute all of its instructions until the apoapsis reaches 100km. Once the apoapsis is past 100km, the loop exits and the residuum of the lawmaking continues.
We can combine this with IF statements in order to have ane main loop that only executes certain chunks of its code under certain atmospheric condition. For example:
Fix MYSTEER TO HEADING ( xc , 90 ). LOCK STEERING TO MYSTEER . UNTIL Send : APOAPSIS > 100000 { //Remember, all altitudes will be in meters, non kilometers //For the initial ascent, nosotros desire our steering to exist directly //upwards and rolled due east IF SHIP : VELOCITY : SURFACE : MAG < 100 { //This sets our steering 90 degrees up and yawed to the compass //heading of 90 degrees (east) SET MYSTEER TO HEADING ( ninety , 90 ). //Once we pass 100m/s, we want to pitch downwardly ten degrees } ELSE IF Transport : VELOCITY : SURFACE : MAG >= 100 AND Ship : VELOCITY : SURFACE : Mag < 200 { Prepare MYSTEER TO HEADING ( 90 , 80 ). PRINT "Pitching to 80 degrees" AT ( 0 , 15 ). Impress ROUND ( Ship : APOAPSIS , 0 ) AT ( 0 , sixteen ). }. }. Each fourth dimension this loop iterates, information technology will cheque the surface velocity. If the velocity is beneath 100m/s, information technology volition continuously execute the start block of instructions. One time the velocity reaches 100m/southward, it will stop executing the first cake and beginning executing the 2nd block, which will pitch the nose down to lxxx degrees in a higher place the horizon.
Putting this into your script, it should look like this:
//hellolaunch //Beginning, we'll clear the terminal screen to brand it expect overnice CLEARSCREEN . //Adjacent, we'll lock our throttle to 100%. LOCK THROTTLE TO 1 . 0 . // one.0 is the max, 0.0 is idle. //This is our countdown loop, which cycles from 10 to 0 PRINT "Counting down:" . FROM { local inaugural is 10 .} UNTIL inaugural = 0 Pace { SET countdown to countdown - ane .} Practise { PRINT "..." + countdown . Expect ane . // pauses the script here for 1 2d. } //This is a trigger that constantly checks to encounter if our thrust is zero. //If it is, it volition endeavor to stage and then render to where the script //left off. The PRESERVE keyword keeps the trigger agile fifty-fifty after it //has been triggered. WHEN MAXTHRUST = 0 THEN { Print "Staging" . STAGE . PRESERVE . }. //This will be our main control loop for the ascension. Information technology will //cycle through continuously until our apoapsis is greater //than 100km. Each cycle, it will check each of the IF //statements inside and perform them if their conditions //are met Prepare MYSTEER TO HEADING ( 90 , 90 ). LOCK STEERING TO MYSTEER . // from at present on we'll be able to change steering past but assigning a new value to MYSTEER UNTIL Transport : APOAPSIS > 100000 { //Remember, all altitudes will be in meters, not kilometers //For the initial ascension, we want our steering to be straight //up and rolled due e IF SHIP : VELOCITY : SURFACE : Mag < 100 { //This sets our steering 90 degrees up and yawed to the compass //heading of ninety degrees (east) SET MYSTEER TO HEADING ( 90 , 90 ). //Once we pass 100m/s, we want to pitch down ten degrees } ELSE IF SHIP : VELOCITY : SURFACE : MAG >= 100 { Gear up MYSTEER TO HEADING ( 90 , eighty ). PRINT "Pitching to lxxx degrees" AT ( 0 , 15 ). PRINT ROUND ( Send : APOAPSIS , 0 ) AT ( 0 , 16 ). }. }. Once more, copy this into your script and run it. You should see your countdown occur, then information technology will launch. Once the ship passes 100m/southward surface velocity, it volition pitch down to 80 degrees and continuously print the apoapsis until the apoapsis reaches 100km, staging if necessary. The script will then end.
Footstep seven: Putting it all together¶
We now take every element of the script necessary to do a proper (albeit unproblematic) gravity turn. We only need to extend information technology all the way through the ascent.
Adding additional IF statements within our main loop will allow us to perform further actions based on our velocity. Each IF statement you see in the script below covers a 100m/due south block of velocity, and volition adjust the pitch 10 degrees further down than the previous block.
You can come across that with the AND statement, we tin cheque multiple weather condition and only execute that block when all of those conditions are true. Nosotros can carefully set up the weather condition for each IF statement to allow a block of code to be executed no matter what our surface velocity is.
Copy this into your script and run information technology. It should take yous most to orbit:
//hellolaunch //Showtime, we'll clear the terminal screen to make it look nice CLEARSCREEN . //Adjacent, we'll lock our throttle to 100%. LOCK THROTTLE TO 1 . 0 . // 1.0 is the max, 0.0 is idle. //This is our countdown loop, which cycles from 10 to 0 PRINT "Counting down:" . FROM { local countdown is 10 .} UNTIL inaugural = 0 Pace { SET countdown to countdown - ane .} DO { Impress "..." + countdown . Await 1 . // pauses the script here for 1 2nd. } //This is a trigger that constantly checks to see if our thrust is zilch. //If information technology is, it volition attempt to stage and so return to where the script //left off. The PRESERVE keyword keeps the trigger active even subsequently it //has been triggered. WHEN MAXTHRUST = 0 So { PRINT "Staging" . STAGE . PRESERVE . }. //This volition exist our chief command loop for the ascension. Information technology will //cycle through continuously until our apoapsis is greater //than 100km. Each wheel, it will cheque each of the IF //statements inside and perform them if their weather //are met Gear up MYSTEER TO HEADING ( ninety , xc ). LOCK STEERING TO MYSTEER . // from now on we'll be able to change steering by but assigning a new value to MYSTEER UNTIL Send : APOAPSIS > 100000 { //Remember, all altitudes will be in meters, not kilometers //For the initial rise, we want our steering to be direct //up and rolled due e IF Ship : VELOCITY : SURFACE : Mag < 100 { //This sets our steering 90 degrees upwardly and yawed to the compass //heading of ninety degrees (east) Ready MYSTEER TO HEADING ( ninety , 90 ). //Once nosotros pass 100m/south, we want to pitch down x degrees } ELSE IF SHIP : VELOCITY : SURFACE : Mag >= 100 AND Ship : VELOCITY : SURFACE : Magazine < 200 { SET MYSTEER TO HEADING ( 90 , 80 ). PRINT "Pitching to 80 degrees" AT ( 0 , xv ). Impress Round ( Ship : APOAPSIS , 0 ) AT ( 0 , sixteen ). //Each successive IF statement checks to see if our velocity //is within a 100m/s block and adjusts our heading downwards another //ten degrees if so } ELSE IF Send : VELOCITY : SURFACE : Mag >= 200 AND SHIP : VELOCITY : SURFACE : Mag < 300 { Gear up MYSTEER TO HEADING ( 90 , seventy ). PRINT "Pitching to seventy degrees" AT ( 0 , 15 ). PRINT ROUND ( SHIP : APOAPSIS , 0 ) AT ( 0 , xvi ). } ELSE IF SHIP : VELOCITY : SURFACE : MAG >= 300 AND SHIP : VELOCITY : SURFACE : MAG < 400 { Set MYSTEER TO HEADING ( 90 , 60 ). PRINT "Pitching to threescore degrees" AT ( 0 , fifteen ). Impress ROUND ( Send : APOAPSIS , 0 ) AT ( 0 , sixteen ). } ELSE IF SHIP : VELOCITY : SURFACE : Mag >= 400 AND Ship : VELOCITY : SURFACE : MAG < 500 { Gear up MYSTEER TO HEADING ( 90 , 50 ). PRINT "Pitching to 50 degrees" AT ( 0 , 15 ). Impress Round ( SHIP : APOAPSIS , 0 ) AT ( 0 , 16 ). } ELSE IF Transport : VELOCITY : SURFACE : Mag >= 500 AND SHIP : VELOCITY : SURFACE : MAG < 600 { Ready MYSTEER TO HEADING ( 90 , twoscore ). PRINT "Pitching to forty degrees" AT ( 0 , 15 ). PRINT ROUND ( SHIP : APOAPSIS , 0 ) AT ( 0 , 16 ). } ELSE IF Send : VELOCITY : SURFACE : Magazine >= 600 AND Transport : VELOCITY : SURFACE : Mag < 700 { SET MYSTEER TO HEADING ( ninety , 30 ). Print "Pitching to thirty degrees" AT ( 0 , fifteen ). PRINT ROUND ( SHIP : APOAPSIS , 0 ) AT ( 0 , 16 ). } ELSE IF SHIP : VELOCITY : SURFACE : MAG >= 700 AND Ship : VELOCITY : SURFACE : MAG < 800 { SET MYSTEER TO HEADING ( ninety , 11 ). Print "Pitching to 20 degrees" AT ( 0 , 15 ). Impress ROUND ( SHIP : APOAPSIS , 0 ) AT ( 0 , xvi ). //Beyond 800m/s, nosotros can keep facing towards 10 degrees above the horizon and await //for the principal loop to recognize that our apoapsis is above 100km } ELSE IF Transport : VELOCITY : SURFACE : MAG >= 800 { SET MYSTEER TO HEADING ( 90 , ten ). Print "Pitching to 10 degrees" AT ( 0 , 15 ). Print ROUND ( Transport : APOAPSIS , 0 ) AT ( 0 , xvi ). }. }. PRINT "100km apoapsis reached, cut throttle" . //At this point, our apoapsis is above 100km and our main loop has ended. Next //nosotros'll make certain our throttle is zero and that we're pointed prograde LOCK THROTTLE TO 0 . //This sets the user's throttle setting to zilch to prevent the throttle //from returning to the position it was at earlier the script was run. Prepare Ship : CONTROL : PILOTMAINTHROTTLE TO 0 . And here is it in action:
And toward the terminate:
This script should, in principle, work to get y'all to the point of leaving the temper. Information technology will probably all the same autumn back downwardly, because this script makes no effort to ensure that the craft is going fast enough to maintain the orbit.
As you can probably run into, it would notwithstanding have a long way to become before it would get a actually Practiced launching autopilot. Think well-nigh the following features y'all could add yourself equally you lot become more familiar with kOS:
- You lot could change the steering logic to make a more smooth gravity turn by constantly adjusting the pitch in the HEADING co-ordinate to some math formula. The example shown here tends to create a "too high" launch that's a bit inefficient. In addition, this method relies on velocity to decide pitch angle, which could result in some very firey launches for other ships with a higher TWR profile.
- This script just stupidly leaves the throttle at max the whole style. You could brand it more sophisticated by adjusting the throttle as necessary to avoid velocities that result in high atmospheric heating.
- This script does not endeavour to circularize. With some simple checks of the time to apoapsis and the orbital velocity, yous can execute a burn down that circularizes your orbit.
- With fifty-fifty more than sophisticated checks, the script could be made to work with fancy staging methods like asparagus.
- Using the PRINT AT command, you can brand fancier status readouts in the terminal window equally the script runs.
Source: https://ksp-kos.github.io/KOS/tutorials/quickstart.html
Posted by: carpentercomay1968.blogspot.com

0 Response to "How To Install Kerbal Space Program"
Post a Comment