Patrykz94 / KSP-RO-Booster-Landing

A booster landing script using the kOS mod for Kerbal Space Program
MIT License
19 stars 2 forks source link

Question about code #12

Open GYskyfall opened 5 years ago

GYskyfall commented 5 years ago

default I can't figure out the meaning of these codes, would you please explain to me? another question: How can you get the coefficients of the PID loops and other formulas?

Patrykz94 commented 5 years ago

Let me just start by telling you that this is a very old version of the code, I'd recommend you look at the "dev-overhaul" branch instead of "master" as that has the latest version. This old version wasn't coded very well and I'm having a hard time understanding some of the code myself (basically, I was a noob when I wrote this).

But here's a quick explanation what those variables do:

landingOffset is a vector that goes from the predicted impact position to the landing pad position. It's then flattened, normalized and resized to a value of posOffset. Basically if you add this to the lzPos:position, it should point in opposite direction to the predicted impact position.

landingOffset2 is similar to landingOffset, instead of using the predicted impact position, it uses the current booster position. So if you add that to the lzPos:position, it will pint at a spot directly behind the landing pad. Also, the length of this vector is dependent on how far the booster is from the landing pad. The closer you are, the shorter the vector will be so as you get closer to he landing pad, it will want you to cancel your horizontal velocity (this is actually used for guidance during landing, the booster is aiming for lzPos:position + landingOffset2).

velDir is just a vector of surface velocity (just resized to 25, I think I did that just beacuse at lenght 25 it was easily visible using the vecdraw function).

velDirFlat same as velDir but flattened/horizontal only.

desiredDir (I hate myself when I look at this variable) is used during the boostback and reentry burns. This is the vector that I lock steering to and it basically points from predicted impact position to a point behind the landing pad during boostback burn. During reentry burn, basically it does the opposite of that what it does during boostback.

Also, I recommend you have a look at syntax highlighting. Without that it's even harder to understand code, here you can find out how to install it in Sublime Text (assuming that's what you use) and other editors: https://github.com/KSP-KOS/EditorTools/tree/develop/SublimeText3

GYskyfall commented 5 years ago

Thank you very much!

GYskyfall commented 5 years ago

Would you please tell the name or example of the guidance using the landoffset2 in landing and recomend some reference about those guidance.

I also don’t understand the meaning of the “ landburnS2” ,would you please explain it.

what's the meaning of the "body:position" in the formula calculating the landoffset?