Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration of Trajectories aerodynamic prediction mod #2137

Closed
fat-lobyte opened this issue Apr 17, 2019 · 4 comments
Closed

Integration of Trajectories aerodynamic prediction mod #2137

fat-lobyte opened this issue Apr 17, 2019 · 4 comments

Comments

@fat-lobyte
Copy link

Hey there!
I was wondering, is it possible to adapt the Trajectories mod and Principia so they can work together?
What that mod does is calculating forces based on the aerodynamic configuration and on pressure/velocity of the atmosphere and integrate it into a flight path.

We have our own (quite primitive) integrator and trajectory renderer, but I think when using Principia it would be nice to just use Principias facilities and just provide the forces that are added on top your gravitational forces and used for the predicted trajectory (only when enabled by the user manually with a toggle, of course).

One potential issue I can see is that Trajectories is a C# plugin, wheres almost everything in Principia is in C++, so I don't know how the communication could work here.

Is that something in the realm of possibilities?

@eggrobin
Copy link
Member

Is that something in the realm of possibilities?

I don’t really think so, unfortunately.

First we have the UX/UI aspect: Principia ultimately tries to provide something that should be redundant with Trajectories, in that both show predicted trajectories in the body-centred, body-fixed reference frame; having both at the same time is likely to be a visual mess.

I think the right solution here for the UX question would be to make Principia’s orbit plotting better: Principia needs to plot orbits no matter what happens, even outside of landing situations, so it should handle that case as well.
However, it should not draw orbits below the horizon when there are mountains on the horizon, and it should find the point of impact and probably mark it on the map.

There remains the question of aerodynamics. We can, in theory, handle aerodynamics; in fact, we do (since Δημόκριτος) when you are flying in the atmosphere: as soon as you leave the ground, the movement of the vessel is the result of Principia’s integration, which takes FAR’s (and the stock model’s) contributions into account.

The problem is of course to predict the aerodynamic forces.

it would be nice to just use Principias facilities and just provide the forces that are added on top your gravitational forces and used for the predicted trajectory

This is technically infeasible (I do not want to even think about calling C# from the depths of our C++ integrator), unless we have a standardized analytic model for aerodynamic forces, whose parameters could then be interchanged.

At the moment, Principia does not handle vessel orientation, so it would not be able to use anything more elaborate than a “cannonball” model.
We have plans to handle orientation (a bit like PersistentRotation, but correctly handling Euler’s equations for rigid body motion), but it will be many months before this bears fruit.

@fat-lobyte
Copy link
Author

Thank you for your feedback!

First we have the UX/UI aspect: Principia ultimately tries to provide something that should be redundant with Trajectories, in that both show predicted trajectories in the body-centred, body-fixed reference frame; having both at the same time is likely to be a visual mess.

I wasn't suggesting to do both, I was suggesting to use Principia's plotting mechanism.

which takes FAR’s (and the stock model’s) contributions into account.

But that is only for the current flight, not the predicted path, correct?

This is technically infeasible (I do not want to even think about calling C# from the depths of our C++ integrator),

I was thinking more along the lines of trajectories writing into a buffer, and Principia reading from it.

unless we have a standardized analytic model for aerodynamic forces, whose parameters could then be interchanged.

That's probably not going to happen. Force calculation in Trajectories is dependent on KSP-internal functions and uses the static's (like FlightGlobals) of the game. This also forces it to run on the main thread. Finding a standardized analytic aerodynamic model would be akin to implementing a new FAR.

At the moment, Principia does not handle vessel orientation

Trajectories doesn't calculate motion, but it has a setting so the user can input their "desired" orientation.

So this way is probably not going to happen. What about the other way around? Is it possible for Trajectories to get out the future positions/velocities (space) and the acceleration due to gravity (atmosphere) from Principia?

@eggrobin
Copy link
Member

eggrobin commented Apr 27, 2019

But that is only for the current flight, not the predicted path, correct?

Indeed.

Finding a standardized analytic aerodynamic model would be akin to implementing a new FAR.

I don’t think this is the case for our purposes.

I just discussed this with @ferram4: when limiting ourselves to reasonable reentry situations (which will mostly involve hypersonic flight), and under the assumption of fixed angle of attack, sideslip, and roll, considering the force as being only a function of the dynamic pressure 𝑄 and Mach number is a usable approximation. This is even mostly linear for fixed Mach number, so an analytic model obtained by a suitable interpolation of the force as a function of 𝑄 and Mach number seems feasible.

Flight at low Mach number is a mess, but if it significantly alters where you land (as opposed to just when you land), your landing site is going to be highly unpredictable no matter what happens.

I think this approach is feasible, but it will be a while before we are ready for it.

What about the other way around? Is it possible for Trajectories to get out the future positions/velocities (space) and the acceleration due to gravity (atmosphere) from Principia?

I don’t think this direction is a possibility.

Just getting the future positions and velocities (the future trajectory) would be a complex API on our side (this means a heavy maintenance burden), and you cannot do much with them anyway, as the future trajectory will change under the influence of aerodynamic forces.

Getting the acceleration due to gravity and integrating it yourself quickly puts you in the position of reimplementing a chunk of Principia, and, perhaps more importantly, means that the plotting will have to happen on your side, bringing back the UX problem of having two trajectories from different mods that say different things (possibly in different reference frames).

@fat-lobyte
Copy link
Author

Fair enough, thanks for taking a look. I'm closing this issue then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants