giuliodondi / kOS-Shuttle_OPS1

kOS ascent guidance script for the Space Shuttle in KSP Realism Overhaul
9 stars 3 forks source link

Kerbal Space Program Space Shuttle OPS1 Ascent Guidance

Updated June 2024 - please go through the README

My KSP ascent guidance script for the Space Shuttle, intended to be used in KSP Realism Overhaul. Uses Powered Explicit Guidance (also called UPFG) for vacuum guidance, adapted and modified to perform aborts. Allows for assisted manual flight.

References

Installation

Required mods:

Known Incompatibilities

You will find one folder:

Put the contents of the Script folder inside Ship/Script so that kOS can see all the files. There are a few scripts you can run:

Setup

The script needs to know accurately the mass of orbiter + payload + ET + propellants for closed-loop guidance, without the mass of SRB or launch clamps. The script will measure everything automatically provided that the part tree is set up correctly in the VAB.

Take care of the following things while building the Shuttle Stack in the VAB:

Make sure the vessel staging is as follows (from the bottom stage upwards) :

If you don't use SpaceShuttleSystem parts, or if you mismatch SSME versions, the script should detect this and break during vehicle initialisation. This is intended and meant to signal to you that something is wrong.

kOS configuration file

The mission parameters are specified in the main launch script ops1.ks or ops1_3a.ks. The scripts assume that the Shuttle stack has been assembled properly in the VAB, else it might fail to measure things accurately.

It contains variable definitions for:

The main Ascent script

Upon running ops1.ks you will be greeted with a GUI with buttons and a data display to interface with the program:

ascent_gui

The abort buttons and selectors, except for engine failure, are frozen at program start and unfreeze after SRB separation

The ASCENT TRAJ displays

ascent_traj_displays

These two displays show useful data and trajectory printouts:

Meaning of Rated Power Level and the THROT indicator

The Space Shuttle Main Engine had several performance improvements in its operational life, and you have all the variants at your disposal in KSP RO.
The caveat is that "full power" is an ambiguous term in this situation. For this reason we define the Rated Power Level (100% RPL) as 2090 kN, the max thrust of the original variant. This is significant because for the later part of the Shuttle program, when they used the RS-25D variant, the nominal throttle setting was 104% RPL and boosted to the full 109% RPL in case of an abort. This was done to reduce wear and risk of failure on the engines, it's all realistic and simulated by the script.

How to fly manually with CSS

CSS means control-stick-steering, a fly-by-wire mode that allows you to use keyboard or joystick to command changes in pitch, roll or yaw letting kOS worry about keeping stability.
At any time you can switch between the two. A manual ascent from liftoff to orbit in CSS is possible but challenging. Here are some tips and remarks on how to do it:

Nominal mission scenario

Running the ops1.ks or ops1_3a.ks script is the only action required for a nominal launch (aborts are different). Simply running the script will program the launch about 10 seconds after running the script, meaning that the LAN of the target orbit depends on the time of day you choose to launch.
You can launch to rendezvous with a vessel in orbit by selecting it as a target in the map view BEFORE running the script. This will override the launch inclination to match and warp to the right time to launch so the LAN is correct.

These are the main events durign ascent:

Abort scenarios

General remarks

Abort modes are usually required whenever one or more engines fail. You can either shutdown an engine manually or setup an automatic failure using the Engine Failure panel:

engfail_gui

There are two kinds of abort modes:

Intact aborts

Intact aborts mean that there always is a procedure that will take the Shuttle to a landing runway with sufficient energy. The Shuttle has continuous intact abort coverage from liftoff to orbit in case of a single engine failure.
In some regions, even a double engine failure will allow an intact abort. This is valid both for a sudden double-engine failure or a second engine failure during an ongoing abort

intact_modes

The above chart shows the intact abort modes and their boundaries:

Return to Launch Site (RTLS)

