Sign in to follow this  
pa1983

Universal Rocket Laucnh System "aka" URLS

Recommended Posts

I have not been playing KSP a lot the last few years after I quit building space planes.

Was a bit hard to find something fun to do motivating me to play but eventually I decided to use KOS and do some scripting. I cant code or script realy so that was interesting :P

After doing some scripts that could take a specific rocket up in orbit or a spaceplane up and land I decided I needed something "Universal".

Even with a handful of scripts and rockets when I played career with limited parts one have to invent rockets as the parts are unlocked so realy my new shiny rockets and there scripts where useless until the "end game".

 

So I needed something that worked with most rockets.

That is when I started to work on my "Universal Rocket Launch System" or URLS as I like to call it.

Its written for KSP 1.2.2 and KOS, I suppose never versions "should work"?

You can download the script here.

https://dl.dropboxusercontent.com/u/27196441/urls.zip

The goal with the scrip is to put ANY payload in a 100-103km Low Kerbal Orbit.

 

urls2.png

Now Im no programmer or scripted, And Im definitely not good at maths so my "formulas" might be a bit strange but they get the job done at least tough there not always as precise as I would like them to be.

 

The script consist of a number of guidance modes.

But basically the rockets pitch is calculated and set based on its altitude using a formula I created.

The rockets velocity is calculated based of altitude to using a formula I derived and the engines are throttled accordingly to maintain proper acceleration trough the gravity turn.

 

I actually derived my gravity turn formula used for the pitch with a rocket I called the Delta I. It could naturally do a gravity turn so I recorded that data, created a simple script that mimicked that and also tuned the thrust of the stages accordingly.

Once I had this simple script I had enough data to create the gravity turn formula I mentioned earlier and the formula for the target velocity and all other formulas I needed.

 

Now the problem is that not every rocket behaves like the one I used as a benchmark, the Delta I.

The most common problem I noticed was either a to powerful first stage and a weak second stage and this created a problem.

If the second stage is to weak aka low TWR it will not gain altitude fast enough, basically it will fall short of the intended profile of the gravity turn.

Since the velocity is calculated based on altitude a second or 3:e stage could actually find it self costing at a pitch up attitude and just run out of fuel since the script did not demand full thrust because the orbital speed at that altitude was meet.

As fare as the script was concerned the orbital velocity at that altitude was correct and sure it was but since vertical velocity was around zero the stage would just cost until the fuel ran out.

 

So my next guidance mode I had to create is also based of altitude BUT the formula I derived calculates what time the rocket should be at that altitude.

If we assume the rocket turns as programmed by she script and accelerates properly we should always know at what time our rocket should be at a specific altitude.

 

So this secondary guidance mode basically calculates the time the rocket should be at Altitude X and it checks that against the time since launch and if we are ahead or behind to much this guidance mode takes control over the throttle.

This mode wont allow the velocity of the rocket to go below 90% of the velocity that was the target, simple reason is that we dont want the rocket to fall out of the sky but other then that it can override the velocity as much as desired to "catch up".

This secondary guidance mode will allow even a second or 3:e stage to coast in to orbit.

 

Usually when the second or 3:e stage struggles to get in to orbit its usually enough just to move fuel from that stage to the previous stage, that gives more D/V on previous stage and a lighter second or 3:e stage giving them better TWR.

 

The last guidance mode is basically there to put the rocket in LKO and this mode is activated either when the AP is deemed high enough or the rocket is high enough in orbit.

 

To be able to understand what the script is doing I created a User Interface. It will show useful data the script uses and what guidance modes are in use and what part of the script has completed.

This is very useful when designing a rocket to fly with the script. One can pretty easily determine if a stage has the proper TWR or not for example or adjust thrust limits on solid rocket boosters for example since the script has no control over those.

 

I will now explain what the screen shows from top to bottom

 

urls1.png

 

Apoapsis altitude - this is just apopasis altitude in meters so pretty strait forward

Periapsis altitude - this is your periapsis altitude in meters.

Vertical speed - this is your rockets vertical speed in m/s so useful to tune thruster limits and engine configurations.

Vertical speed target  - this is the vertical speed in m/s your rock should travel at the first 1000m after launch.

 

Orbital Velocity - this is the orbital velocity in m/s of your rocket and its used for simplicity from launch to LKO.

Velocity deviation - this shows the difference between the calculated velocity and the actual velocity in m/s the rocket is travelling at. Positive number and the rocket is going to fast and a negative number and the rocket is going to slow.

 

Time in flight - this is the time the rocket has been flying since launch shown in seconds only.

