Jump to content

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


Recommended Posts

On 9/3/2021 at 9:20 PM, Arrowstar said:

First, would anyone actually use something like this when they play KSP? 

*jumps up and down waving arms* ME! OOH! OOH! MEMEMEME!

On 9/3/2021 at 9:20 PM, Arrowstar said:

Be realistic, as this could potentially be a lot of effort. 

But it wouldn't be for a while. KSA will resume ops in 2022 but it's still a ways from launching scanning satellites tho that is a priority. I'd use it right away for cameras tho

Still, there's always people asking about good scanning orbits in the DMagic SCANSat thread and no one has really produced a tool dedicated to helping people with this. Best that's ever been done is a table of good orbits per instrument but that's been outdated for a while with more recent changes to how the SCAN instruments work

On 9/3/2021 at 9:20 PM, Arrowstar said:

there any other uses you can come up with that you might want to be able to do with this sort of functionality?

Not yet...

Link to comment
Share on other sites

23 hours ago, Drew Kerman said:

*jumps up and down waving arms* ME! OOH! OOH! MEMEMEME!

Well obviously if you would like it, @Drew Kerman, then I think I have to implement it. ;)

Quote

But it wouldn't be for a while. KSA will resume ops in 2022 but it's still a ways from launching scanning satellites tho that is a priority. I'd use it right away for cameras tho

Still, there's always people asking about good scanning orbits in the DMagic SCANSat thread and no one has really produced a tool dedicated to helping people with this. Best that's ever been done is a table of good orbits per instrument but that's been outdated for a while with more recent changes to how the SCAN instruments work

These are some good ideas.  I'll have to post a demo video in the SCANSat thread once I've got everything to my liking.  Thanks!

Speaking of demo videos, I've got an initial implementation into LVD!  It's actually pretty slick to play around with.  I'm going to have fun with this. ;)  Check it out.

kwrccVl.gif

 

 

Edited by Arrowstar
Link to comment
Share on other sites

13 hours ago, Razgriz1 said:

How do you do things like this so quickly?? Teach me your ways!

In this case, I had most of the math worked out before I asked people if they would be interested.  Acutally getting it into LVD then was just a matter of writing the classes that do what you see based on the original development script.  All the hard work was done before I asked lol. ;)

Link to comment
Share on other sites

Alright, here's a fun image for you all to look at.  As it turns out, the sensor obscuration system works with celestial bodies other than the central body of the current orbit.  In this case, I have a sensor on the surface of Kerbin (at KSC, of course) and I have a grid of sensor target points all over the surface of Minmus.  Here's what the display currently looks like.

vCVKYKn.png

See those big black cones in the middle of the big green sphere?  Those are sensor shadows being created by the Mun (the big one, left) and Minmus (small one, right).

Here's what the grid of points on the surface of Minmus looks like.

GOTrIvG.png

Anyway, I'm working on a tool that will do the analysis of sensor data and provide XLS files out for the user.  It turns out that in this particular scenario, we can actually get out what kind of coverage of Minmus KSC gets.

grz7ikV.png

The first ~4000 seconds of this plot represent time that KSC cannot see Minmus at all.  The blue line you see represents the  approximate instantaneous amount of the surface of Minmus visible from KSC, and the orange line is the total amount of the surface cumulatively seen by the sensor.  Keep in mind that "the surface" here is represented by points that are 0.01 km off the surface of Minmus, and so we're not looking at the surface as a continuous thing, but rather sampling points near it for this analysis.

I'll have more to show next week, but I hope this gets people excited about what's possible here. :) Let me know if you have any questions!

Link to comment
Share on other sites

This afternoon I've built KSPTOT v1.6.9 pre-release 2!  This pre-release introduces the new Sensor system into KSPTOT's Launch Vehicle Designer (LVD) tool.  Here's the change log:

  • LVD: New Sensor system
    • Model sensors attached to vehicles, ground stations, and other points.
    • Detect sensor targets, defined as points or sets of points.
    • Plot sensor data and output to XLS files.
    • New actions to update sensor properties.
  • LVD: The yellow "working" labels are now gone and have been replaced with a more modern looking notification area at the bottom of the UI, complete with spinning "busy" widget. ;)
  • LVD: View Settings UI is now properly resizable.

Let's talk through how the new sensor system works in practice.  In order to use the sensor system, you need to model at least one sensor and at least one sensor target.  Both of these options are found under the new Scenario -> Sensors menu.

