
This has the effect of trying to move gforce to 1.0, matching the gravitational force. Where thrott is the throttle percentage from 0 to 1 or no thrust to full thrust. Note: I'm still working out a way to make math and code look nice with blogger, so it's not the easiest to read here. Check out the nicer formatted IPython Notebook on github for a better experience. Where ∥ameasured∥ is our measured current max acceleration using an onboard accelerometer and gmeasured is our onboard gravitational acceleration magnitude using our graviola detector ( graviola, what a word). GforceΔthrottthrott=∥a∥/g⟹gforcemeasured=∥ameasured∥/gmeasured=Kp(gforcegoal−gforcemeasured)=Kp(1.0−gforcemeasured)=thrott+Δthrott As a first step for hovering, we'll have our controller change in velocity by limiting our g_force to 0 via gforcegoal=1.0. What is dthrott? Well, we're going to implement, you guessed it, a PID controller.
#KERBAL SPACE PROGRAM KOS UPDATE#
This says: Until the fuel goes below 0.1 kg (about zero), print out the current g_forces and change in throttle level (to an onboard text file), then update our thrust level based on this dthrott change in throttle, finally wait 0.1 seconds before repeating. For simplicity we use a pre-existing controller for maintaining a vertical orientation ( this end must point up or you will not go to space today).Īn example kOS script that logs data looks like this: Using this data we can then write a script to control the thrust of the rocket, and try to make it reach and stay at a goal altitude. KOS enhances sensors such as an accelerometer, barometer and an avionics hub, to allow the onboard flight computer to track the altitude, airspeed and g-forces of the craft. PID Controlled Hovering KSP rocket - Link to IPython Notebook Here is the nicer formatted IPython Notebook.

There were failures, but we eventually succeeded. Our intrepid little spaceship consists of a single engine, some landing legs and a parachute in case ( when) our controller goes haywire. So we're going to try and write a kOS script for Kerbal Space Program (KSP) to control a single-stage rocket engine and have it hover at a set altitude.

#KERBAL SPACE PROGRAM KOS MOD#
The other thing, what this post is about, is that there are a lot of really interesting mods for it, one of which is kOS, a mod that allows you to program your rockets using a simplified scripting language.

It does a really good job of making learning orbital mechanics a fun experience. Kerbal Space Program is a game that lets you build rockets and launch ( explode) them to space into orbits, land ( crash) on other planets, and lots of other sorts of fun ( disasters).
