Hello wonderful person is Anton and welcome to Kerbal space program or should I say welcome back to Kerbal space program this was actually one of the original games I used on the channel one of the games I played the most and this was the game that started this as an educational channel more so than anything else into this.
Video I wanted to talk about care PC a to that I actually would.
Highly recommend you use and the two that I’m.
Thinking of using the summer to teach you a little bit of programming anyway welcome to the math so a few years ago I made a video about Kos Kos if you don’t actually know what that is let me actually show you the website for it is Kerbal operating system it’s basically kind of a language of someone.
Developed that allowed you to use Kerbal space program to make these scripts and.
Automate pretty much everything you could do takeoffs you could do landings you could put yourself in orbit you can even land on the.
Moon but it was a language I was only using the Kerbal.
Space program and that created a few challenges like for example if you discover the bug it was hard to kind of fix it on the other hand I always wanted to try to find a way to basically integrate my knowledge of programming into KSP and just so what happens there is a tool that I only discovered maybe a few months ago.
It’s a tool known as K RPC which stands for Kerbal remotes program Kol I guess something like that what this allows you to do is use the languages you might already know or help you learn the.
Language that you want to learn I’m talking about programming languages and then transfer to KSP and basically automate everything so you can use c-sharp you can use C++ Java fluid Python Ruby and Haskell but we’re going to be using Python and today I actually want to show you how to install all this and how to use all this.
And introduce the idea of using scripts and using programming to basically play KSP completely remotely so we’re going to go into the game and start our first programming experience in KSP now here’s the thing I already have an installed I’m gonna show you how easy.
It is to install it and basically all you have to do is well first of all download care PC and.
Install it on your computer one of the easiest ways is to use what’s known the sea-can which is the mod installation utility this is under github.
KSP that’s again it Caspi – the cameras and get this file if you’re on Windows and order so I feel on Mac and just run it and it will allow you to install care PC you also need to install python and i usually highly recommend using this and I couldn’t navigator this is a sort of a package that includes everything we’re going to be using Jupiter notebook and here if you go into environments.
Click on this open terminal and in the terminal type pip install key RPC it will install the library that you need to play this in Kerbal space program that’s really all there is to it I already have it so it’ll basically say you don’t have to install anything then close this and you can actually jump into your Kerbal space program and you’re going to.
See this little box here it’s gonna say start server we’re gonna click on this and right away it actually starts writing the server on your computer on the port 5,000 now here’s the cool.
Part about this is that you can actually use this remotely from what I understand you can actually connect from outside of your computer basically from your smartphone while you’re on the bus or something and then launch these scripts of let’s say a mission.
It’s already in progress so let’s say you’re you have some sort of a transformation from Jewell to do not and you kind of are.
Waiting for this window or opportunity meanwhile writing a script on the bus and then you can actually just have this launch the script remotely while you’re away from your computer absolutely brilliant we’re gonna.
Use this really simple vehicle ability to try to launch this so I’m.
Gonna show you how the script works and actually so yeah this is the vehicle just one stage here or actually two stages sorry these boosters will separate this will continue up and then there is actually another way we couldn’t separate here later.
The key RPC documentation there’s a toriel here it actually explains everything really well i’m gonna show you some of the comments here and the way it works is usually very very simple so you import the library first you then connect to your server and then you activate your vessel so these three lines you always have here i.
Can actually use vessel that flight command so this command right here to connect it to a variable code flight info and.
Then I can call this variable right here with a command called mean altitude and this will actually bring up the altitude you see in a second and I can also use another command it’s actually.
Pretty long that will display our location on kerbin so here I’m gonna run it and in the second or so will return my altitude and my position so 75 meters or 76 meters and this is our I think this is X Y Z I believe.
I don’t actually remember but.
This will allow you to basically pinpoint specific location on kerbin or really any other planet you can choose the body and change the body as you.
Wish this is a really good tutorial right here that shows you how to do it we’re going to go into this a little bit more detail later on but for now let’s actually just do the following let’s let’s take this so we’re gonna basically do this and just do one more one thing one simple thing we’re going to.
Automate our launch and we’re going to go straight up and then we’re gonna separate our boosters and keep going up and separate the last part and then release the.
Parachutes that’s really all I want to do now all this is actually from the tutorial you can find on the APC website but I’m.
Just going to explain to you the commands here so the first command vessel dot.
That’s basically how you start the command and remember vessel is the variable at the way sign right here it’s the active vessel will basically engage the autopilot and then target the autopilot toward 90 90.
So this is up and this is East so in other words it’s going to be pointing up but also East so if you.
Want to start doing gravity turn afterwards you just have to start decreasing this number we’re then are going to engage the autopilot with this command the third line here sets our throttle all the way to the max is gonna be from 0 to 1 and then we’re going to just.
Wait a little bit so we have to actually import the time library we’re gonna wait one second before we actually launch.
And so the next step is going to be to print launch right here and then activate the stage so this should actually take off our craft and we’re going to launch this and jump into the game and the bearer goes.
Hands off basically it’s doing it by itself now right now it’s gonna keep flying I would by the way I’ve already connected several times as you can see there’s all the connections in.
This way here right now it’s gonna keep going up but it’s not going to do anything once the fuel has exhausted but you can actually start adding commands to it as you go as a matter of.
Fact you don’t have to write a long script you can basically add to it as you progress so I can now jump back into my script and basically add another thing here that will set the throttle to zero.
And then stage the craft and there we go so that just initiated the next stage we didn’t get to see it but I believe I believe alright well there there there there are the boosters so there actually flew away because they still.
Had some fuel left and if you want to basically activate the other stage let’s set this back.
To one and that’s actually let’s.
Turn a little bit we’re gonna put this right here oh here comes the space music we’re gonna turn zero degrees and maybe wait a little bit time sleep two seconds and time sweet two seconds as well and then activate the last stage so here we go just.
So just so we could actually see it so it starts turning activates the engine and starts moving sideways beautiful so now we’re basically initiate a very very awkward very strange gravity turn.
So you can see the orbit is a great increase in here and we’re getting quite a lot of speed but we don’t want to go too fast so.
We might actually have to stop our engines manually soon but this is essentially how you can totally automate everything and you can.
There’s a lot of commands you can use in here as a matter of fact all of them are listed under a care PC documentation under Python there’s a lot of stuff you can learn from this by doing it this way you can actually start learning Python by playing through the game and it’s actually absolutely awesome I’m gonna hopefully create a little stream that I actually been meaning to start for.
A while where I want to teach you a little bit of about Python by using Kerbal space program and will actually make her own commands as well all right looks like I’m out of fuel now I’m moving at a speed of 2,800 meters per second and yep we are in orbit very eccentric orbit but orbit unto us pretty cool so this was completely automated well more or less automated using the scripts let’s revert oh I can revert.
No I wanted to revert it I guess it’s because I had this spacecraft staying here for a while I guess I’m gonna have to place another craft here and this is what Valentina crimin this time and what I want to.