Jump to content

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


Recommended Posts

I'm experiencing what seems to be a bug, but also seems incredibly unlikely to actually be a bug. When I generate a trajectory, the time listed in seconds for the maneuver seems to be wrong.

 211122022-4c686f11-77c3-40f5-b776-a69ea0

Here it displays it as year 41,

211122636-e07584ae-44f6-4869-b51e-451ee7

But after uploading the maneuver, it displays a year significantly later. Am I doing something wrong?

Link to comment
Share on other sites

2 minutes ago, Horizons Aerospace said:

I'm experiencing what seems to be a bug, but also seems incredibly unlikely to actually be a bug. When I generate a trajectory, the time listed in seconds for the maneuver seems to be wrong.

 211122022-4c686f11-77c3-40f5-b776-a69ea0

Here it displays it as year 41,

211122636-e07584ae-44f6-4869-b51e-451ee7

But after uploading the maneuver, it displays a year significantly later. Am I doing something wrong?

Can you take a screenshot of the maneuver upload display dialog box?

Link to comment
Share on other sites

2 minutes ago, Horizons Aerospace said:

211123978-3d2a3f0e-9092-4445-9226-f11396

So it looks like you're in year 33 in game but the trajectory solution you have is in year 41.  I would expect to see a very long wait until the burn because of that. 

The other thing you could be experiencing is that KSPTOT can use two time systems: Earth time and Kerbin time.  You might have those set to different things between KSP and KSPTOT.

Link to comment
Share on other sites

  • 3 weeks later...

I realise this has been asked before, but it was only done quite a few years ago - if development on this is still active, would it be possible to utilise GPU acceleration for the optimiser, such as OpenCL? Especially when the population and iteration numbers have been set to high values, it'd cut down a significant amount of time.

Link to comment
Share on other sites

Just now, Regor said:

I realise this has been asked before, but it was only done quite a few years ago - if development on this is still active, would it be possible to utilise GPU acceleration for the optimiser, such as OpenCL? Especially when the population and iteration numbers have been set to high values, it'd cut down a significant amount of time.

Hey there!

Yes, development on KSPTOT is still active.  I don't have any major things I'm working on now, but a lot of that is just other things going on in life. 

Unfortunately, there are some incompatibilities that prevent me from allowing GPU compute in KSPTOT.  First and foremost, MATLAB only supports CUDA, so it's not possible to use OpenCL.  Second, the way the trajectory propagation code is put together doesn't really support GPU compute in general, since it's mostly object oriented work.  And third, I'm not actually convinced that CPU compute would speed up trajectory optimization, since optimization problems aren't really massively parallel in the same way that linear algebra can be.

I hope that helps!  Let me know if you have any thoughts about this or any other questions. :)

Link to comment
Share on other sites

3 minutes ago, Arrowstar said:

Hey there!

Yes, development on KSPTOT is still active.  I don't have any major things I'm working on now, but a lot of that is just other things going on in life. 

Unfortunately, there are some incompatibilities that prevent me from allowing GPU compute in KSPTOT.  First and foremost, MATLAB only supports CUDA, so it's not possible to use OpenCL.  Second, the way the trajectory propagation code is put together doesn't really support GPU compute in general, since it's mostly object oriented work.  And third, I'm not actually convinced that CPU compute would speed up trajectory optimization, since optimization problems aren't really massively parallel in the same way that linear algebra can be.

I hope that helps!  Let me know if you have any thoughts about this or any other questions. :)

Awesome, glad to see this fantastic project alive!

As for the GPU computation, I guess you're right in saying that GPU compute probably wouldn't help. My rationale for suggesting that is that I know that n-body simulation for example can really benefit from massively-parallel computation, so I didn't really realise it wouldn't help much here. Thank you anyway!

Link to comment
Share on other sites

  • 2 weeks later...

With the upcoming early access release of KSP 2, I just wanted set expectations regarding KSPTOT integration.  First, it's going to be some time before I release a KSPTOTConnect plugin for KSP 2.  I'm going to have to start mostly from scratch, release C#, and relearn the KSP 2 API.  I don't have an estimate right now but I'll keep you all in the loop when I do.

Second, I'm probably only going to support the functionality which builds bodies.ini files from KSP, the functionality to pull orbits from KSP, and the ability to upload maneuvers.  I know there's some other functionality in KSPTOTConnect but I'm probably not going to implement, for example, the RTS stuff.  I don't think many people use it and I don't have a ton of time to work on it.  Perhaps in the future I'll dig into that, but at least for now, this is the plan going forward.

