kOS Tutorial 02 - Landing Near the Space Center
HTML-код
- Опубликовано: 7 фев 2025
- This video is the second video in my kOS series. In it we learn how to de-orbit and land the rocket we launched last time, as well as a few more features of the mod. Please let me know if this video was helpful to you by leaving a comment!
Download the exmple code here: gist.github.co...
kOS Release and Download Thread: forum.kerbalspa...
Official kOS documentation: ksp-kos.github....
Official kOS Quick Start Tutorial: ksp-kos.github....
The music used in this video was created by Kevin MacLeod under a CCbyA license and consists of the following tracks:
"Funkorama" "Cold Funk" "Slow Burn" "Pilot Error"
The above music can be download from incompetech.com
After playing KSP for three years, I just discovered kOS and am having flashbacks of BASIC. Thank you for the extremely clear explanations.
Amazing job again! Video is very interesting. Using your previous script, I have actually made a script to take me to orbit (without copying your script, made from scratch). The tutorial is very helpful and enjoyable to watch. Hopefully by next week i will have written a deorbit script. This time i will actually have an idea on what I am doing. Thanks again. Can`t wait for the next one! :)
That video really helped me pinning the last touches to my deorbit program, thanks a lot!
that video makes it look wayyyy too easy! Thanks for the vid! Im about to give it a try!
Really nice job. You do a very nice job of explaining.
next video should be on Maneuver Nodes. Setting, Reading, Executing
Are they Monopropellent RCS Engines your using to land??? How does that give enough thrust?
Nice to see another ham de KF7QYA!
8:31 Safety margins! Kerbals are strong as steel!
hey, this was a video from 8 years ago so I guess a reply is not warranted, but how did you derive the value for the tval on the suicide burn? I understand 1/TWR, its for hovering, but what about the next terms that you subtract from it?
I've found the line you're talking about; the second term basically looks to add power if the rocket is coming in at a higher vertical speed or is close to the ground.
In a coming-in-hot scenario, verticalspeed is highly negative, so this would increase throttle significantly.
As for the other parts, it looks like he added a term to increase throttle with decreasing distance to the ground. All the constants seem to basically be magic numbers he derived from testing the code out and tweaking it to fit this particular vehicle.
aerobraking might be a fun thing to try.
Is there a way to have separate codes for different stages on the same rocket? I'm aiming to recreate the Falcon 9 relanding at launch site while Dragon heads off to space.
same as im trying to do, its hard as hell.
this wouldn't work anyways, since as soon as the landing booster goes out of the physics bubble of the ship, it wouldn't compute anymore and just be "on rails" -> balistic trajectory. It'll crash into the ground.
But you could have two programs running at different CPU modules. One only starts doing stuff as soon as it's decoupled. I think that should work
it does, that's how i did it. I used "message" to let my booster know it could do its thing.
Nice video! For me, my deorbit burn makes me land on mountains. (and by land i mean crash into them), do you know a fix for this? ive even tried using the script you provided (copy pasting then testing)
Oh, sorry but I've got another question:
How do I calculate a linear equation? I'd need this for calculating the Thrust I need to stay at one altitude.
I have this:
UNTIL FLIGHTSTATE = 2
{
SET THRUST TO SHIP:MAXTHRUST*THROTTLE.
SET NEEDEDTHRUST TO THRUST/SHIP:MASS*9.82=1.
1 should be the TWR at this point, allowing the rocket to stay in the air, and not going up or down. But I only get a TRUE or FALSE from kOS. Anything I can do? :)
}
Since AFAIK runmodes are always SET to specific values, and not incremented or decremented, would you recommend using strings instead of numbers?
10/10 IGN
Hello thanks for the vid but i have some questions ?
how do i modify this code in 1 stage lower my Lower Periapsis below 60 km in one burn no matter where i am at in my orbit then start run mode 25
You can use something like this:
wait eta:apoapsis.
lock steering to retrograde.
lock periapsisCondition to ship:periapsis
Great series, this was what I was looking for and what finally got me started properly with this mod!
Just one Question:
Your equation for the impact time doesn't make sense to me. I tried it out by experimenting with kerbal engineer and it does not work.
Shouldn't it be a rearrangement of the equation
Altitude=0,5*g*t^2 + (-verticalspeed)*t ?
My problem is that I can't get it rearranged because of the square.
I hope you can help me with that.
Martin Zietz You're right, my impact time calculation was way off since it doesn't account for acceleration due to gravity. This worked out well enough for this demo, but once we step up to things requiring more accuracy it's not good enough. (early on simplicity>accuracy)
The equations that I've started using are as follows:
set SEALEVELGRAVITY to (constant():G * body:mass) / body:radius^2.
lock GRAVITY to SEALEVELGRAVITY / ((body:radius+ALTITUDE) / body:radius)^2.
lock fallTime to (0-VERTICALSPEED - sqrt( VERTICALSPEED^2-(2 * (-GRAVITY) * (betterALTRADAR - 0))) ) / ((-GRAVITY)).
This gives a *way* more accurate estimation for the time it will take to hit the ground, even if the ship currently has a positive vertical speed. It still needs to account for atmospheric drag, but does at least account for the differing amounts of gravity the higher up you are. It will eventually need to be updated to account for the fact that gravity doesn't stay at that one level for the whole estimation though. That's an update for another time, lol.
I hope this helps you out!
Seth Persigehl Thx, it does. I just simplified your gravity equation to:g=(G*mass)/((radius+altitude)^2).Works for me. Thank you so much for these tutorials.
Hey, Seth! I've found these tutorials very helpful.
I'm attempting to do an autonomous landing of a vehicle on land, like SpaceX. I know your scripts works when called, and all my rockets descend and land perfectly.
I'm attempting to perform a boostback burn after it hits orbit. I have the longitude I want to burn at, and the craft recognizes it, but how do I tell it to stop burning when the impact location is roughly near KSC? Thanks!
+Eric That is an excellent question! The (sub-optimal) method that I used in my SpaceX landing program was to burn until the ratio between (horizontal speed to the landing site) and (time it takes to impact the ground, taking into account gravity a different altitudes) was higher than 1 + an overshoot margin with a fudge factor for air resistance. It worked well enough, but wasn't the most fuel efficient or safest method by any means. You might find this post useful, as Caleb9000 has been doing some amazing work: www.reddit.com/r/Kos/comments/4f85d4/spacex_style_return_to_launch_script_code/
Cheers!
Thanks so much! Is there any chance you'd continue the "how to KOS" series?
You're awesome! But one thing I didn't really understand: How do you set the target of your landing site to the LATLNG (Latitude/Longitude)? I tried something like "LOCK/SET TARGET TO LATLNG(-5,125)." But that didn't really worked out. Also, how do you show off those arrows? For example I'd like them to show in the direction where my Target vessel is, but I have no idea how. Any hints there? :)
Thank you!
The command you have should work. Perhaps the function that then calls on TARGET is having issues? Here's a link to the github documentation on LATLNGs ksp-kos.github.io/KOS_DOC/math/geocoordinates.html
And here's the documentation for drawing vectors so you can try it before I show it in a video: ksp-kos.github.io/KOS_DOC/structures/misc/vecdraw.html
Good luck!
Seth Persigehl
Thanks for your reply! I'm really looking forward to see more tutorials, you do a really great job! :)
Nice tutorial!
though it would be nice to have the tutorial number in the title :P
I'm glad you liked it! Good point about numbering the videos. Fixed :)
would this code also work if I added a parachute to my craft (I know how to activate it at a certain height, I just wonder about the burn calculations (I am a math and scripting idiot))
Most of the code would work just fine, it's only the final touchdown code that would need to be changed (Runmode 27 in my code) and WHEN condition to throw the chutes at the given height, like you mentioned. The burn calculations would need to be changed to work with the reduced terminal velocity. There are several ways you could go about changing the code, such as reducing the preset thrust level on line 176 from (1 / TWR) to something more like ( 0.1 / TWR) depending on how effective your parachutes are. Good luck!
do i need to code in c ?
tatuf Metuf Nope, not for this mod. kOS uses it's own language. Here's a link to the official quick start guide: ksp-kos.github.io/KOS_DOC/tutorials/quickstart.html
+Seth persigahl plz help me i dont know where to type all of this in the new versions of ksp and kos i'm also really bad at learning code :'(