RTLS is quite involved and has a powered phase (until MECO) and a Glide phase after that. Powered-RTLS guidance aims to bring the Shuttle to the following conditions at MECO: - Altitude about 72 km - Moving towards the launch site with velocity that depends on distance at MECO - Less than 2% propellant remaining, no more than 20 s of burn time on two engines There are several phases to Powered-RTLS abort: - **Lofting** if the engine is lost before SRB sep, to try to achieve close to nominal altitude and vertical speed. Actual active RTLS guidance kicks in after SRB sep - **Dissipation**, flying outbound for a certain time to waste fuel. Guidance is open-loop, limited to pitching up by an angle that depends the surface velocity at engine failure (or SRB sep). The script uses the PEG algorithm as a predictor to estimate the fuel needed to reverse course, when this matches the fuel remaining minus 2%, the dissipation phase ends. If RTLS is triggered very close to the negative return boundary, this step is skipped. Automatic OMS dump is initiated during fuel dissipation. - **Flyback**, where the shuttle pitches around towards the launch site and the outbound trajectory is slowly reversed to bring it home. The script uses a modified version of PEG for guidance. Since velocity-to-go and time-to-go need to match the 2% propellant constraint at MECO, as well as the constraint between position and velocity, active throttling is used as an extra degree-of-freedom. Throttling is disabled some time seconds before MECO as it can become unstable. The OMS fuel dump will cease before or at MECO during flyback. ### RTLS TRAJ 2 display ![rtls_traj2_display](https://github.com/giuliodondi/kOS-Shuttle_OPS1/blob/master/Ships/Script/Shuttle_OPS1/images/rtls_traj2_display.png) This display is rendered when the RTLS abort is initialised and lasts until after MECO. - At the top you have another cutoff velocity indicator, this time in terms of surface velocity. The range is from 1500 to 2500 m/s, and since the goal is to turn back higher cutoff speeds are indicated from right to left. - While the CO mark is actively placed in the right place, you should expect the actual speed at cutoff to be off this mark by a little. - The data lines are identical to the ASCENT TRAJ display, with the exceptionif an additional readout in the top-right UPFG box: - The desired burnout delta-time (T_C), this is the main indicator of a good RTLS guidance state, more on this later - The central plot is a little complicated. It represents altitude on the vertical versus the horizontal component of downrange velocity from the launch site. This means there are positive velocity (i.e. travelling away) and negative velocity (travelling back) regions of the plot in the horizontal direction. - The Shuttle bug should move within the curved lines, first it will be in the lower right region, moving up and further right during fuel dissipation. During flyback it will start moving to the left as the Shuttle decelerates, and also down as it loses altitude. It will cross the "0" line when the Shuttle starts moving back to the launch site, then it will keep moving left and gradually start climbing once again. - the bottom-right curve is the nominal ascent trajectory, the Shuttle shouldn't be to the right of this - the top slanted curve is the maximum lofted trajectory during flyback for aborts close to the Negative Return boundary - The bottom segment is the depressed trajectory for a liftoff engien failure, the Shuttle is slow and heavy in this case - The left-most horizontal line with "CO" indicates the cutoff line at 72km altitude, the Shuttle should be close to this line at MECO ### The meaning of T_C T_C is just a name for the difference between the time to burn down to 2% propellant minus the time-to-go coming from the PEG algorithm, it's the main figure that dictates when we should stop dissipating fuel and begin flying back During the dissipation phase this will be positive, because TGO assumes we turn back immediately but we still have too much propellant. Actually, if the engine failure is before SRB sep and the algorithm is started when we're still close to the launch site, there might not be a good solution to find and T_C will have some nonsense values. TGO and VGO will be yellow until we're safely far enough away and T_C is stable, only then the program will accept its value to check if we should begin flyback. Once we trigger Flyback, T_C will settle around zero as the PEG algorithm adjusts the throttle so that we burn propellant all the way to 2% during the rest of the manoeuvre. ### Glide-RTLS After MECO and separation, the script will stop and automatically call the **OPS3** reentry script which takes case of **Glide-RTLS (GRTLS)** guidance. In a nutshell: the Shuttle pitches up to 45° as it performs an aerobraking manoeuvre to stabilise the falling trajectory into a more nominal reentry trajectory, controlling vertical G forces. At the end of GRTLS the Shuttle will be about 200 km from the launch site, 35/40km altitude at about Mach 4, in a gentle descent. **Please read carefully the OPS3 documentation for more about Glide-RTLS** ### Detailed results from my RTLS tests Here I present my test results for RTLS aborts. The scenario was STS-9 (RS-25A, Lightweight tank, Spacelab payload at 57° inclination). The only variable is the time of engine failure _t_fail_ which ranges from liftoff to just before Negative Return. The plots include both Powered and GLide RTLS phases ![rtls_trajplot](https://github.com/giuliodondi/kOS-UPFG_OPS1/blob/master/Ships/Script/Shuttle_OPS1/images/rtls_traj.png) The first plot is altitude vs. downrange distance, and shows the general shape of the trajectory. You can see: - engine failures before SRB sep result in lofted trajectories, as commanded - The maximum altitude during the manoeuvre is geenrally higher the later the engine failure - all trajectories target the same altitude at MECO, it's the "hump" at 72km - The downrange distance at MECO is different for all trajectories ![](https://github.com/giuliodondi/kOS-UPFG_OPS1/blob/master/Ships/Script/Shuttle_OPS1/images/rtls_vel.png) The second plot is horizontal velocity vs. altitude. Here you can see clearly: - when the engine was lost (the point of deviaton from the dashed nominal line) - when flyback was triggered (the point where the lines "bounce to the left" - that the Shuttle is already on its way down when flyback is triggered, in the case of early aborts - that the Shuttle does not come to a dead stop at the inversion point, as there is some sideways motion - That, just like downrange distance, all velocities at MECO are different ![](https://github.com/giuliodondi/kOS-UPFG_OPS1/blob/master/Ships/Script/Shuttle_OPS1/images/rtls_rvline.png) The third plot shows downrange distance vs. velocity, centered around the point of MECO. All the lines terminate close to the Range-Velocity (RV) line, which is the equation that Guidance uses to target MECO. Where exactly you land on the RV line is not important as long as the script cuts off the engines on it, which you can see as the velocity becomes almost constant (before increasing again during the Glide-RTLS descent). Curiously, very early and very late aborts produce trajectories that arrive closer to the site than mid aborts, this trend can also be seen in the farthest distance reached during flyback (see plot 1). Early aborts have low speed and acceleration and so the Shuttle cannot travel very far before flyback, while late aborts have the highest acceleration. ![](https://github.com/giuliodondi/kOS-Shuttle_OPS1/blob/master/Ships/Script/Shuttle_OPS1/images/rtls_throt.png) The final plot shows the throttle setting in terms of RPL percentage. The thottle is kept at maximum during fuel dissipation, and is actively adjusted during the flyback phase. You can see: - Max-Q throttle-down is done for all cases except a liftoff engine failure - MECO is where the lines end, right before it there is a period of minimum throttle (67% RPL), this is Terminal Guidance - The earlier the engine failure, the more fuel we need to dissipate, which results in a later pitcharound and flyback and a later MECO - All plots show a flatlining right before Terminal Guidance. This indicates when active throttling is deactivated during active PEG guidance because it's too sensitive - During flyback, throttle initially settles around 98-99% RPL. This is a canned value given to the PEG algorithm during dissipation to determine the flyback moment with margin for error - An exception to this is the very latest abort since the dissipation phase is skipped for this one, as such there is more propellant that there ought to be which requires less thrust to meet the MECO constraints - Right before throttling deactivation, the throttle starts to show signs of instability The Glide-RTLS phase, which starts after arrival on the RV line, is completely open-loop, just a control loop exeuting pre-programmed manoeuvres triggered by the vessel state. The 40° angle of attack should be no problem for the Shuttle, assuming the control surfaces are set as per the Entry script instructions. Do not shift the CG aft, as the script will deploy the body flap to stabilise pitch and I've seen that this induces yaw instability in this phase.

