Youen

[old thread] Trajectories : atmospheric predictions

Recommended Posts

+1 to thank you for your continued work on this. Looking forward to the day when we can use this in stock again :)

Share this post


Link to post
Share on other sites
Yeah, really surprised stock didn't expose something similar. Oh well, doesn't affect me too much ass I am a FAR man to the core.

I am a bit late the party but stock does expose most if not all of the aerodynamics. The problem that I had in MJ is that the stock call are not thread safe and all the MJ sim is done in a thread. If anyone need more details on why stock does not work with thread I'll gladly share them in an other thread (just PM me to mention it)

So if Trajectories does not use thread the stock method can be called and that would me far easier (and precise) than re-coding it, like I did.

Share this post


Link to post
Share on other sites

Would it be okay if this gets updated on CKAN, and the forum linked to here. Not the old thread?

Share this post


Link to post
Share on other sites

It's not on CKAN and KerbalStuff because it's not really ready yet. Here is a list of the major issues at this time :

- does not work with stock aerodynamics (that would bring thousands of bug reports if players install it without knowing)

- breaks your craft if prediction simulates forces that exceed FAR tolerance (bug in FAR that is solved but not released yet) ; if you go in map view, even while in orbit, and here big explosions, you probably just hit that bug and screwed your flight

- bug when your trajectory goes in the atmosphere of another body than the one you are orbiting (I think it also cause issues when orbiting the sun) that can slow down or freeze the game

- bug if you haven't entered the atmosphere yet (for example when loading a flight that is in orbit and trying to predict reentry before actually entering the atmospher, or so I believe, but haven't got time to investigate more)

If you experience one of these bug, just uncheck the "display trajectory" box, and you should be good to go. At this time, I recommend you only activate it when you know you're in a situation where it works (predicting entry of the body you are orbiting, with FAR, with a craft that is strong enough to actually survive entry).

- - - Updated - - -

I am a bit late the party but stock does expose most if not all of the aerodynamics. The problem that I had in MJ is that the stock call are not thread safe and all the MJ sim is done in a thread. If anyone need more details on why stock does not work with thread I'll gladly share them in an other thread (just PM me to mention it)

So if Trajectories does not use thread the stock method can be called and that would me far easier (and precise) than re-coding it, like I did.

Trajectories does not use threads (though it does spread computations on multiple frames, it does so in the main thread), so this method looks good. Thanks for the hint (haven't had time to look into it yet).

Share this post


Link to post
Share on other sites
I am a bit late the party but stock does expose most if not all of the aerodynamics. The problem that I had in MJ is that the stock call are not thread safe and all the MJ sim is done in a thread. If anyone need more details on why stock does not work with thread I'll gladly share them in an other thread (just PM me to mention it)

So if Trajectories does not use thread the stock method can be called and that would me far easier (and precise) than re-coding it, like I did.

Let me guess: the stock API is a static method? Have you considered using InvokeIfRequired()? Depending on which thread the stock class/object is actually running.

Share this post


Link to post
Share on other sites

Is there any point downloading this at the moment, if stock doesn't work? Does it just predict inaccurate trajetories, or are the problems more serious? I loved this mod before 1.0, hoping I can continue to use it.

Share this post


Link to post
Share on other sites

Progress report, first I had to figure out how to predict pressure, temperature and density at a given altitude. That part is done, I can get predictions of pressure, temperature and density really close to the actual values given for the vessel and/or parts. That's necessary to get the drag/lift forces right.

Secondly, I needed a way to understand what forces are acting on the vessel. It's done on a part basis - I studied Nathankell's AeroGUI mod and figure out some more info about stock aero.

I then went down the wrong path trying to implement Mechjeb's simulation - which as sarbian points out was made to be thread-safe and is overkill for this mod. I got in way over my head. Learned a few thing along the way, like I forgot all my vector math. sarbian helped clue me in to certain methods and calls that allow predictions for stock aero, notably Part.DragCubeList.AddSurfaceDragDirection. I've got that working in a test plugin trying to replicate the forces shown in AeroGUI. Then RealLife got the better of me while trying to figure out the vectors. Hopefully I'll get some more time soon.

It has been a real mental exercise - I'm used to FORTRAN/C/Python in a command line environment, so learning C# with Unity/KSP has been challenging.

Share this post


Link to post
Share on other sites
Is there any point downloading this at the moment, if stock doesn't work? Does it just predict inaccurate trajetories, or are the problems more serious? I loved this mod before 1.0, hoping I can continue to use it.

Currently its only working for FAR aerodynamics...

Progress report, first I had to figure out how to predict pressure, temperature and density at a given altitude. That part is done, I can get predictions of pressure, temperature and density really close to the actual values given for the vessel and/or parts. That's necessary to get the drag/lift forces right.

Secondly, I needed a way to understand what forces are acting on the vessel. It's done on a part basis - I studied Nathankell's AeroGUI mod and figure out some more info about stock aero.

Cheers :)

