Jump to content

[WIN/MAC/LINUX] KSP Trajectory Optimization Tool v1.6.9 [New MATLAB Version!]


Recommended Posts

Hi everyone!

This evening I am happy to announce the release of KSP Trajectory Optimization Tool v0.12! Here's a quick overview of the changes:

  • Version 0.12
  • New Application: KSP TOT Mission Architect
    • Allows for the planning of complete missions from Kerbin injection orbit to anywhere in the solar system.
    • Plan ballistic trajectories, gravity assist maneuvers, injection orbits and more using the same basic orbital mechanics and patched conics system that KSP uses! No more infinitesimal sphere of influence approximations to ruin your burn planning.
    • Tracks spacecraft mass and fuel usage so you ensure you always have enough fuel to return to Kerbin.
    • Built in mission optimizer can goal seek to target celestial bodies, minimize fuel usage, or hit inclination/eccentricity targets -- all optimally.
    • Full orbit visualization means that you'll know precisely where you're going and how you're going to get there.
    • Mission state log provides the complete spacecraft state at effectively any point along the mission, from initial get-go to the final injection burn.
    • And more!

    [*]Improvements to the astrodynamics code:

    • Orbit propagation code has been vectorized to allow for faster execution.
    • Orbit RV/Keplerian conversion has been vectorized for MUCH faster execution. Code is also far more robust!

    [*]Improvements/fixes to the rendezvous application.

I just kinda buckled down today and finished off the one major bug that was standing between me and release. ALSO: people were shouting for a Mission Architect tutorial, so I created one! It's with the download package in PDF format: "From Kerbin to Laythe." Check it out and tell me what you think. :)

I'd really appreciate feedback on the new Mission Architect, as it's a completely new tool and very complex compared to everything else. Please let me know your thoughts. If you find bugs, I need to hear about those too. And if you like it, I'd like to hear that, too. ;)

Download link is the same and located in the OP.

Oh, I have a graphics art request for this fine community. If anyone has any skill with graphics applications, could I ask you a favor? I'd like to take the 6-8 images of the application I have in the OP and condense them down into a single, nice-looking collage. Would someone be willing to help with that? If so, please PM me. Thanks! :)

Thanks, everyone, and happy orbiting!

Link to comment
Share on other sites

[Sun]
epoch = 0
sma = 0
ecc = 0
inc = 0
raan = 0
arg = 0
mean = 0
gm = 117230471000
radius = 696342
atmoHgt = 0
bodycolor = hot
canBeCentral = 1
canBeArriveDepart = 0
parent =
name = Sun
id = 0

[Moho]
epoch = 0
sma = 52621383.047
ecc = 0.20563
inc = 7.005
raan = 70.331
arg = 15.194
mean = 179.908747671079
gm = 16860.5338
radius = 2498.9281975
atmoHgt = 0
bodycolor = gray
canBeCentral = 0
canBeArriveDepart = 1
parent = Sun
name = Moho
id = 4

[Eve]
epoch = 0
sma = 98326845.441
ecc = 0.01
inc = 2.1
raan = 15.168
arg = 0
mean = 179.908747671079
gm = 817153.445
radius = 6995.09428346
atmoHgt = 220
bodycolor = cool
canBeCentral = 0
canBeArriveDepart = 1
parent = Sun
name = Eve
id = 5

[Gilly]
epoch = 0
sma = 314987.761
ecc = 0.55
inc = 12.43
raan = 80
arg = 10
mean = 51.5662016
gm = 0.828925098
radius = 130.06474824
atmoHgt = 0
bodycolor = gray
canBeCentral = 0
canBeArriveDepart = 1
parent = Eve
name = Gilly
id = 13

[Kerbin]
epoch = 0
sma = 135998402.561
ecc = 0
inc = 0
raan = 0
arg = 0
mean = 179.908747671079
gm = 353151.536
radius = 5999.92809976
atmoHgt = 104
bodycolor = winter
canBeCentral = 1
canBeArriveDepart = 1
parent = Sun
name = Kerbin
id = 1

