Jump to content

[old thread] Trajectories : atmospheric predictions


Youen

Recommended Posts

So, working through this....

Feel free to use the above code snippets however you like.

I love you, guys. I copied your code verbatim. Can we keep up this little collaboration of ours? That would be really awesome.

The "problem" at that point becomes one of feedback to the user, who probably just wants to know why their trajectory isn't being displayed. A simple message in either the Trajectories window or an on-screen message might be enough to fix that.
I did just that, in 8fc32aa. Thanks for the hint. Also,
I'm not sure to understand what you mean here. Body-fixed mode only changes how the trajectory is displayed (relative to the rotating frame of the body, instead of the inertial frame), but doesn't change the impact position (indicated by the red cross which is at the same place in both cases).

Ok, I must have mistaken something. Sorry for the confusion

Maybe would be worth waiting for it to work with FAR before releasing on AVC and Kerbal Stuff ? (people can still download version 1.1 on github in the meantime).

Certainly! I just hope I can fix that. Complete game freeze is hard to debug :S

I uploaded the new version. It should work fine for Stock now, I hope. Be sure to report all problems.

https://github.com/fat-lobyte/KSPTrajectories/releases/download/v1.1.0.0-pre3/Trajectories-1.1.0.0-pre.zip

Hmm that could have been the reason it was freezing with FAR? Worth a shot.

I'm afraid not :(

All hail the disassembler. Don't tell squ4d!
Edited by Kobymaru
Link to comment
Share on other sites

@Kobymaru: To increase the speed of debugging, make sure to remove all unnecessary mods from your GameData folder, and even delete some/most SQUAD assets; that will greatly speed up loading times. Then just sputter debug log messages _everywhere_; you'll find them in player.log. With a moderate amount of debug messages put in after every test, you should be able to determine the exact line that causes the freeze within 10 or so iterations.

Link to comment
Share on other sites

@Kobymaru: To increase the speed of debugging, make sure to remove all unnecessary mods from your GameData folder,

Thanks for the hint. In my Dev-install, I only have blitzy's toolbar, FAR and the plugin.

and even delete some/most SQUAD assets

What are "some/most SQUAD assets"? What can I delete so the game still works?

Link to comment
Share on other sites

Try it yourself... you can always wreak havoc on parts safely, but I think deleting all the interiors works, too. It produces errors and breaks IVA, but if you don't need that it greatly speeds up loading.

Also be sure to use a small plugin that lets you skip the menu and directly jump to the last vessel. This is what I'm using: https://bpaste.net/show/f18cc717d902 edit: Heh, nvm, I even stole that code from this very mod :P

Edited by mic_e
Link to comment
Share on other sites

That's not-so-great news. Your mod was a nice alternative to MechJebs landing predictions.

Anyway, I'm a programmer myself, and I have interest in getting involved with KSP mods. I am a complete Unity/C#/Modding noob however. I wanted to start out easy and contribute to existing mods, but your mod might be a good a starting point as any.

If you could stick around a while and give me some pointers, I could try getting it to work for .90. Interested?

Edit:

Ok, so I

- forked your Repo

- disabled AutomatedTesting and TestAutomation

- Bumped the version number

- Recompiled and uploaded to here: https://github.com/fat-lobyte/KSPTrajectories/releases/download/v1.1.0.0-pre1/Trajectories-v1.1.0.0.zip

- Tested it.

All seems to work. No crashes, no errors in the log file, all GUI is available and since I figured out that you should check "Body-Fixed mode", it's even super-accurate (landed at the KSC after making a deorbit burn at phase angle ~330°) :)

I don't know how this AVC / CKAN busyness all works, but since it's working nicely, I'd recommend that you upload it so people can make use of it.

Edit 2: Does not work with Ferram Aerospace yet.

Uuhhh, your github page cannot be found.

Link to comment
Share on other sites

Just a quick update:

With clearing out my Dev Install of KSP as suggested and with that nifty little snippet of mic_e, I was able to spam the log with billions of debug statements.

Having done this, I at least figured out the general location of the problem:

In Trajectories.Trajectory.AddPatch(), file Trajectory.cs:475 there is a while loop that ominously starts with

while (true)

This little fella is in fact an infinite loop under conditions where the trajectory meets the atmosphere. Because of that, all of the game locks up and you are left with about 0.05 FPS.