Any thoughts or questions? :)

Link to comment
Share on other sites

I've been prototyping some functionality tonight for the LVD user interface.  For some time now I've wanted to have the ability to resize various elements of the LVD main interface through the use of mouse click and drag.  Unfortunately, while The MathWorks has a slick grid layout system for their UIs, they lack this particular functionality and despite my insistence over the years, they have not yet implemented it natively.  I had some inspiration tonight and sat down to implement it.  I think I have what is basically a working prototype of the functionality, though it's only in a test UI window and not LVD itself.  I wanted to keep it generic so I can implement it easily in other KSPTOT UIs in the future if I desire.

This will necessitate some internal MATLAB functionality that became available in R2022b, and since we're on R2022a for KSPTOT now, I expect that we'll move to R2023a whenever that releases in the near future. 

It's pretty slick and I'm excited to get it implemented in KSPTOT soon.  I hope you all enjoy it and it makes your time with KSPTOT more enjoyable. :)

L2uaRu9.gif

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
On 2/23/2023 at 5:11 PM, jfinizolas said:


i'm having a bit of trouble, for some reason the predicted path and the ksp trajectory just wont match, what would the problem be? the parameters all seem to be right

 

1aAMWdv.png6PqUVV9.png

This is almost certainly a case of the sphere of influence radius assumption in MFMS (it being infinitesimal).  It could also be that the burn isn't in the right spot in KSP, and since your eccentricity is very small, mean anomaly/true anomaly can get squirrelly.  Try the maneuver in LVD, which is using a physics engine similar to KSP, to see if you can figure out what actually happened.

On 3/4/2023 at 5:17 AM, sonic300 said:

Hello!

First thanks for this porwerfull log but a i have a lot of issues with.....When i optimize in mission architect the log get stuck most of the time and i have to shutdown the process.

 

an idea ?

Unfortunately, without the contents of your ksptot.log file, I can't really say.  I would urge you to use Launch Vehicle Designer over MA, though.  LVD is more stable and I've done a much better job with it.  Despite the name, LVD does the same thing MA does, just much better.

Link to comment
Share on other sites

Hello there, new to the tool, so maybe I´m missing some things, to the point, I´m just trying  KSPTot for the first time, so I think on to do something easy, like a trip to the moon for to check the tool and his possibilities, I´m using RSS so I did an .ini file when I start the application and load a scene on KSP.

Transfer central body is The sun, Departure Body is Earth, and here in the arrival body I couldn´t find the Moon...so I´m stuck,

did I miss something?

 

thanks

Link to comment
Share on other sites

5 minutes ago, Makrom said:

Hello there, new to the tool, so maybe I´m missing some things, to the point, I´m just trying  KSPTot for the first time, so I think on to do something easy, like a trip to the moon for to check the tool and his possibilities, I´m using RSS so I did an .ini file when I start the application and load a scene on KSP.

Transfer central body is The sun, Departure Body is Earth, and here in the arrival body I couldn´t find the Moon...so I´m stuck,

did I miss something?

 

thanks

Yes, the central body for a transfer from Earth to the Moon wouldn't be the Sun.  The main porkchop plotter tool isn't actually what you want to use here.  For a simple rendevous analysis, use the Rendezvous Maneuver Sequencer tool (Tools -> Maneuver Planning).  For a more detailed analysis, you can use Launch Vehicle Designer, which despite the name handles generalized spacecraft and rocket mission design and analysis.  Start with RMS first and you can graduate to the more difficult LVD later. :)

Let me know if you have any other questions!

Link to comment
Share on other sites

Okay, I´m wondering how do I set the periapsis for the destination body, I can use the SMA parameter but I´m not getting the desired results, also, it seems that the tool, at least with the option I´m using (RMS) it considers circular orbits, but I can´t make it work reasonably with orbits with a high eccentricity, by example, for a trip to the moon, a periapsis of 600 km and an apoapsis of 2000 km can give you a boost of about 500 ms DV free..not sure how to use that with this tool , but anyway I´m just starting to use it...and also I can see that the tool doesn´t translate the data to principia, so I have to enter the numbers manually

Edited by Makrom
more data
Link to comment
Share on other sites

