MechJeb2

MechJeb2

4M Downloads

[Suggestion] Changing LambertSolver

fibonatic opened this issue ยท 5 comments

commented

I am not 100% sure how the LambertSolver calculates the position change within a certain change in time. However I recently worked on an equation which gives the change in time depending on the change in position: http://physics.stackexchange.com/questions/69380/what-are-common-methods-for-calculating-the-time-dependency-of-elliptical-orbit
So the opposite of of what this does. Unfortunately there is no inverse function of this equation, however with newton or secant method it could be done. I am not sure if this would be faster than this LambertSolver, but I would suspect it would since you have an exact equation.

I have confirmed this equation for both circular, elliptical and hyperbolic orbits (e=0, 0<e<1, e>1), however for a parabolic orbit it does not (e=1).

commented

Just answered your question over on stackexchange, all you have is an equivalent version of Kepler's equation, nothing new there. Lambert solvers are specifically designed to deal with this problem. You could hypothetically solve the same problem with a Newton approach, but all of the orbital elements of the transfer orbits are unknowns, so it's a multivariable problem. If that were more efficient in practice, there would be no such thing as a special-purpose Lambert solver.

commented

It's quite alright, orbital mechanics can get pretty complicated.

Yes, those are the correct inputs to a Lambert solver. It can be used in many ways, but almost always as a subroutine of some more useful outer-level calculation. For example, if you want to find a transfer orbit between two planets which are on inclined, eccentric orbits. You know the origin and destination planets' orbits, which can tell you orbital position as a function of time (by numerically solving Kepler's equation with a series expansion, a Newton method, or otherwise). So if you depart planet 1 at time t1 and arrive at planet 2 at time t2, the Lambert solver tells you the transfer orbit required to do so. Comparing the velocity of this transfer orbit at t1 to the orbital velocity of planet 1 at that point, you can calculate hyperbolic excess velocity and from there the departure delta-V. Plotting this departure delta-V versus the departure and arrival times give you what's called a porkchop plot. Play around with http://alexmoon.github.io/ksp to see what porkchop plots look like for KSP planets. The transfer window is given by the departure time of the lowest delta-V point in the porkchop plot.

As far as I've looked through the MechJeb code, it only uses the Lambert solver in a handful of places: the "intercept target at time X" maneuver planner, and in "fine-tune closest approach." The interplanetary transfers in MechJeb are done a little differently, I believe they only calculate an in-ecliptic transfer, and I forget exactly how they determine the time and delta-V to use. It's in OrbitalManeuverCalculator.

commented

I am sorry, I was confused about the purpose of the Lambert solver. I first thought that it was used to determine the displacement on an orbit, during a given time interval. So the inputs are two position vectors (start and end) and the length of the time interval you want and orbit to change position from start to end?
However I do wonder why you would want to use this, since often you do not want an maneuver to happen within a given amount of time, since this way can be very inefficient in therms of fuel consumption.

commented

That makes sense (using it for transfer orbits with an inclined target body) and that tool you linked is very, very nice.
It might also be useful to construct a table of optimal launch windows from Kerbin to all the other planets, since the global game time and position of the planets is the same for everyone.
And I also wonder if it would be possible to incorporate gravity assists into such a program.

commented

I'm not sure if the math capabilities or GUI are quite rich enough in a JavaScript web app to do gravity assists, or if the author of that tool has any plans for extension of its capabilities beyond what it does now.

There is a different tool, not as easy to use since it's written in Matlab and requires a big runtime download to run standalone, being developed here: http://forum.kerbalspaceprogram.com/showthread.php/36476-WIN-KSP-Trajectory-Optimization-Tool-v0-5
It's essentially a higher-featured version of the porkchop plotter, and that author is definitely working on adding gravity assists and other features.