Share this post


Link to post
Share on other sites
Let me guess: the stock API is a static method? Have you considered using InvokeIfRequired()? Depending on which thread the stock class/object is actually running.

No, nothing like that. That part of KSP current code was actually done in a way that would work perfectly for my needs if not for that :

The aerodynamics uses KSP FloatCurve, which are themselves based on Unity AnimationCurve. AnimationCurve is implemented in native code and seems to include some kind of caching logic that is not thread safe. So when MJ calls the curves from a thread it sometimes get a value from a call of the main KSP thread doing its work, and the main KSP thread gets a value intended for MJ's thread. So the game simulation get crazy result and some of your vessel part explode randomly from overheat when KSP aero/heat model get values that have nothing to do with the ship current situation.

The fix for that was not hard and I just created a copy of the Curve for each thread I create. Then I had to duplicate a lot of KSP code to use those for my sim :(

Share this post


Link to post
Share on other sites
No, nothing like that. That part of KSP current code was actually done in a way that would work perfectly for my needs if not for that :

The aerodynamics uses KSP FloatCurve, which are themselves based on Unity AnimationCurve. AnimationCurve is implemented in native code and seems to include some kind of caching logic that is not thread safe. So when MJ calls the curves from a thread it sometimes get a value from a call of the main KSP thread doing its work, and the main KSP thread gets a value intended for MJ's thread. So the game simulation get crazy result and some of your vessel part explode randomly from overheat when KSP aero/heat model get values that have nothing to do with the ship current situation.

The fix for that was not hard and I just created a copy of the Curve for each thread I create. Then I had to duplicate a lot of KSP code to use those for my sim :(

Argh - a mix with native code... that's a problem of course. If there are not too many operations on this specific class have you considered wrapping it (well - the instances of it of course) and use delegates to make sure the actual main thread is doing the work? But I guess that's exactly the problem: you need to calculate a lot of values all the time.

PM me in case you think I can help with multithreading in .NET. I don't have experience with Unity, though.

Share this post


Link to post
Share on other sites
ERMERGERD it updated!

Thanyou Kobymaru!

All Thanks, Reputation and Kudos towards Youen and atomicfury for this update please! I didn't move a finger.

Share this post


Link to post
Share on other sites

Hang in there man. I'm waiting on this before I plan any interplanetary aerobreaking missions. The crew is becoming more familiar with Kerbins aero forces and planning more atmospheric missions. Jeb has expressed to me that he has plenty to do on the interim. So no rush. Val is the one who is being impatient but I'll have a chat with her. Young hotshot impatient pilots, amiright?

Share this post


Link to post
Share on other sites

With the new system, the shape of the craft greatly impacts reentry. If you set up the reentry node or just do your retro burn, then dump the engine to expose the heat shield for reentry, the mass and shape of the craft has greatly changed and the prediction is wrong. Maybe we could get a way to note which stage the craft will be at for reentry or aerobrake?

Share this post


Link to post
Share on other sites
With the new system, the shape of the craft greatly impacts reentry. If you set up the reentry node or just do your retro burn, then dump the engine to expose the heat shield for reentry, the mass and shape of the craft has greatly changed and the prediction is wrong. Maybe we could get a way to note which stage the craft will be at for reentry or aerobrake?

This is something we'd all like, but there's been several discussions that it's exceedingly difficult to make this happen, sooo I wouldn't expect it any time soon.

Share this post


Link to post
Share on other sites

[*]It works with stock aerodynamics (although stock wings are not simulated) and FAR/NEAR

Stock aerodynamics are not yet supported.

Uhh, so... Then what is this supposed to work with?

Share this post


Link to post
Share on other sites
Uhh, so... Then what is this supposed to work with?

*facepalm. FAR, for now. Apparently FAR is still super popular.

Share this post


Link to post
Share on other sites

Why does the thread title indicate this is a 1.0.2 compatible version but the links goe to only a 0.90 compatible version of the mod?

This is very confusing and maybe the first post title should get changed to [0.90] ... ?

The previous three posts are an indication of the confusion the title is causing.

Edited by ctbram

Share this post


Link to post
Share on other sites
Why does the thread title indicate this is a 1.0.2 compatible version but the links goe to only a 0.90 compatible version of the mod?

This is very confusing and maybe the first post title should get changed to [0.90] ... ?

The previous three posts are an indication of the confusion the title is causing.

Well - all it takes is reading the OP where it indicates

  • Stock aerodynamics are not yet supported.

This mod is 1.0.2 compatible provided you read the post and understand that it only supports FAR atm. Alternatively, the .90 version is not compatible at all with either stock or FAR and therefore it is titled appropriately so long as someone takes the 2 seconds to read the opening line. Moreover, the CKAN thread is NOT updated yet intentionally to keep people from trying to grab this mod WITHOUT reading the post where it indicates it only works with FAR. If CKAN were updated, many people would d/l this and then come crying in the thread about it not working without even bothering to try and read. All this information I have just relayed is mentioned over the last couple of pages of this thread so it just takes the time to read the thread and all is plainly apparent.

RTFM wins every time.

Share this post


Link to post
Share on other sites
Uhh, so... Then what is this supposed to work with?

Thanks, I changed it to make it more clear.

Why does the thread title indicate this is a 1.0.2 compatible version but the links goe to only a 0.90 compatible version of the mod?

There is a Beta-version on GitHub, that does at least load in 1.0.2 and works but only if you need FAR. KerbalStuff doesn't get Beta versions.

This is very confusing and maybe the first post title should get changed to [0.90] ... ?

The previous three posts are an indication of the confusion the title is causing.

You are right. What do the developers think about thist? Youen, Should I change it back to[0.90] for now?

Share this post


Link to post
Share on other sites

Not to be a debbie downer, but yeah, I agree that saying it is compatible with 1.0 (with the subtitle: atmospheric predictions) is misleading since it doesn't work with stock, which is the basis for compatibility.

A large portion of users are not concerned that FAR works.

It'd be kinda like updating ForScience to "1.0", but only DMagic's custom science experiments function properly, and none of the stock experiments.

Or if hotrockets was updated, but only KW and B9 parts work.

Edited by WaveFunctionP

Share this post


Link to post
Share on other sites

I'd change the thread title to include something like 1.0.2 (FAR req'd.) or (FAR only)

Also, if you have a link to Trajectories v1.2.0, but the title says [0.90], then people will assume that v1.2.0 is the version to use for KSP 0.90. I presume that v1.1.3 is still the latest for 0.90, right?

@WaveFunctionP: Not really, it just adds a temporary dependency that wasn't there before. For example, KAS requires KIS. FAR and DRE require ModularFlightIntegrator. Many mods require ModuleManager. Some dependencies are packaged with the mod, others aren't.

No big, except that people who don't read the whole OP (or otherwise keep up on the thread) might not realize that the dependency is there (which I understand, because they might have previous expectations).

Share this post


Link to post
Share on other sites

While it does give you some information where you'll splash down it isn't very correct. I'm using FAR and this mod & Deadly Reentry.

1st - Decoupler changes your trajectory, obviously something that you'll have to take into account for yourself right now.

2nd - As I was doing a re-entry and entering the atmosphere the X started to slowly move left as my craft slowed down and as Kerbin rotated so it doesn't seem to be very accurate. But this might be because I'm using FAR 0.15.2 while this mod supports 0.15.1.

Share this post


Link to post
Share on other sites

Koby I suggest thread title: [1.0.2] Trajectories v1.2.0 : atmospheric predictions [FAR required for now while we fix Stock]

Share this post


Link to post
Share on other sites
While it does give you some information where you'll splash down it isn't very correct. I'm using FAR and this mod & Deadly Reentry.

1st - Decoupler changes your trajectory, obviously something that you'll have to take into account for yourself right now.

2nd - As I was doing a re-entry and entering the atmosphere the X started to slowly move left as my craft slowed down and as Kerbin rotated so it doesn't seem to be very accurate. But this might be because I'm using FAR 0.15.2 while this mod supports 0.15.1.

Make sure to check the descent profile on the Trajectories menu. If you're re-entering, for example, with your ship in retrograde, check that box and the mod will recalculate.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.