This is a complete autopilot for optimum rocket ascent guidance.
This is not a plugin for KSP, but standalone application using kRPC KSP plugin to control the vessel.
Compatable with kRPC 3.7 (KSP 1.2.2)
It uses burn-coast-burn scheme to guide rocket in a specified orbit from ground with two phases:
1. Gravity turn phase. Vessel is guided at ideal gravity turn trajectory (near zero AoA) through dense atmosphere to minimize control momentums and drag.
2. Orbit injection phase. Vessel is guided into specific orbit with optimal control and coast arc between two burn segments.
Both phases are connected for smooth transition and optimality. Vessel control in both phases are based on dynamic iterative numerical solver of optimum control problem. This is something used for modern real life rocket guidance systems. Math background used there, is something like this.
Works good for any “normal” rocket, including real rocket models like R-7 series with real scale Earth. Can be used at any planet or moon with any vessel design. Install of KJR plugin is strongly recommended to minimize oscillations and stabilize attitude control system.
Parameters:
Orbit Parameters:
Pe - Required orbit Periapsis (distance from surface to lowest point) in km. Must be specified.
Ap - Required orbit Apoapsis (distance from surface to highest point) in km. Default to Pe.
Inc - Required orbit inclination (angle between ecliptic plane) in deg. Default to launch point.
LAN - Required orbit Longitude of Ascending Node in deg. Default to some optimum value.
APE - Required orbit Argument of Periapsis in deg. Default to some optimum value.
TAM - True Anomaly. Default to some optimum value. See note.
This utility is designed for low orbits only, it simply can’t converge for hi orbits. Pe, Ap, Inc and APE is a dynamic control parameters, so guidance system continuously adjusts trajectory to match them at the end. LAN is a semi dynamic parameter, launch control will delay launch time to match this parameters as close as possible, then adjusts trajectory during ascent. TAM can’t be specified directly, but can be picked up from target body or vessel. It is a static parameter and affects launch time only. You can try to launch vessel directly to other, but actual precision is not enough to start docking maneuvers immediately in most cases. Direct APE setting is not recommended, because it strongly affects computation stability. I am recommended to leave it optimum or use circular orbits.
You can set something as target, and use some of it’s orbit parameters (for example, Moon LAN and Inc) to get already aligned orbit after launch. Inclination changes below launch site location is possible, but very-very fuel consumptive, try to avoid it.
Control Parameters:
Min Turn V - Vertical speed for gravity turn start. Vessel must gain some vertical speed after launch to enter gravity turn without problems. In other hands, if this speed is too high, AoA and dynamic pressure limits can prevent it to enter gravity turn properly. Do not set this less than 10 m\s, even on Minmus without atmosphere, because it strongly affects computation stability.
Min Path ALT - MSL altitude for orbit injection start. Set this high enough, because vessel can perform rapid maneuvers with high AoA if it is out of gravity turn trajectory at switching point (crash is possible if this is happens in dense atmosphere). Other reason to set this parameter higher, is a situation, when the vessel can’t exit dense atmosphere, because of strong AoA and dynamic pressure limits, so it can’t correct its trajectory to stay on perfect gravity turn. Increasing this parameters makes whole trajectory higher, but less efficient and optimal. Also, in some cases (with very low thrust on upper stages), solver finds optimum solution by utilizing planets gravity itself, with very long coasting arc and atmosphere reentry in it. You can avoid this making parameter higher. And it is a good idea to set this parameter very low on bodies without atmosphere to save some fuel.
Min Throttle - Minimum throttle for throttling in case of dynamic pressure limit violation.
Skip Stages - Skip N upper stages from computations, can increase solver stability and performance dramatically.
Q Limit - Dynamic pressure limit controlled by engines throttling.
Lon G Limit - Longitudinal acceleration limit controlled by engines throttling.
Angle Limit - Some function of AoA and dynamic pressure that limits rocket maneuver authority during flight in atmosphere. Set this lower if rocket goes out of control, or higher, if can’t maintain gravity turn trajectory.
Coast Arc - Use coast arc (recommended but not mandatory). You can disable this (and this will increase computations seed and stability) for real rocket models with real scale Earth because of this rocket’s design, so it will reach desired orbit with one continuous burn, as in real life.
Coast Fixed - Start coast arc exactly on last stage separation (useful for real engines models with only one ignition).
Target Roll - Roll angle for flight guidance.
Pitch\Roll\Yaw Aero T - Momentums produced by aerodynamic surfaces in case of FAR installed at some flight conditions. Have no access to aerodynamic model through kRPC, so you need to find (with experiments) this values for each vessel by yourself.
Alpha limit - Maximum AoA used for space planes takeoff from runway during initial rotation, not used for rockets or for space planes in flight (it is always limited to 15 deg for space planes).
Auto Stage - Use automatic stageing (clever and smart enough for most cases).
Pre Active - Start next stage engines N seconds before stage separation (useful for real engines models with spin up time).
Inter Stage - Pause between staging events.
Auto Warp - Automatic time scale control during coasting.
Use kRPC AP - Use default kRPC autopilot for attitude control. It is slightly more stable in some cases because there is no delay between KSP and controller, but have significantly lower performance because of it’s structure.
This utility partially supports space planes with launch from runway. In this case, instead of gravity turn, it uses “Min Turn V” for minimum takeoff speed, and “Q Limit” as reference, to gain altitude and speed. Then switches to orbit injection phase as usual. “Partially”, because I have no access to aerodynamic model through kRPC and can’t make this controllers stable enough, but you can try…
Statistics:
TTO - Remaining time to orbit.
TFL - Total flight time.
TTL - Remaining time to launch.
TTC - Remaining time to coast.
TCT - Remaining total coast time.
TTB - Remaining time to burn.
TBT - Remaining total burn time.
BDV - Burn equivalent vacuum delta-v. Slightly overestimated because of atmospheric drag not included in computations, but pretty accurate. You can rely on them.
RDV - Residual equivalent vacuum delta-v. This is a delta-v that you will have on the rocket after orbit insertion. Slightly underestimated because of atmospheric drag not included in computations, but pretty accurate. You can rely on them.
AP Mode - Brief description of current autopilot mode.
OPT State - Trajectory optimizer state. You can’t launch rocket if there is “no solution”. This means you have not enough fuel or thrust to reach desired orbit or something wrong with staging sequence (or with trajectory optimizer itself). Nothing is guaranteed if solver is “not converged”. So, there is some old solution, or solution is not precise enough. You can engage autopilot with hope that you do not crash into planet. Nominal state is “converged”, this means that rocket can achieve desired orbit from this point.
How to use:
1. Install kRPC server plugin (with CKAN or directly) and run KSP in window mode.
2. Select some vessel for launch (through assembly building, launch pad, or simply switching to it resting somewhere).
3. Check kRPC server plugin running in KSP with appropriate parameters.
4. Run Launch Control application.
5. Select “Coast Arc” and “Coast Fixed” options.
6. Press “Connect” button, wait for connection and vessel state synchronization.
7. Check for kRPC server will rise three connections: AttControl, StateSync and LaunchControl.
8. Select orbit and control parameters.
9. Press “Apply” button.
10. Wait for optimizer convergence (OPT State: converged).
11. Press “Engage” button.
12. Disengagement occurs automatically after the vessel reached desired orbit.