It took me long enough to get there and it's 0:30 over here in Europe, so I didn't dig much further. In case anyone who reads this has an epiphany, please speak up fast. If not, well, I guess I'll get digging again tomorrow.

tl;dr for the Users: There's a bug when FAR is used and we found it, now we have to fix it. Please Stand By.

ps.: I never thought I'd make testimonials for Microsoft, but the MSVC# 2013 Prof does turn out to be pretty darn useful:

http://i.imgur.com/hOid5HB.png

pps.: Sorry for spamming the Release thread, but I'm too tired to make a proper Development thread and I want to get it right.

Edited by Kobymaru
Link to comment
Share on other sites

Just with FAR.
on the github page it reads

"If you try to go from Orbital to Suborbital flight with Trajectories enabled, you will freeze up your game."

is this in general or just with FAR?

FYI, the first time I tried this the game almost locked up on me while in ascent. I double checked all the versions and saw that the FAR-MechJeb extenstions were updated. I reinstalled FAR and it's MJext, then reinstalled the newest version of Trajectories and all was fine again. MJ and Trajectories still don't jibe with their landing predictions but at least it didn't lock up the computer!

Link to comment
Share on other sites

Interesting.

FYI, the first time I tried this
What is "this" and what version has "this"?

Interesting.

the game almost locked up on me while in ascent.
What's "almost" locking up?
I double checked all the versions and saw that the FAR-MechJeb extenstions were updated.

What were the old versions?

I reinstalled FAR and it's MJext
Which version would that be?
, then reinstalled the newest version of Trajectories
Is that 1.0.0 from CKAN/Kerbalstuff or 1.1.0 from my GitHub page?
and all was fine again. MJ and Trajectories still don't jibe with their landing predictions but at least it didn't lock up the computer!

Are you saying that if the FAR MechJeb extensions are installed, Trajectories work and are displayed correctly?

Also, what's "don't jibe with"? Sorry, I'm not a native english speaker.

Link to comment
Share on other sites

Interesting. What is "this" and what version has "this"?

Interesting. What's "almost" locking up?

What were the old versions?

Which version would that be?

Is that 1.0.0 from CKAN/Kerbalstuff or 1.1.0 from my GitHub page?

Are you saying that if the FAR MechJeb extensions are installed, Trajectories work and are displayed correctly?

Also, what's "don't jibe with"? Sorry, I'm not a native english speaker.

Phew. I thought I was being fairly succinct. Guess not! OK, The first time I tried the newly re-compiled Trajectories version 1.1.0.0, with FAR 14.5 and MechJeb dev 366, the first time I hit around 9000meters (I'm guessing) my framerate went down to about 1fps. Every once in a while something I've changed will kill the game and that's how it starts, framerate takes a hit and then the entire laptop locks up. On a side note, I'm running 0.90 in Linux Mint, 64bit.

At that point, the FAR MechJeb extensions were not updated. I checked here and saw that Trajectories were updated to 1.1.0.0-pre. I got the same results. Then I checked again and FAR was updated to 14.5.1 and the new FAR MechJeb extensions were out, as well as MJdev371. Combining all three of these new versions I did not get the horrible framerate and everything went as normal.

As for 'not jibing' I mean that MechJeb and FAR don't work well together, even with the FAR extensions. Trajectories does indeed predict correctly, even if MechJeb and FAR cannot get that part right.

So..in short, I'm using MJ371, FAR14.5.1, FARext for MJ, and Trajectories 1.1.0.0-pre and I don't see any performance hits like I used to.

Link to comment
Share on other sites

Phew. I thought I was being fairly succinct. Guess not! OK, The first time I tried the newly re-compiled Trajectories version 1.1.0.0, with FAR 14.5 and MechJeb dev 366, the first time I hit around 9000meters (I'm guessing) my framerate went down to about 1fps. Every once in a while something I've changed will kill the game and that's how it starts, framerate takes a hit and then the entire laptop locks up. On a side note, I'm running 0.90 in Linux Mint, 64bit.

At that point, the FAR MechJeb extensions were not updated. I checked here and saw that Trajectories were updated to 1.1.0.0-pre. I got the same results. Then I checked again and FAR was updated to 14.5.1 and the new FAR MechJeb extensions were out, as well as MJdev371. Combining all three of these new versions I did not get the horrible framerate and everything went as normal.

As for 'not jibing' I mean that MechJeb and FAR don't work well together, even with the FAR extensions. Trajectories does indeed predict correctly, even if MechJeb and FAR cannot get that part right.

So..in short, I'm using MJ371, FAR14.5.1, FARext for MJ, and Trajectories 1.1.0.0-pre and I don't see any performance hits like I used to.

Thanks a lot for the detailed description! :)

I will play a bit with the Mechjeb FAR extensions tomorrow.

Did you try to compute trajectories after launch and going up, or did you go from orbital to suborbital? If it was the former, could you try the latter case too, please?

Link to comment
Share on other sites

Thanks a lot for the detailed description! :)