When you select Edit Sensors from this menu, you'll see the usual add/remove/edit component dialog box that's used all over LVD.  Go ahead and add a new sensor.  You'll be prompted to select the sensor type (there is only one type at this time).  When you select Conical Sensor, you'll be greeted with this UI.

G8e10s7.png

From here, you can adjust the size and range of the sensor, as well as whether or not the sensor is active at the initial state.  You can also adjust the sensor's origin, which is always a Geometric Point.  The scenario must have at least one geometric point to be able to use sensors.  You can also adjust the sensor's pointing model, which describes which direction the sensor points.  At this time you can either fix the sensor in the vehicle's attitude body frame or you can fix it in a Geometric Coordinate System.  You need at least one geometric geometric coordinate system to use this last function.

Next up we need to add a target.  You add targets using the Edit Targets menu item in the same Sensors menu as before.  There are three different kinds of targets available:

  • Point targets
    • These use one Geometric Point, turning that point into a single target the sensor can detect.
  • Rectangular lat/long grid targets
    • These are a rectangular grid of latitude/longitude target points at a certain altitude above a celestial body. 
  • Circular lat/long grid targets
    • These are similar to the rectangular grid targets, but the grid is a circle, centered at a lat/long point with a certain radius, at a certain altitude above a celestial body.

If you select the circular lat/long grid target option, you'll be greeted with the following UI.

X3MmpDs.png

Options are generally self-explanatory here: select the celestial body, select the circle grid parameters, etc.  You can draw a circle on the 2D map if you want to generate your parameters visually.  Note that some points are displayed as if "found" and others as if "not found" so you can get a sense for what they look like.

Finally, once you have a sensor and a sensor target, you can generate a sensor report from the Sensor Reports menu item. 

bc28LvH.png

Select the sensor and the target you just created, select where you want the output files to be written to, and tap "Generate Report".  This process can take some time as the sensor geometry and target locations are computed at every time step in the simulation.  Once done, the Data Viewer tab will be populated and XLS files containing that same data will be generated.  You are free to work with the data as you need to at this point.

And that's all there is to it!  As you're using this new system, please keep me in the loop if you have any features you'd like to see or bugs you find that need fixing.  Thank you!

Link to comment
Share on other sites

Hey everyone, I've found a bit of a flaw with the system that computes the shadowed sensor volumes for the conical sensors.  I have corrected it, but unfortunately it means that conical sensors are limited to 90 degrees max half angle now.  I'll explain more when I have a bit more time, but long story short, please download the PR2 release again to get the fix.  Thanks!

Link to comment
Share on other sites

48 minutes ago, MashAndBangers said:

So I had a chance to play around with KSPTOT last night, and I was able to calculate an Eve flyby in the special flyby module, but how do I go from KSPTOT to maneuver nodes in KSP?

You have a couple options.  The "easy" way is to just use the departure and arrival dates in MFMS and plan the maneuver nodes yourself, knowing that you want to leave and arrive on certain days.  This takes a lot of hand tuning but is procedurally straight forward.  The "medium skill" method is to right click on the DV Maneuver Info text box to upload your departure maneuver node to KSP.  You'll have to do the rest of the maneuver nodes yourself, but it'll work.  The "hard" way is to use the information from MFMS as a seed for Launch Vehicle Designer and, using LVD, put together a high fidelity simulation akin to the "lvdExample_ToEelooViaJool_BackPropExample.mat" example LVD mission that I provide with KSPTOT.

If you're new to the idea of mission planning, try the first way for now and just try to get the departure and arrival times in KSP to be close by hand adjusting your maneuver nodes.  You're also looking to make sure that your post-flyby orbit around the Sun looks generally pretty close to what is shown in MFMS.

Once you've tried that, let me know if you want help with any of the other more challenging methods and I'll answer whatever questions you might have.  Hope that helps! :)

Link to comment
Share on other sites

@Arrowstar  Is it possible to export a KoS .csv from your "lvdExample_L2HaloOrbit"?  In LVD, when I select Simulation --> Create KoS Control CSV file & try exporting various parts (or all) I just get stuck at the "parsing state log data..." with no .csv generated (even with "Edit Event" closed...I just had that open in the screenshot as an example of looking at the details of a specific event).  (I am currently still using the release 1.6.8 since I still have so much to learn...)  (I was thinking I might try to visualize the example in KSP from the 700km sma LKO in a manner similar to your video.) Thanks!