Transoceanic Abort Landing (TAL)

The available TAL landing sites are taken from the landing sites defined in **Shuttle_OPS3/landing_sites.ks**, specifically those downrange of your launch trajectory. The program estimates continuously if there is enough delta-V to reach any of them accounting for gravity losses and crossrange. As soon as one is reachable, TAL becomes active. This is done for both the two- and one-engine case, gravity losses are higher in the latter case and this is why single-engine TAL is only available so late. In case of a manually-triggered abort, the TAL site chosen will be the one in the TAL site GUI selector. In case of an automatic abort, the site will be chosen at random among the sites within reach. If the TAL abort downmodes to single-engine TAL because of a second engien failure, the site remains the one selected. In case of a sudden double engine failure, the chosen site is the one with the best delta-V margin. Either way, there isn't much difference from a normal ascent, save for the automatic OMS dump and the roll to heads-up attitude which happens earlier. After MECO and separation the Shuttle will be around 120km and about to descend. The script will quit itself and automatically call the **OPS3** reentry script. **Please read carefully the OPS3 documentation for more about TAL reentries**

Abort to orbit / Abort once-around (ATO/AOA)

Abort to orbit and Abort once-around use the same guidance and differ only in what you decide to do after MECO. The PEG targeted orbit has an apoapsis just above the edge atmosphere and should only require 250 m/s of OMS propellant to circularise. Additionally, the orbital plane is not constrained so that guidance will not waste any more fuel burning off-plane. Since you need OMS fuel to do orbital corrections, no OMS dump is performed for this abort. The program will quit after MECO. Beyond this you have two options: - the ATO case: do an OMS burn to raise the orbit and continue your mission - the AOA case: firstly do a combined circularization - plane change OMS burn to bring you closer to a landing site on the next pass. Later on do a second OMS deorbit burn with the deorbit planner tool My fork of SpaceShuttleSystem with the **OPS3** entry script afford enough crossrange ability to cover all Abort Once Around trajectories. For AoA aborts out of KSC, you can return to KSC for inclinations up to ~45° . For higher inclinations, Northrup (White Sands) is your best choice. For Vandenberg launches, AoA back to Vandenberg is your only option

Contingency aborts

Coming soon, not implemented yet