[Mun]
epoch = 0
sma = 120000
ecc = 0
inc = 0
raan = 0
arg = 0
mean = 97.4028252
gm = 65.138398
radius = 1999.05496077
atmoHgt = 0
bodycolor = gray
canBeCentral = 0
canBeArriveDepart = 1
parent = Kerbin
name = Mun
id = 2

[Minmus]
epoch = 0
sma = 47000.000
ecc = 0
inc = 6
raan = 78
arg = 38
mean = 51.5662016
gm = 176.575771
radius = 599.6944232
atmoHgt = 0
bodycolor = cool
canBeCentral = 0
canBeArriveDepart = 1
parent = Kerbin
name = Minmus
id = 3

[Duna]
epoch = 0
sma = 207261552.641
ecc = 0.05
inc = 0.06
raan = 135.5
arg = 0
mean = 179.908747671079
gm = 30135.591
radius = 3201.63228989
atmoHgt = 154
bodycolor = autumn
canBeCentral = 0
canBeArriveDepart = 1
parent = Sun
name = Duna
id = 6

[Ike]
epoch = 0
sma = 32000.109
ecc = 0.03
inc = 0.2
raan = 0
arg = 0
mean = 97.4028252
gm = 1856.79236
radius = 1299.24345118
atmoHgt = 0
bodycolor = gray
canBeCentral = 0
canBeArriveDepart = 1
parent = Duna
name = Ike
id = 7

[Dres]
epoch = 0
sma = 408393482.03
ecc = 0.14
inc = 5.0
raan = 280
arg = 90
mean = 179.908747671079
gm = 2148.39732
radius = 1378.86990408
atmoHgt = 0
bodycolor = gray
canBeCentral = 0
canBeArriveDepart = 1
parent = Sun
name = Dres
id = 15

[Jool]
epoch = 0
sma = 687735603.202
ecc = 0.049675
inc = 1.304
raan = 52
arg = 0
mean = 5.72957795
gm = 28252123.3
radius = 59992.356201
atmoHgt = 374
bodycolor = gray
canBeCentral = 1
canBeArriveDepart = 1
parent = Sun
name = Jool
id = 8

[Laythe]
epoch = 0
sma = 271840
ecc = 0
inc = 0
raan = 0
arg = 0
mean = 179.908747671079
gm = 196195.299
radius = 4999.36301675
atmoHgt = 415
bodycolor = winter
canBeCentral = 0
canBeArriveDepart = 1
parent = Jool
name = Laythe
id = 9

[Vall]
epoch = 0
sma = 431520
ecc = 0
inc = 0
raan = 0
arg = 0
mean = 51.5662016
gm = 20747.6525
radius = 2996.9789984
atmoHgt = 0
bodycolor = winter
canBeCentral = 0
canBeArriveDepart = 1
parent = Jool
name = Vall
id = 10

[Tylo]
epoch = 0
sma = 685000
ecc = 0
inc = 0.025
raan = 0
arg = 0
mean = 179.908747671079
gm = 282521.233
radius = 6031.00270523
atmoHgt = 0
bodycolor = gray
canBeCentral = 0
canBeArriveDepart = 1
parent = Jool
name = Tylo
id = 10

[Bop]
epoch = 0
sma = 1285000
ecc = 0.24
inc = 15.04
raan = 10
arg = 25
mean = 51.5662016
gm = 248.677529
radius = 649.77923637
atmoHgt = 0
bodycolor = gray
canBeCentral = 0
canBeArriveDepart = 1
parent = Jool
name = Bop
id = 11

[Pol]
epoch = 0
sma = 1798899.946
ecc = 0.170
inc = 5.25
raan = 2.0
arg = 15.0
mean = 51.5662016
gm = 0.721684565
radius = 43.987022214
atmoHgt = 0
bodycolor = gray
canBeCentral = 0
canBeArriveDepart = 1
parent = Jool
name = Pol
id = 14

[Eeloo]
epoch = 0
sma = 901188200.009
ecc = 0.26
inc = 6.15
raan = 50
arg = 260
mean = 179.908747671079
gm = 7440.90314
radius = 2098.33429289
atmoHgt = 0
bodycolor = gray
canBeCentral = 0
canBeArriveDepart = 1
parent = Sun
name = Eeloo
id = 16