10 hours ago, Makrom said:

Okay, I´m wondering how do I set the periapsis for the destination body, I can use the SMA parameter but I´m not getting the desired results, also, it seems that the tool, at least with the option I´m using (RMS) it considers circular orbits, but I can´t make it work reasonably with orbits with a high eccentricity, by example, for a trip to the moon, a periapsis of 600 km and an apoapsis of 2000 km can give you a boost of about 500 ms DV free..not sure how to use that with this tool , but anyway I´m just starting to use it...and also I can see that the tool doesn´t translate the data to principia, so I have to enter the numbers manually

  1. It sounds like what you're doing is a bit more complicated that RMS was designed for.  You'll probably need to use the more general purpose LVD.  All RMS does is give you a transfer orbit and DV vectors to hit your desired target exactly.  You can't specify a target orbit because it was really designed to be used for rendezvous with spacecraft.
  2. RMS definitely doesn't work with Prinicipia.  If you want to go N-body, you'll need to use LVD.  It's the only tool in KSPTOT that can handle that, but I'll tell you up front that the learning curve for n-body gravity is a bit steep.  Feel free to ask questions!
Link to comment
Share on other sites

6 hours ago, Arrowstar said:
  1. It sounds like what you're doing is a bit more complicated that RMS was designed for.  You'll probably need to use the more general purpose LVD.  All RMS does is give you a transfer orbit and DV vectors to hit your desired target exactly.  You can't specify a target orbit because it was really designed to be used for rendezvous with spacecraft.
  2. RMS definitely doesn't work with Prinicipia.  If you want to go N-body, you'll need to use LVD.  It's the only tool in KSPTOT that can handle that, but I'll tell you up front that the learning curve for n-body gravity is a bit steep.  Feel free to ask questions!

Yeah well, it seems that LVD is something more complex related to design and plan every stage of a ship/mission...a tutorial or example could be useful.

Will start doing a multi flyby maneuver for to transfer it to LVD for to have a start point

Edited by Makrom
more data
Link to comment
Share on other sites

K, Got some questions

I design a flyby from earth to venus and then back to earth, using a ship of 35/10 tons.

https://imgur.com/oNOLBd5https://imgur.com/oNOLBd5

In LVD, the initial spacecraft state show one UT time (I think is the beginning of the window launch..) and the maneuver upload to ksp dialog shows another UT time (I think the moment when the maneuver should be executed)

Translating the numbers the initial state is at 162 days and 19 hrs, and the maneuver date is at 217 days 9 hours.

https://imgur.com/yIG46Slhttps://imgur.com/yIG46Sl

but in principia I don´t get the desired trajectory.

Now, if I subtract 1 hour to the maneuver date (217 days 8 hrs) i got this

https://imgur.com/nXups4E

which is kinda closer to what LVD projects, at least in the trajectory.

So, there are something related with timing that I´ m not seeing? maybe I´m not reading the right numbers?

I´m using UT, as in the game (RSS+RO+Principia) the time starts at year 0, day 0

thanks!

 

 

Link to comment
Share on other sites

5 minutes ago, Makrom said:

K, Got some questions

I design a flyby from earth to venus and then back to earth, using a ship of 35/10 tons.

https://imgur.com/oNOLBd5https://imgur.com/oNOLBd5

In LVD, the initial spacecraft state show one UT time (I think is the beginning of the window launch..) and the maneuver upload to ksp dialog shows another UT time (I think the moment when the maneuver should be executed)

Translating the numbers the initial state is at 162 days and 19 hrs, and the maneuver date is at 217 days 9 hours.

https://imgur.com/yIG46Slhttps://imgur.com/yIG46Sl

but in principia I don´t get the desired trajectory.

Now, if I subtract 1 hour to the maneuver date (217 days 8 hrs) i got this

https://imgur.com/nXups4E

which is kinda closer to what LVD projects, at least in the trajectory.

So, there are something related with timing that I´ m not seeing? maybe I´m not reading the right numbers?

I´m using UT, as in the game (RSS+RO+Principia) the time starts at year 0, day 0

thanks!

Thanks for the info.  In LVD, do you have third body gravity forces turned on?  And are you using the Principia bodies.ini file that I include with KSPTOT?

Link to comment
Share on other sites

13 minutes ago, Arrowstar said:

