Arrowstar / ksptot

KSP Trajectory Optimization Tool
Other
87 stars 13 forks source link

Mission Architect won't iterate over coast event with anomaly #21

Open 1greywind opened 5 years ago

1greywind commented 5 years ago

KSP TOT version - 1.6.2

Sometimes Mission Architect can't find more or less obvious solution. In attached example Optimizer is unable to find correct true anomaly and prograde dV for transmunar injection trajectory. This bug manifests itself in diffirent situations and only thing that helps is to manually set true anomaly insted of using it as optimization variable.

STR: 1 Setup following scenario:

2 Run optimization

3 Observe how optmization function value does not goes below 11300 km

Expected result: Burn true anomaly after optimization = 140 degree, Maneuver prograde after optimization ~ 840 m\s

ksptot.log bug-wont-iterate-over-true-anomaly.zip

Arrowstar commented 5 years ago

Okay, so I see what you're talking about here. Unfortunately this isn't a bug, it's a matter of how gradient descent optimization works. What you're trying to do is get to the Mun, yes?

The best way to handle this is to use the "revs prior to coast" function on Event 4. Set it to 1. Now try reoptimizing. You should see that you end up with a trajectory that runs right into the Mun. (At least I did when I changed that.)

Here's why this works. Without the coast revs set to 1, when you "go to periapsis" in event 4, you aren't actually moving because after the burn, you are at periapsis already. But what about the "Reference Body" to Mun that we set? This only kicks in if the propagator detects an SoI transition to that body during the coast. If it doesn't find one, then it just stops the first time it hits the target condition (true anom = 0) at any body.

Your initial problem set up prior to optimization probably doesn't intercept the Mun at any point, and so when you say go to periapsis, since you don't move, the optimizer probably seems a local minimum and quits early.

Anyway, I'm going to close this because it's more about software techniques than a bug in the code. Thanks for the reporting though! If you have any questions about this, please let me know. :)

1greywind commented 5 years ago

Well, in this particular case you can add 1, 2, 3 or even 4 revs before coast and this won't solve problem.

Try this. Or I will upload video proof a little later.

Arrowstar commented 5 years ago

A video might be helpful. I was able to get a Mun intercept with no problem, but that may be because I'm familiar with the tool. It would be good to see what you're doing.

1greywind commented 5 years ago

In this video I try to add 1 rev before coast, when 3, when 5: http://recordit.co/ibEAfMxCdm

1greywind commented 5 years ago

A video might be helpful. I was able to get a Mun intercept with no problem, but that may be because I'm familiar with the tool. It would be good to see what you're doing.

I'm on KSP TOT 1.6.2 on Windows 7 x64. MCR version is 2017b.

I can get Mun intercept most times, but this example illustrates problem, that manifests itself in different situations. It is just simplest case.

Arrowstar commented 5 years ago

Oh hey, I see. You need to add the rev before the coast to the Coast after the maneuver, Event 4. :)

Let me know how that works for you.