YKZuw1n.png

 

Edited by AloE
Link to comment
Share on other sites

6 hours ago, AloE said:

@Arrowstar  Is it possible to export a KoS .csv from your "lvdExample_L2HaloOrbit"?  In LVD, when I select Simulation --> Create KoS Control CSV file & try exporting various parts (or all) I just get stuck at the "parsing state log data..." with no .csv generated (even with "Edit Event" closed...I just had that open in the screenshot as an example of looking at the details of a specific event).  (I am currently still using the release 1.6.8 since I still have so much to learn...)  (I was thinking I might try to visualize the example in KSP from the 700km sma LKO in a manner similar to your video.) Thanks!

YKZuw1n.png

 

You found a bug!  I've fixed it this morning in the v1.6.9 pre-release 2.  Please download that and give it a try.  It should hopefully do what you want.   Thanks for the report!

Link to comment
Share on other sites

2 hours ago, Entropian said:

Is there any way to restrict the number of maneuvers in a flyby sequence?  Thanks!

There is not, sorry.  Maneuvers are generated when it becomes necessary for two orbits to be connected in a way that can't be achieved through a passive gravity assist maneuver.  Because this, in turn, is strictly dictated by when various bodies are arrived at, there's no way to artificially limit the number of maneuvers.

Link to comment
Share on other sites

Two of the big questions that I always seem to get from new users of KSPTOT and specifically the Multi-flyby Maneuver Sequencer (MFMS) are something in the form of:

  1. Why doesn't my MFMS trajectory match what I see in KSP?
  2. How do I actually execute my MFMS trajectory in KSP?

Unfortunately, while MFMS is excellent for exploring the multiple gravity assist problem trade space, it was never designed to really be used in operations.  What was designed to be used in operations, however, was Launch Vehicle Designer (LVD) and its higher fidelity orbit propagation models.  Thus, the usual advice for people stuck on these two questions in the past has been "recreate your MFMS trajectory in LVD."  Needless to say, this is sort of an ominous task for the beginner as LVD isn't the easiest to use.

Today I want to introduce a new tool that will make the process of recreating your MFMS trajectories in LVD much, much easier.  Say you start with this Kerbin-Eve-Jool-Eeloo flyby trajectory.

3ncLhmb.png

Up until today, you basically had to import the trajectory by hand into LVD.  This involved creating all of the events and initial state by hand, setting the variables, defining constraints, and everything else.  It was definitely time consuming.  Notice, though, the new button in the lower right portion of the window that reads Save Results to File for LVD.  If you push this, it will prompt you to save a binary (MAT) file with the data generated from the last MFMS run.

From there, all you have to do is open LVD up and use the File -> New Mission from MFMS Output menu option.  When you do and select the file you just created, you'll see something like this:

7YWTzUg.png

Well hey, that looks pretty close to the MFMS output!  You'll notice that all of the legs of the trajectory have been imported, but they don't quite line up.  You can see some discontinuities in the trajectory.  If you mouse over the warning about optimization constraints being violated, you'll see that there's a bunch of continuity constraints that need to be brought in.  You'll also notice that there are variables in the mission script.  Were you to investigate these, you'd see that each impulsive delta-v, each leg's propagation duration, and each flyby periapsis state already has optimization variables associated with them.  There's also a "maximize mass" objective function created too.