This is what I have now, and I'm getting reasonable results only for Eve and Duna. Any ideas?

Hey, did you guys ever get this to work?

Link to comment
Share on other sites

Really happy to find the new version released :). Even more happy to find a tutorial for Mission Architect with it :):).

I started doing exactly as the tutorial explains. At step 8, after inserting the constraints and starting the optimizer, there is a first pass but then it stops with an error message:

"There was an error optimizing the mission script: Attempted to access eventLog(0,: ); index must be a positive integer or logical." :( Tried again and again, same result.

Unfortunately, there is no log saved in this instance (a log was saved when the optimizer succeeded with the intercept of Laythe, step 7; but nothing saved about step 8).

Attached the saved MA plan I did following instructions up to step 8. Hope that shows something. Running Windows 8, 64 bit, MCR R2013a (8.1) 32 bit.

Link to comment
Share on other sites

Has anyone got 0.12 to work with 23.5 ?

I got the same error as before and i am wondering if its a problem on my side or just something with the program.

Seems it works at random now.

Edited by Daisai
Link to comment
Share on other sites

Has anyone got 0.12 to work with 23.5 ?

I got the same error as before and i am wondering if its a problem on my side or just something with the program.

Yes, it works fine for me (KSP TOT v0.12, KSP 0.23.5.464). Just out of the box, no need to change any parameter in my case, only to allow my firewall to open ports for both the KSP TOT and the TOT Connect (seen as KSP.exe, being a plugin to that).

Could it be your private network is configured with different IP numbering than standard? (In case, the IPAddressWhitelist.txt should include those valid for your PC).

Link to comment
Share on other sites

Arrowstar, another (small) issue.

As of KSP 0.23.5, Time can be changed from "Earth" days (24hrs, 365 in a year) to "Kerbin" days (6hrs, 426 in a year).

KSP TOT shows only "Earth" days, would be nice to allow it to show "Kerbin" days too, for users who prefer that unit in game.

Link to comment
Share on other sites

Really happy to find the new version released :). Even more happy to find a tutorial for Mission Architect with it :):).

I started doing exactly as the tutorial explains. At step 8, after inserting the constraints and starting the optimizer, there is a first pass but then it stops with an error message:

"There was an error optimizing the mission script: Attempted to access eventLog(0,: ); index must be a positive integer or logical." :( Tried again and again, same result.

Unfortunately, there is no log saved in this instance (a log was saved when the optimizer succeeded with the intercept of Laythe, step 7; but nothing saved about step 8).

Attached the saved MA plan I did following instructions up to step 8. Hope that shows something. Running Windows 8, 64 bit, MCR R2013a (8.1) 32 bit.

Thanks!

Your issue is, at first, fairly obvious. You have a bunch of NaN in your state log, which means that something isn't getting propagated correctly. This is probably causing the issue you see. Problem, of course, is that I'm not sure why it's happening. I'll need some time to investigate. Thanks for the report. :)

Link to comment
Share on other sites

Arrowstar, another (small) issue.

As of KSP 0.23.5, Time can be changed from "Earth" days (24hrs, 365 in a year) to "Kerbin" days (6hrs, 426 in a year).

KSP TOT shows only "Earth" days, would be nice to allow it to show "Kerbin" days too, for users who prefer that unit in game.

Yep, an interesting suggestion. A quick survey of my code shows that the date/time format is pretty deeply embedded in many places. I never expected to have to be able to change that, so I didn't build in any mechanisms to do so. Don't think I'll be able to make much progress here... :/

Link to comment
Share on other sites

Really happy to find the new version released :). Even more happy to find a tutorial for Mission Architect with it :):).

I started doing exactly as the tutorial explains. At step 8, after inserting the constraints and starting the optimizer, there is a first pass but then it stops with an error message:

