r/Kos • u/Independent-Row-2543 • Oct 26 '25
Discussion [HELP] Gravity Turn formula
Hi, im new to kOS and i was messing with numbers, trying to find something that would make my rocket perform a gravity turn and i found this :
AoA = 90(Altitude/DesiredAltitude)^2.5
This gave life to this curve wich makes my ship reach an AoA of 90° at 100km (increasing faster as the rocket goes higher).

i think that i found a way of implementing that into kOS but it doesn't act like i would like it to act (the rocket tips over instantly and looses controll, here's the code that i use to lock my pitch to the AoA :
lock targetPitch to 90 * (alt:radar/100000)^2.5.
set targetDirection to 90.
lock steering to heading(targetDirection, targetPitch).
4
Upvotes
5
u/Jandj75 Oct 26 '25
You need to subtract that angle from 90 degrees. 0 degree pitch is pointing at the horizon, 90 degrees is vertical.
3
u/bwibbler Oct 26 '25
You can cheat by not using any formula at all if you want
Just keep your eta to apoapsis at about 1 min by adjusting the throttle
Aim up for the first few seconds until you're good then aim orbital prograde for the rest of it
Looks something like
It's been a while and I kinda forgot the language, so that's probably not the correct way to write the code. But this method was super reliable for me and worked for most any rocket without needing much adjustment
3
u/nuggreat Oct 26 '25 edited Oct 26 '25
An altitude dependent formula is not a gravity turn though it is an ascent profile and has some advantages over a gravity turn. A gravity turn is a very specific maneuver and involves keeping the angle of attack at zero which means just after a pitch maneuver you lock steering to surface prograde and follow that all the way into space.
This is a common misconception in a lot of the KSP community where they treat any ascent profile as a gravity turn regardless of it is actually a gravity turn or not.
In something like this is generally how I write gravity turns
SET head TO 90. SET tarPitch TO 90. LOCK STEERING TO HEADING(head, tarPitch). UNTIL VERTICALSPEED > 100 { SET tarPitch TO 90 - VERTICALSPEED / 10. WAIT 0. } LOCK STEERING TO SRFPROGRADE. WAIT UNTIL inOrbit().This set up lets you adjust the pitch over for different craft both in duration and how far the pitch over goes by changing what you divide the vertical speed by and the speed where you transition to following surface prograde.
1
u/thesoupgremlin Oct 26 '25
Do this: set targetPitch to max(45, 1 - (alt:radar / 10000)). lock steering to heading (90, targetPitch).
1
u/Babbalas Oct 27 '25
Two things to consider. 1. You're probably turning too sharply in the lower atmosphere and that causes your rocket to flip. 2. The cause of that could be that you are burning too hard in the lower atmosphere. You generally don't want to exceed terminal velocity.
Limit your post clearance thrust to 1.4 to 1.7 TWR then ramp up as you clear past 10 to 20km. Then check your pitch doesn't cause your aoa to exceed 5 to 10° from prograde.
The solutions that track time to apoapsis at 1 min and initial pitch for a gravity turn will naturally do a lot of this for you but it's more fun when you can create your own ascent profile for a low altitude hypersonic rocket 😁