Thanks for the info.  In LVD, do you have third body gravity forces turned on?  And are you using the Principia bodies.ini file that I include with KSPTOT?

Not sure if it´s related, I select the sun and mercury as third body gravity properties in the window for to edit the initial state, didn´t found any option for to "turn on" third body gravity forces on the menus.

I saw the principia.ini file when I install the app, but it says bodies_STOCKPrincipia.ini, and I´m using RSS so I thought it was not a file that I could use, as principia can be used with the stock system also.

 

 

Link to comment
Share on other sites

35 minutes ago, Makrom said:

Not sure if it´s related, I select the sun and mercury as third body gravity properties in the window for to edit the initial state, didn´t found any option for to "turn on" third body gravity forces on the menus.

I saw the principia.ini file when I install the app, but it says bodies_STOCKPrincipia.ini, and I´m using RSS so I thought it was not a file that I could use, as principia can be used with the stock system also.

 

 

Alright, here's what you need to do to start, I think:

  1. Restart KSPTOT entirely.
  2. Make the bodies.ini file for your configuration.  Open up KSP, go to a spacecraft or any rocket on the pad.  Then in the main KSPTOT GUI window (with the porkchop plot), File -> Create Bodies File from KSP.
  3. Update the file you just created to use numerical propagation for the celestial bodies, as I think this is what Principia is doing under the hood. 
    1. Add the following to each body's entry: propType = numerical_integration
    2. Just as a warning, this can be pretty slow, so if you can get away without the numerical propagation of the celestial bodies, I would skip this step.
  4. Load this file.  File -> Load Bodies From File.
  5. Re-open LVD.
  6. Turn on Third Body Gravity.  Scenario -> Edit Initial State.  Push the Edit 3rd Body Gravity Properties button.  Select the bodies you want to use.
  7. Turn on the 3rd body gravity model. Open up your first event.  Select the Force Model Propagator.  Hit the Propagator Options button.  Select 3rd Body Gravity and save/close the dialog.
  8. Repeat this last step for each event in your mission.

Let me know if this helps!

Edited by Arrowstar
Link to comment
Share on other sites

2 hours ago, Arrowstar said:

Alright, here's what you need to do to start, I think:

  1. Restart KSPTOT entirely.
  2. Make the bodies.ini file for your configuration.  Open up KSP, go to a spacecraft or any rocket on the pad.  Then in the main KSPTOT GUI window (with the porkchop plot), File -> Create Bodies File from KSP.
  3. Update the file you just created to use numerical propagation for the celestial bodies, as I think this is what Principia is doing under the hood. 
    1. Add the following to each body's entry: propType = numerical_integration
    2. Just as a warning, this can be pretty slow, so if you can get away without the numerical propagation of the celestial bodies, I would skip this step.
  4. Load this file.  File -> Load Bodies From File.
  5. Re-open LVD.
  6. Turn on Third Body Gravity.  Scenario -> Edit Initial State.  Push the Edit 3rd Body Gravity Properties button.  Select the bodies you want to use.
  7. Turn on the 3rd body gravity model. Open up your first event.  Select the Force Model Propagator.  Hit the Propagator Options button.  Select 3rd Body Gravity and save/close the dialog.
  8. Repeat this last step for each event in your mission.

Let me know if this helps!

Adding the propType = numerical_integration to the .ini file throws an error on startup about "epoch must be the same for all the bodies" or something like that, so I skip that step.

Doing the third body gravity thing and running the "optimize mission" downs the time to fix in principia from 1 hour to 14 minutes, so I think it´s better

Link to comment
Share on other sites

21 hours ago, Makrom said:

Adding the propType = numerical_integration to the .ini file throws an error on startup about "epoch must be the same for all the bodies" or something like that, so I skip that step.

Doing the third body gravity thing and running the "optimize mission" downs the time to fix in principia from 1 hour to 14 minutes, so I think it´s better

okay, I´m using the multi flyby maneuver tool and LVD,  I can do the trajectory and translate it to principia with some tweaking, but still got far from the planet, can´t find a way for to predict the desired altitude.

Update: after some testing I could see that the data for prograde/normal/radial using third body gravity in every event is not different from the data without it, the only parameter that does change is the time for the maneuver, I could be doing something wrong, but that can explain why I can´t translate the data to principia accurately, not sure if it is a bug, but it is my experience until now.

 

Edited by Makrom
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...