"There was an error optimizing the mission script: Attempted to access eventLog(0,: ); index must be a positive integer or logical." :( Tried again and again, same result.

Unfortunately, there is no log saved in this instance (a log was saved when the optimizer succeeded with the intercept of Laythe, step 7; but nothing saved about step 8).

Attached the saved MA plan I did following instructions up to step 8. Hope that shows something. Running Windows 8, 64 bit, MCR R2013a (8.1) 32 bit.

Alright, can you try again with this (hopefully fixed) version? It's just the executable, so drag, drop, and replace the official 0.12 executable. Let me know if you get the same error. I wasn't able to reproduce it on my end anymore.

Link to comment
Share on other sites

Alright, can you try again with this (hopefully fixed) version? It's just the executable, so drag, drop, and replace the official 0.12 executable. Let me know if you get the same error. I wasn't able to reproduce it on my end anymore.

Same thing, still the optimizer stops with that error.

Hope the following might be useful: I restarted the MA plan with step 7 (removed constraints, Optimizer works fine). Then reentered the constraints for step 8, but only distance to body and periapsis, not the inclination. Now the optimizers runs for 4 iterations, then stops (same error). The inclination constraint alone does nothing (optimizer does one step, outputs same solution as before, going right to the CoM of Laythe), no error. Only inclination + periapsis constraints (not distance to body), error at the first iteration. Only inclination + distance to body (not periapsis), error at first iteration (I know skipping constraints does not make for a good plan).

I want to ask if the MCR version is a strict dependency for KSP TOT. Would it work if I install version R2014a (8.3) 64 bit on my PC?

In case there is no strict dependency, I would like to test again with that other MCR.

Link to comment
Share on other sites

Same thing, still the optimizer stops with that error.

Hope the following might be useful: I restarted the MA plan with step 7 (removed constraints, Optimizer works fine). Then reentered the constraints for step 8, but only distance to body and periapsis, not the inclination. Now the optimizers runs for 4 iterations, then stops (same error). The inclination constraint alone does nothing (optimizer does one step, outputs same solution as before, going right to the CoM of Laythe), no error. Only inclination + periapsis constraints (not distance to body), error at the first iteration. Only inclination + distance to body (not periapsis), error at first iteration (I know skipping constraints does not make for a good plan).

Huh. I've been unable to reproduce your problem, to be honest. Can I get a screenshot of your Optimization window? The one where you enter the constraints? Is the MA plan you linked to above still the one causing issues? I'll investigate more when I get home from work and perhaps put together a debug version for you to try.

I want to ask if the MCR version is a strict dependency for KSP TOT. Would it work if I install version R2014a (8.3) 64 bit on my PC?

In case there is no strict dependency, I would like to test again with that other MCR.

As far as I know, it is, but I've never tried with anything other than either A) a full version of MATLAB or B) the version of the MCR I link to in my OP. Please feel free to test, though, I'd be interested in hearing what happens. I'd also be interested in you trying the 2013a 64-bit version if the 2014 version does not work.

Link to comment
Share on other sites

Huh. I've been unable to reproduce your problem, to be honest. Can I get a screenshot of your Optimization window? The one where you enter the constraints? Is the MA plan you linked to above still the one causing issues? I'll investigate more when I get home from work and perhaps put together a debug version for you to try.

Sure. Here are screenshots of:

1. Optimizer Constraints

1.1 Central Body

1.2 Inclination

1.3 Radius of Periapsis

2. Optimizer Window (just when 1st iteration is done, a moment before the error comes)

3. Error Message Dialog

This all with the same MA plan, the one I linked before.

As far as I know, it is, but I've never tried with anything other than either A) a full version of MATLAB or B) the version of the MCR I link to in my OP. Please feel free to test, though, I'd be interested in hearing what happens. I'd also be interested in you trying the 2013a 64-bit version if the 2014 version does not work.

Going to try R2013a 64-bit, then R2014a 64-bit. Will take a bit of time, will report afterwards.

Link to comment
Share on other sites

As far as I know, it is, but I've never tried with anything other than either A) a full version of MATLAB or B) the version of the MCR I link to in my OP. Please feel free to test, though, I'd be interested in hearing what happens. I'd also be interested in you trying the 2013a 64-bit version if the 2014 version does not work.

Well, tried both R2013a (8.1) and R2014a (8.3) 64-bit. No joy, KSP TOT shows this; is happy only when R2013a (8.1) 32-bit is found.

Link to comment
Share on other sites

I think even if it recognized the 64 bit MCR it still wouldn't run because the solveKepler.mexw32 is compiled for 32bit Matlab. This is what stops me from running the source code on my 64bit version of Matlab at least.

I also had to create this account to thank the author of this tool. I was working on orbit solvers myself in Matlab and I'm glad you've taken it way farther than I ever probably would have.

Link to comment
Share on other sites

Sure. Here are screenshots of:

1. Optimizer Constraints

1.1 Central Body

1.2 Inclination

1.3 Radius of Periapsis

2. Optimizer Window (just when 1st iteration is done, a moment before the error comes)

3. Error Message Dialog

This all with the same MA plan, the one I linked before.

Alright, I've added a bunch of debug output at the point where you're encountering the error. Here's what I need from you:

  1. Run the debug version of KSP TOT MA in this ZIP file.
  2. Check the "ksptotlog.txt" file for debug out immediately upon seeing the error. (The log clears every time you restart the application.)
  3. Provide me the error text from ksptotlog.txt here.
  4. Provide me a screenshot of the Mission Optimizer status window at the time of the error. This is the screenshot that shows the variable values, the objective function value, and constraint value graphs.

Finally, I need help reproducing the issue on my end. I've taken your save file and tried to make it give the same error you're seeing, but I can't figure out how. What I need you to do is load up Mission Architect, load the case file you linked to a few posts up, and then give me step by step (or button click by button click :)) instructions on how to reproduce the error.

Once I see what's causing the error from your log output and I can reproduce it here using your steps, I should be able to fix it quickly. :) Btw, no need to do all that at once. If you want to just get me the log output or the reproduction steps first, that's fine.

Thanks!

(EDIT: The debug version of KSP TOT I'm providing has 0.12.1 features for MA built-in, most of which are finished. You're going to notice some new things. Don't be alarmed. :wink:)

Well, tried both R2013a (8.1) and R2014a (8.3) 64-bit. No joy, KSP TOT shows this; is happy only when R2013a (8.1) 32-bit is found.

Yeah, I was afraid of that. MATLAB is finicky like that. Thanks for the try though! Much appreciated! :)

Edited by Arrowstar
Link to comment
Share on other sites

Arrowstar: please find here:

- screenshot of KSP TOT (debug) after loading the plan (it is giving something as warnings, that did not appear with other versions);

- screenshot of the optimizer status window after 1st iteration, just before the error;

- KSPTOTlog file (I see it registered the error).

Step-by-step:

- Launch KSPTOT;

- Reenter Kerbin-Jool for transfer window;

- Compute Porkchop Plot;

- Compute Departure Burn (setting SMA=700 Km as initial orbit);

- Open Mission Architect;

- Load saved Plan (the exact file I sent and you tried);

- Open the Optimizer;

- with Variables, select "Event 4: To Laythe"

(I double click on each constraint, to check those are the ones actually in the plan, and match with your tutorial step 8; they are actually matching)

- click "Optimize Mission"

(Optimizer Status Window opens, runs first iteration, outputs error.)

Link to comment
Share on other sites

I think even if it recognized the 64 bit MCR it still wouldn't run because the solveKepler.mexw32 is compiled for 32bit Matlab. This is what stops me from running the source code on my 64bit version of Matlab at least.

Many thanks for that info. I am not fluent with MatLab, but was thinking at some possibilities to compile KSPTOT in a 64bit version. I would have wasted my time (and money if required) not knowing this.

Link to comment
Share on other sites

Arrowstar: please find here:

- screenshot of KSP TOT (debug) after loading the plan (it is giving something as warnings, that did not appear with other versions);

- screenshot of the optimizer status window after 1st iteration, just before the error;

- KSPTOTlog file (I see it registered the error).

The errors messages you are seeing aren't really errors. They're alerts to you, the analyst, that your plan may have some flaws, such as slamming into a planet or running out of fuel. :) They are new for v0.12.1 and you can ignore them for now.