I will play a bit with the Mechjeb FAR extensions tomorrow.

Did you try to compute trajectories after launch and going up, or did you go from orbital to suborbital? If it was the former, could you try the latter case too, please?

I did not try to compute trajectories going up, but I suspected that it was was causing the framerate drop before I switched to 1.1.0.0-pre. As for landing, while using MJ's landing function and targetting the KSC, Trajectories correctly predicted the true landing spot, while FAR and MJ kept thinking that the ship was still going to land at the Space Center.

So trajectories had it right, but using Far with MechJeb alone, MJ can't correctly predict the effects that FAR has on entering the atmosphere. But using those 2 in conjunction with Trajectories, it's easy enough to make corrections to land where I want.

(So yea, now that the framerate issues seem to be gone, it looks like Trajectories is working as intended for me, while MJ and FAR still need to learn to work together)

Edited by Eleven
Link to comment
Share on other sites

So I decided to help and pulled your debug release, slapped in a few extra debug statements around that while loop and ran Trajectories on a Dev install I have. This is KSP 0.90.0, with FAR 0.14.5.1, Hyperedit, toolbar and Mechjeb Dev 366 from a few days ago. I do not have any MechJeb FAR extensions on. It worked with no crashes. So I went to your pre-release version and tried an ascent and re-entry with predictions on ... seemed to work fine. Only thing I noticed is that I needed to correct a little more than I remember to land at KSC. This was a capsule landing. So, I didn't see any framerate issues and the mod is working.

Link to comment
Share on other sites

(So yea, now that the framerate issues seem to be gone, it looks like Trajectories is working as intended for me, while MJ and FAR still need to learn to work together)
So I decided to help and pulled your debug release, ... So, I didn't see any framerate issues and the mod is working.

So you are telling me you don't have the bug? Because I am still seeing the issue. Could you help me out a bit, please?

- Download this save file: https://www.dropbox.com/s/h37hkayszuc12pi/persistent.sfs

- Make a folder in <KSP-install>/saves/ and copy the persistent.sfs there

- Start KSP and open said save file