Deviation from ideal trajectory - this will show you how much behind or ahead in time in seconds the rocket is on its trajectory, ideally you want no deviation but some will eventually occur as the rockets vertical speed declines the accuracy is reduced.

 

Target pitch - this shows the pitch the rocket is suppose to have not what it is, apparently it was very "hard" to script something that would show the rockets actual pitch so you should check this pitch value against the navball to make sure your rocket actually has the authority to pitch over as demanded.

 

Then we have guidance modes.

Only one guidance mode can have full authority at a time and what mode has authority will be shown with the word "Active" next to it.

 

Vertical Velocity - This guidance mode is used the first 1000m of the accent, the rocket tries to go strait up and accelerate at a predetermined rate.

Orbital Velocity - This is the primary guidance mode for the gravity turn and the one you want to spend most of the time in. It controls the velocity of the rocket according to altitude and should work for any rocket with good enough TWR.

Time deviation - this is the secondary or fallback guidance mode. Its primary job is to take control from "Orbital Velocity" guidance mode if the rocket for example has an excessive TWR, like solid rocket boosters that was not properly configured with a thrust limit.

Its more commonly activated when a second or 3:e stage has a to low TWR and it will make sure full throttle is used to try and coast the rocket in to orbit.

I have also had instances where boosters smashed one of my main engines of and then this mode could save the rocket to.

You dont realy want to be in this mode because then your rocket is not balanced to work well with the script but since this guidance mode is based on altitude it will be less accurate at say 50km or higher since the vertical speed decreases and the rockets starts to level of so even the best rockets might spend 10-20 sec in this mode before going in to the last guidance mode.

This mode is also triggered if the rocket is 5 seconds behind or ahead of its intended point in time.

 

Orbital Manoeuvrers - this is the last guidance mode and its basically there to get your in to LKO. It is activated either when the rocket has high enough altitude or when the AP is high enough. We dont want the AP to go higher then the intended LKO do we.

 

The last part in our User Interface  is Mission parameters. The word complete will be shown next to a mission parameter when it has been executed.

 

Gravity turn - gravity turn is completed.

LKO - rocket is in a stable Low Kerbal Orbit.

Payload delivery - payload has be deployed.

Deorbit burn - the orbital stage has done a retro burn and will now reenter Kerbin at 30km altitude and burn up.

 

Now there area few other things that needs to be mentioned about the script.

If an attribute in the User Interface reads "null" the that only means the data is no longer correct or available and therefore no data is shown to confuse the user.

The script will check for engine flameouts and will stage as long as there are flamed out engines.

The script will also check for active engines and stage until active engines are detected.

Every time the rocket stage it will default to full thrust on the engines just to make sure it wont fall behind on its intended trajectory since the TWR will usually be lower with a new stage then an empty one.

The scrip uses action group 10 to jettison faring or anything else you want to get rid of, this will happen at 54000m. If you want to jettison your faring earlier you can have that in your staging sequence as usual.

The reason I opted for 54000m to jettison fairings is the the fact that I got destructive wobble with 3.75m parts up to about 50000m. Since the script is universal I need a safe altitude to deploy the fairings.

The script will stage one last time in orbit to jettison then payload, but action group 9 is also triggered and can be used to separate a payload from the last stage and also extend antennas if you need an uplink to control the payload.

Also the scripts formula to estimate velocity is a bit off in the early part of the gravity turn compared to the rocket it was designed for (Delta I) so its pretty common for it to report that the rocket is a bit behind in velocity but still show that the rocket is on time aka no Time Deviation.

Try out the Delta II rocket supplied with the script for a good benchmark rocket to use as a reference.

For the first stage I usually use a TWR of 1.5 based of the Vacuum numbers, if I use the atmospheric numbers I tend to go with 1.3.

 

The scrip is primarily intended to make launches easy and routine and not to make them the most efficient to save that little bit of fuel. You should tune your rocket so it spends most time in the "orbital velocity" guidance mode for best performance but the script is intended to fly pretty much anything that can be flown manually tough its not designed for space shuttles.

I have tested pretty much all my rockets, good and bad once and also most stock rockets in KSP and they do work (staging order might need tuning tough).

 

You can download the script here.

https://dl.dropboxusercontent.com/u/27196441/urls.zip

It will include the Delta II rocket (improved version of the Delta I but performance the same) and also a Soyuz ST (picture below) that I designed using the script.

I would recommend flying them first to get an idea of how the script works and how you can use it to tune your rockets.

 

So now its up to you to break my script and tell me what it cant do :D So feel free to post any good or bad launches in this thread.

urls3.png

 

 

 

Edited by pa1983

Share this post


Link to post
Share on other sites
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this