2
u/Polymath6301 Apr 27 '26
There are two points in your KSP career when the dopamine high reaches dangerous levels.
The first is when you first dock manually.
The second is when you’re own, home-developed docking script docks, especially when it’s part of a full rendezvous.
Congratulations!
1
u/Pretty-Ad8932 Apr 28 '26
oh, I haven't done rendezvous :) It seems very complicated. At most I have a script that matches the inclination of the target's orbit. Docking by comparison is actually not so hard to figure out.
2
u/goldalbatross Apr 28 '26
I just made a script that combines a couple of maneuvers to launch from my Mun base and rendezvous with my Mun Gateway. I have a bug with my inclination burn so I usually only get within 3-5 kilometers of the station with the transfer burn. Hopefully I can close that gap some.
It actually wasn’t too bad to write a Hohmann transfer. As long as you are working with mostly circular orbits the math is straight forward. So maybe start there.
I’m going to bookmark this for when I start to figure out the auto docking part!
1
u/Pretty-Ad8932 Apr 28 '26
yeah I guess I should start with circular orbits. How circular though? Can your code work with, say, those low Kerbin orbit rescue contracts? They usually have a difference of around 10 km between periapsis and apoapsis.
1
u/nuggreat Apr 28 '26
There isn't really a fixed threshold where a target is in to eccentric an orbit it is more that a more eccentric target means a less efficient hohmann transfer that doesn't get you quite as close and at some point that will just be unacceptable. Where that point is depends on the player and the vessel. For me and my scripts 10 km in LKO is perfectly reasonable.
1
u/Polymath6301 Apr 28 '26
The calculations for Hohman transfers aren’t too hard, and then it’s just timing. Even a binary chop algorithm will get you there.
1
u/Pretty-Ad8932 Apr 28 '26
I think the hard part is that there are many ways to do it depending on how long you want to wait and how much delta v you want to spend. You could probably either minimize the wait or minimize the delta v but I think many times you may want something in the middle? Not too long but not too expensive?
1
u/Polymath6301 Apr 28 '26
Good point. If you’re going to be docking at a fuel depot, then I guess burn as much fuel as you dare!
9
u/SausageSmuggler21 Apr 27 '26
Dude! With all the activity in the main sub after the Artemis II mission, I've been getting the itch to load up again. Docking is usually what causes me to quit my campaigns. This is amazing!
(I do like that right when the ships docked, with your POV and Kerbol in the background, it looked like they exploded for a second. )
1
u/ikansh-mahajan Apr 27 '26
Btw kOS vs kRPC can anyone explain what's the difference?
1
u/Pretty-Ad8932 Apr 27 '26
I haven't tried kRPC but afaik it allows you to script in languages other than Kerboscript (which was made for kOS)
3
u/nuggreat Apr 27 '26
There is one main difference between kOS and kRPC and everything else stems from that difference. That difference is that kOS exists within KSP where as kRPC is external to KSP.
The result of kOS running your code from within the KSP physics thread is that there is very little control lag between reading data from the game and responding to it. But the down side of running within the thread is that kOS has to limit how much computation it allows or else it will lag KSP.
kRPC on the other hand because it provides
RPCs or Remote Procedure Calls for other external programs to use to reach into KSP to get data or issues commands into KSP adds some extra lag to getting data and then issuing commands based on that data simply because the retrieval and response take time. But the advantage this provides is that kRPC can be used with most common programing languages and said programs you write have full access to the rest of your computer for any computation you might want to do without any risk of lagging KSP provided your programs do not intrude on the threads KSP is using to run the game.Personally I prefer kOS because it exists within KSP and as a result it feels more like I am writing code to run on a rocket because of the limitations that kOS has when it comes to running player code, as apposed to kRPC which feels more like I am writing programs out side of a game to control the game.
8
u/Pretty-Ad8932 Apr 27 '26 edited Apr 27 '26
Update: you don't really need midPos, instead you can just
lock tgtVel to relPos:normalized. The original idea was going to midPos allows some "breathing room" but you already get some by first going to the point that is 20 meters before the target docking port (this also allows your ship to approach your target from the back and a little sideways without crashing. It will still crash if you try to approach straight from the back though.)