- Go to tracking station, switch to the only vessel (It's in LKO)

- Go to Map view

- Enable Trajectory display (To make sure: right click to get to the settings, then you have the "Display Trajectory" checkbox)

- Enable the Navball and push Z for full throttle. This will put your ships trajectory in the atmosphere.

- [sometimes everything works. In that case, press escape to go back to the KSC, then go back to the vessel and try again]

- What happens now?

On my end, everything now just locks up.

Edited by Kobymaru
Link to comment
Share on other sites

So I did just as you asked - and got the lockup as soon as the orbit hit the atmosphere - I can reproduce what you see.

Then I tried with a new craft I had working before (mark 1-2 pod, 800 tank, poodle, parachute), orbited and re-entered and I saw a trajectory in atmosphere. Hmmm.

Then I tried again with a new craft built like yours (oops, I added a parachute). Hyperedit'd it to orbit, then burned retrograde. I saw a trajectory in atmosphere!

Looking at the VESSEL entries in the savegame, I saw that your "k0" craft is missing the FAR modules... Which get created when you make a new vessel in FAR.

The following is my GUESS at what is happening: If you have a craft that was built without FAR installed, FAR ignores it (?) but then Trajectories comes along at requests FAR data for something w/o FAR modules, and it goes haywire? This would match the behavior Eleven and myself saw.

Link to comment
Share on other sites

The following is my GUESS at what is happening: If you have a craft that was built without FAR installed, FAR ignores it (?) but then Trajectories comes along at requests FAR data for something w/o FAR modules, and it goes haywire? This would match the behavior Eleven and myself saw.

It does not work like that. When a mod change a part it is changed for both old and new craft. The saved ship don't get the module because they were not loaded since FAR was installed.

Link to comment
Share on other sites

I love you, guys. I copied your code verbatim. Can we keep up this little collaboration of ours? That would be really awesome.

Anything I come across I'll certainly offer up. Glad I can help! I know little to nothing of the internals of FAR, so... not much I can do for you there.

I did just that, in 8fc32aa. Thanks for the hint.

Cool. I'll check that out this evening if I get the chance. Thanks!

Link to comment
Share on other sites

It does not work like that. When a mod change a part it is changed for both old and new craft. The saved ship don't get the module because they were not loaded since FAR was installed.

Dumb guess! I checked again and have some more curious behavior that might be a clue. I don't have time to check the code but...

I reloaded my save, loaded a craft that had been working, turned on trajectories and it froze right when the path hit the atmosphere.

I reloaded again, turned OFF trajectories, dipped into the atmosphere (once it hit 4X warp) and then turned ON trajectories, and it worked. Any else able to reproduce this?

Link to comment
Share on other sites

So you are telling me you don't have the bug? Because I am still seeing the issue. Could you help me out a bit, please?

- Download this save file: https://www.dropbox.com/s/h37hkayszuc12pi/persistent.sfs

- Make a folder in <KSP-install>/saves/ and copy the persistent.sfs there

- Start KSP and open said save file

- Go to tracking station, switch to the only vessel (It's in LKO)

- Go to Map view

- Enable Trajectory display (To make sure: right click to get to the settings, then you have the "Display Trajectory" checkbox)

- Enable the Navball and push Z for full throttle. This will put your ships trajectory in the atmosphere.

- [sometimes everything works. In that case, press escape to go back to the KSC, then go back to the vessel and try again]

- What happens now?

On my end, everything now just locks up.

BOOM 1fps. Game didn't actually die, but it was totally unplayable. I was able to uncheck the 'display trajectories' box and it went back to normal again :)

I tried again, this time with good old KerbalX and everything is nice and smooth. Must me something with that craft file of yours?

Edited by Eleven
Link to comment
Share on other sites

Independent of the actual solution to this problem, you should probably add a counter and emergency abort (printing a big fat warning message) to that while loop. I recall that it has caused lag issues in the past, and it probably will again in the future.

Regarding the issue: I've only taken a short glimpse at the code, but I think the relevant questions are:

- Will any save file that was created with FAR installed from the beginning cause this issue?

- Can the issue be reproduced with the old version and KSP 0.25?

- If not, what change caused things to break?

Link to comment
Share on other sites

Soo... I tested this as well and the mod "works"

I don't get any performance drops but the mod doesn't work very accurately. on a normal reentry trajectory the course gets plotted but as the craft descents through the atmosphere the landing point keeps getting corrected towards the east and ends up somewhere between the initial X spot and the end of your normal orbital vector. The shallower your reentry and the more aerodynamic your craft the bigger the error.

I'm aware that you caninfluence this by your angle of attack but it should stay the same if you punch in SAS and lock your rotation, or just be retrograde during atmospheric reentry.

Using FAR 14.5.1 and Trajectories 1.1.0-pre.

I tested this with a rather aerodynamic craft (shuttle) a normal rocket and a makeshift station (5 MK I capsules tricoupled together)

Link to comment
Share on other sites

So I did just as you asked
BOOM 1fps. Game didn't actually die, but it was totally unplayable. I was able to uncheck the 'display trajectories' box and it went back to normal again :)

Thanks for the testing guys!

Independent of the actual solution to this problem, you should probably add a counter and emergency abort (printing a big fat warning message) to that while loop.

I prefer not to do that, because OP already wrote a nice abort/timeout logic - it just doesn't work for some reason. Better to fix what's already there.

- Will any save file that was created with FAR installed from the beginning cause this issue?

Strangely enough, yes. I saw missing FAR modules on the craft, and also I'm consistently seeing the behaviour that after loading the save it works the first time, and reloading the vessel so my guess is that there is something wrong with initialization.

- Can the issue be reproduced with the old version and KSP 0.25?
I don't know, and I'm not to keen on testing it because that would require taking out the .90 specific code again.
If not, what change caused things to break?
There's also the new version of FAR. Edited by Kobymaru
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...