Step-by-step:

- Launch KSPTOT;

- Reenter Kerbin-Jool for transfer window;

- Compute Porkchop Plot;

- Compute Departure Burn (setting SMA=700 Km as initial orbit);

- Open Mission Architect;

- Load saved Plan (the exact file I sent and you tried);

- Open the Optimizer;

- with Variables, select "Event 4: To Laythe"

(I double click on each constraint, to check those are the ones actually in the plan, and match with your tutorial step 8; they are actually matching)

- click "Optimize Mission"

(Optimizer Status Window opens, runs first iteration, outputs error.)

So I did precisely this and I still couldn't reproduce the error. I do see that the problem appears to be in the central body constraint, or at least it's getting registered there. The actual problem is probably outside of that function and inside the propagation code somewhere.

Can you try removing the central body constraint and try again? If that doesn't work, remove constraints one at a time (top to bottom) until it does work. Let me know what you find.

Link to comment
Share on other sites

I also had to create this account to thank the author of this tool. I was working on orbit solvers myself in Matlab and I'm glad you've taken it way farther than I ever probably would have.

Thanks! It's been a fun journey. Let me know if you have any questions when using KSP TOT. :)

Link to comment
Share on other sites

Arrowstar: please find here:

- screenshot of KSP TOT (debug) after loading the plan (it is giving something as warnings, that did not appear with other versions);