Really, all you need to do at this point is scale the constraints properly and optimize the mission.  The whole process has been reduced from 1 hour or more of event creation to just a few minutes at most (and when you get good, I think it's probably closer to just one minute or less).

Anyway, after you let the optimizer run for a bit, your finalized mission plan should come in nicely.  (Note, in the image that I show here, I imported a slightly different MFMS trajectory because I've been testing with this one.  You get the idea though!)

2GjJl4i.png

Pretty neat, huh?

What do you all think?

Link to comment
Share on other sites

2 hours ago, Arrowstar said:

What do you all think?

I think I'm glad I took a break and didn't launch my interplanetary mission last month like I had originally planned a few years ago :P Was *not* looking forward to getting it implemented in MA or LVD earlier this year given my shrinking time constraints. Look forward to plotting a new series of Extremis missions now! Bummer I need to go back to finding new flyby routes first since I only searched through 2021...

Link to comment
Share on other sites

2 hours ago, Drew Kerman said:

I think I'm glad I took a break and didn't launch my interplanetary mission last month like I had originally planned a few years ago :P Was *not* looking forward to getting it implemented in MA or LVD earlier this year given my shrinking time constraints. Look forward to plotting a new series of Extremis missions now! Bummer I need to go back to finding new flyby routes first since I only searched through 2021...

Haha, well, I'm glad I could come up with a tool that makes things a bit easier!  I look forward to seeing what you come up with for new missions. :)

Link to comment
Share on other sites

Hi everyone,

I've just build KSPTOT v1.6.9 pre-release 3.  This primarily includes the new MFMS data import functionality that I described the other day.  I would certainly appreciate if anyone who uses MFMS and LVD could try out this functionality on their end and see if there are any breaking bugs.  I have tested the functionality on both the stock solar system and the JNSQ solar system and everything seems to be in order.   Here's the change log:

  • MFMS: Inclusion of a new button on the UI that allows for binary data from the last run to be exported to file.
  • LVD: New menu item to create a new mission scenario from MFMS binary data.
  • MA/LVD: Initial state and final state shown in the UI are now the earliest and last (chronological) state in the state log, as opposed to the first and last state log entries.  This is important in LVD because of the ability to use Set Kinematic State actions to move around in time, and because propagation can be both forwards and backwards.
  • The Edit Constraint UI now shows the current scaled value of the selected constraint.

Please let me know if you find any bugs!  Happy orbiting. :)

Link to comment
Share on other sites

Would it be possible to include an option to set the display scale factor? Currently on a high-res display the tool is pretty unusable, half the info boxes appear to be missing. The text scales correctly but does not fit into the UI boxes.

As far as I understand the following should set this in Matlab, but I don't know how that could be changed in a runtime tool like KSPTOT:

>> s = settings;s.matlab.desktop.DisplayScaleFactor
>> s.matlab.desktop.DisplayScaleFactor.PersonalValue = 1.5

Or is there a way I can enter this somewhere myself?

xx1G0dn.png

Link to comment
Share on other sites

4 hours ago, jd284 said:

Would it be possible to include an option to set the display scale factor? Currently on a high-res display the tool is pretty unusable, half the info boxes appear to be missing. The text scales correctly but does not fit into the UI boxes.

As far as I understand the following should set this in Matlab, but I don't know how that could be changed in a runtime tool like KSPTOT:

>> s = settings;s.matlab.desktop.DisplayScaleFactor
>> s.matlab.desktop.DisplayScaleFactor.PersonalValue = 1.5

Or is there a way I can enter this somewhere myself?

xx1G0dn.png

Oh goodness, that is... bad lol.

Okay, some questions first:

  1. What operating system are you using?
  2. What is the resolution of your monitor set to?
  3. Does this happen with any of the other tools/UIs or just Mission Architect?  Mission Architect is the only UI I didn't port over to the App Designer framework because it's "bug fix only" for me at this point.
  4. In your KSPTOT log, what does the header say for the version of MATLAB you're running?

To answer your question, yes, there is actually a way for you to run the command yourself.  Do the following:

  1. Open up Launch Vehicle Designer.
  2. Find the Plugins menu and click Manage Plugins .
  3. Create a new plugin with the button on the left.
  4. Copy/paste the code you created into the code editing area in the middle.  Keep in mind that it's two lines there, and we don't include the ">>".  That symbol is just the command prompt.  So basically just the following, keeping in mind that you may need to play with that 1.5 number.
    s = settings;
    disp('Old Display Scale Factor:');
    disp(s.matlab.desktop.DisplayScaleFactor.PersonalValue);
    s.matlab.desktop.DisplayScaleFactor.PersonalValue = 1.5;

     

  5. Check the box on the right that says to run the plugin before propagation.
  6. Check the box on the lower right which activates plugins. There should be a red area that appears when you have plugins activated.
  7. Save and close the plugin editor.
  8. Propagate the script (control-p).

When you are finished with your plugin, your Plugin Manager should look something like this.

nDmvvPa.png

You might need to restart MATLAB at this point.  Can you tell me what happens when you do everything I've described?

You probably also need to follow Step 2 in the Accepted answer of this post to calibrate the system DPI.  Basically:

Quote
To calibrate the system's DPI to match the scale factor, please use the following terminal commands:
% xdpyinfo | grep resolution
resolution: 96x96 dots per inch
% xrandr --dpi 144

The DPI value chosen should be the resolution found with "xdpyinfo" multiplied by the MATLAB scale factor that was set. In the example, 96 × 1.5 = 144.

MATLAB must be restarted after Step 2.

Please let me know if any of this helps, as well as the answers to my questions above.  Thanks!

Edited by Arrowstar
Link to comment
Share on other sites

Thanks, the plugin fixed most of the windows now. Except for Mission Architect. But I wanted to use mostly the flyby tool, so I'm happy with this.

25 minutes ago, Arrowstar said:

Okay, some questions first:

  1. What operating system are you using?
  2. What is the resolution of your monitor set to?
  3. Does this happen with any of the other tools/UIs or just Mission Architect?  Mission Architect is the only UI I didn't port over to the App Designer framework because it's "bug fix only" for me at this point.
  4. In your KSPTOT log, what does the header say for the version of MATLAB you're running?

1. Linux (Kubuntu 21.04)
2. 3840x2160 / 184 dpi
3. Without your fix above, it affected all windows. With the fix, only Mission Architect is still at the wrong scale.
4.

========================================
  _  __ _____ _____ _______ ____ _______
 | |/ // ____|  __ \__   __/ __ \__   __|
 | ' /| (___ | |__) | | | | |  | | | |
 |  <  \___ \|  ___/  | | | |  | | | |
 | . \ ____) | |      | | | |__| | | |
 |_|\_\_____/|_|      |_|  \____/  |_|
========================================
KSPTOT v1.6.8
MATLAB 9.10.0.1710957 (R2021a) Update 4
DATE: 2021/10/01 15:38:59
========================================
Switching to hardware OpenGL rendering at runtime on unix is not supported.


 

Link to comment
Share on other sites

2 minutes ago, jd284 said:

Thanks, the plugin fixed most of the windows now. Except for Mission Architect. But I wanted to use mostly the flyby tool, so I'm happy with this.

1. Linux (Kubuntu 21.04)
2. 3840x2160 / 184 dpi
3. Without your fix above, it affected all windows. With the fix, only Mission Architect is still at the wrong scale.
4.

========================================
  _  __ _____ _____ _______ ____ _______
 | |/ // ____|  __ \__   __/ __ \__   __|
 | ' /| (___ | |__) | | | | |  | | | |
 |  <  \___ \|  ___/  | | | |  | | | |
 | . \ ____) | |      | | | |__| | | |
 |_|\_\_____/|_|      |_|  \____/  |_|
========================================
KSPTOT v1.6.8
MATLAB 9.10.0.1710957 (R2021a) Update 4
DATE: 2021/10/01 15:38:59
========================================
Switching to hardware OpenGL rendering at runtime on unix is not supported.


 

Okay, thanks!  So I'm actually going to encourage you to work with Launch Vehicle Designer instead of Mission Architect.  LVD is basically everything I had hoped to make MA and a lot more.  It's just a far more powerful tool, and while the learning curve is a bit steeper, it's way, way more powerful.  You're welcome to post questions here and I'll do my best to help if you'd like. :)

Anyway, glad it's working now!

Link to comment
Share on other sites

7 minutes ago, Arrowstar said:

Okay, thanks!  So I'm actually going to encourage you to work with Launch Vehicle Designer instead of Mission Architect.  LVD is basically everything I had hoped to make MA and a lot more.  It's just a far more powerful tool, and while the learning curve is a bit steeper, it's way, way more powerful.

Yeah, it's pretty overwhelming at first sight! But now that I can actually read things I think I'll be able to figure out what I want to do. :)

Link to comment
Share on other sites

I'm fascinated by this mod and the possibility of making use of it. I have a trillion questions that I've narrowed down to two. If you had a moment to share your thoughts it'd be very much appreciated - I'm attempting to count the cost, as they say.

I'm using KSRSS, scaled up 2.5x. Will I be able to give your tool the solar system data it needs for calculations? To complicate things (or maybe it doesn't matter) there's Kronometer and SigmaDimensions involved doing the scaling and calendar witchcraft I guess. I'm nervous about your tool and KSP maybe speaking different time/date scales?

Once the tool is happy, I would love to be able to reconstruct a Pioneer 10/11 type mission, where a Jupiter encounter leads to a Saturn encounter. Is that type of thing even possible in KSP? Clearly the real mission timing/parameters don't translate into KSP, but would your tool be able to do something with high level parameters like that?

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