- screenshot of the optimizer status window after 1st iteration, just before the error;

- KSPTOTlog file (I see it registered the error).

Step-by-step:

- Launch KSPTOT;

- Reenter Kerbin-Jool for transfer window;

- Compute Porkchop Plot;

- Compute Departure Burn (setting SMA=700 Km as initial orbit);

- Open Mission Architect;

- Load saved Plan (the exact file I sent and you tried);

- Open the Optimizer;

- with Variables, select "Event 4: To Laythe"

(I double click on each constraint, to check those are the ones actually in the plan, and match with your tutorial step 8; they are actually matching)

- click "Optimize Mission"

(Optimizer Status Window opens, runs first iteration, outputs error.)

Okay, can you try this debug version before doing what I asked above? I added another set of debug statements at the place where I *think* the problem is. Just do what you did before, make the error appear, and send me the ksptotlog here. :) Thanks!

Link to comment
Share on other sites

Can you try removing the central body constraint and try again? If that doesn't work, remove constraints one at a time (top to bottom) until it does work. Let me know what you find.

Removed the Central Body constraint: still error after first iteration (KSPTOT log);

Removed also Inclination constraint (only periapsis left in): Optimizer has solution after first iteration (if I launch the optimizer again, it looks for new solutions, making more iterations but no error) (Screenshot of MA with solution; KSPTOT log is not updated, still have the one with the last error).

About the central body, that is making me guess if the PC locale may have some role with this error (I found that was the culprit with other tools, those had to be recompiled so to be working with any national setting). My PC is set to work so to display numbers with point delimiting thousands, comma delimiting decimals (just the opposite of what the locale states for US).

The "bodies.ini" file is created with US locale setting. I have now tried editing that file for Jool and Laythe (Sun is already invariant):

- by putting commas instead of points, and

- by removing any decimal part.

In both cases, the optimizer (with all three constraints set) completes just one iteration and gives a solution (though a wrong one), but never stops with an error.

Hope the above makes sense and helps isolate the issue.

Link to comment
Share on other sites

Yeah, that's interesting actually. (Yes, the bodies.ini file uses US notation, as that's where I'm from. :)) I'll investigate.

Did you try the second debug version? The one with additional output? Anything to report there?

Link to comment
Share on other sites

Well here's the problem:

################## Propagation Error ###################

Event Num: 4

Error Msg: Searching for SoI transition failed: initial state is already outside central body SoI.

#########################################################

It could be related to your locale settings. What PC locale are you using, if I can ask? I'll try changing my PC to the same and reproducing.

Link to comment
Share on other sites

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...