Jump to content

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


Recommended Posts

On 2/29/2020 at 6:49 PM, Drew Kerman said:

And another request I think I made: Frontal Area output for the GA - just as an easy way to check all drag updates are using the proper values

Added for next release.

13 hours ago, Drew Kerman said:

@OhioBob, I did not intend to rope you in on this I'm not looking for you to do anything or change anything on your end. Either @Arrowstar makes changes to LVD or I make adjustments on my end

Since this change isn't going to happen soon or maybe not ever, I will adjust things myself to allow compatibility with LVD

Ack, I don't even think I can match the curves anyways since BetterSRBs is using all 4 curve parameters for its thrust curves and LVD's curves are more linear (mass, throttle). So even if I try to just scale down the curve and adjust the thrust value in LVD I can't get it to match the curve BetterSRB has

To be clear, if this can't be worked out I will just go back to using my own thrust profiles - no one has to bend over backwards or anything to get BetterSRB working with LVD

@OhioBob, @Drew Kerman: Yes, I was referring to @Drew Kerman modifying the throttle table in KSPTOT/LVD to accommodate the 0%-100% bounds on throttle via scaling the whole thing.  Definitely no action required on your part, @OhioBob.

@Drew Kerman, which four curves do you need?  I have a post-it note on my desk with a long-term "TO DO" to add the other curves I'm missing, but I've never had any reason to do so because no one has ever needed them until now as far as I know.  I could probably try to add them this weekend if it was useful...

Link to comment
Share on other sites

9 hours ago, ProfWashburn said:

Good afternoon everyone! 

First of all I love this software! Arrowstar, you are a legend. 

Thanks! :)

Quote

Does anyone know if the RTS in KSPTOT supports a public URL in the RTS connection system? If it does, I'm trying to get the ngrok settings correct so that I have the correct port exposed on the localhost machine running KSP and KSPTOT Connect.

I've honestly never tried.  I believe that 99% of the time it gets used locally, so this doesn't come up much.  However, I can tell you that anything that "java.net.InetAddress.getByName()" can resolve can be used, as far as I can tell (see here for how I'm using it).  Any idea if these ngrok addresses work with that?

EDIT: I just tried it and it doesn't seem to work.  If you have any insight into what I would need to do to make it work for you, let me know and I'll do my best to make it happen by this weekend.

EDIT 2: I do know that it's port 8282 that the main KSPTOT RTS connection is through, but given my awful net code skills from years ago, each different connection type streams through a different port.  I can get you the range if that helps.  Hopefully this doesn't hinder the effort.

Edited by Arrowstar
Link to comment
Share on other sites

@Arrowstar Thanks for the info!!

Just found this on the Oracle site:

Quote

 

InetAddress getByName()

Determines the IP address of a host, given the host's name.

The host name can either be a machine name, such as "java.sun.com", or a textual representation of its IP address. If a literal IP address is supplied, only the validity of the address format is checked.

 

 

ngrok is supposed to be invisible to the machine running KSP.  It should make the RTS system think that it is connected directly to 127.0.0.1 on the machine running KSP and KSPTOT Connect. I'm wondering if it is looking for the remote machines IP address instead of accepting multiple connections from the single localhost address? Each remote computer would be trying to establish a connection to the system on 127.0.0.1. 

ngrok displays this line -  Forwarding   123abc456.ngrok.io -> 127.0.0.1:8282

So each machine would put the 123... ngrok url into the RTS remote host box. ngrok would then forward all traffic to the primary machine running KSP  but it all shows up looking basically like another instance of KSPTOT trying to establish another RTS connection on 127.0.0.1 on the primary machine. 
 

It might help to have a way to specify a port in the RTS connection window to be able to lock down which port each computer communicates on. I'm not sure what amount of work that is for a potential solution but it would certainly make troubleshooting a lot easier. 

I have had multiple computers connected and streaming data from one computer with KSPTOT Connect, so I know the system can handle multiple connections from different machines. The issue seems to lie in establishing the connection using this tunnel service. Most likely due to port assignments or something. 

I'm going to keep hacking away at this and see if I can get something going. I'll report back with any progress or lack there of haha 

Thanks again for the really cool software and the help! Have a good evening! 

Edited by ProfWashburn
Link to comment
Share on other sites

11 hours ago, Arrowstar said:

which four curves do you need?  I have a post-it note on my desk with a long-term "TO DO" to add the other curves I'm missing, but I've never had any reason to do so because no one has ever needed them until now as far as I know.  I could probably try to add them this weekend if it was useful...

Alright, here is the curve of the booster I'm working with:

thrustCurve
{
  key = 0 0.1 0 35
  key = 0.03 0.801 0.76 0.76
  key = 0.61 1.2418 0.76 -0.62
  key = 1 1 -0.62 0
}

It produces a curve like this (thrust/time):

LkmVjht.png

The two additional values are "In Tangent" and "Out Tangent", as seen via the OP of this mod for floatcurve editing:

That's the extent of my knowledge on the matter :PCall back OhioBob if you need more info I guess. Thanks as always for the consideration

Edited by Drew Kerman
Link to comment
Share on other sites

6 hours ago, Drew Kerman said:

Alright, here is the curve of the booster I'm working with:


thrustCurve
{
  key = 0 0.1 0 35
  key = 0.03 0.801 0.76 0.76
  key = 0.61 1.2418 0.76 -0.62
  key = 1 1 -0.62 0
}

That's the extent of my knowledge on the matter :PCall back OhioBob if you need more info I guess. Thanks as always for the consideration

If you want to edit the curve so that the shape is the same but it has a maximum value of 1, then just divide the last three numbers of each key by the maximum value found in the second column.  In the example provided, the maximum value in the second column is 1.2418, so dividing through by that we get,

thrustCurve
{
  key = 0 0.08053 0 28.185
  key = 0.03 0.64503 0.6120 0.6120
  key = 0.61 1 0.6120 -0.4993
  key = 1 0.8053 -0.4993 0
}

To compensate for the lower thrustCurve multiplier, you would need to multiple maxThurst by 1.2418.
 

Edited by OhioBob
Link to comment
Share on other sites

@OhioBob you are both a scholar and a gentleman! *bows*

Note @Arrowstar this doesn't let you off the hook just gives me the ability to use this curve if LVD can implement the in/out tangents

Also still note that I am still willing to just approximate my own 2-column curve to work with what LVD currently has

Edited by Drew Kerman
Link to comment
Share on other sites

Tonight I want to share an update that is coming to the drag model within Launch Vehicle Designer.  One of the items on my long term wish list has been to allow users to make drag coefficient a function of some independent variable.  I'm pleased to share that I've finally gotten this together.

Here's the new drag properties dialog box for actions and the initial state.

DuSguwj.png

The frontal area section is unchanged from what you have now.  The big change comes in the drag coefficient section.  Instead of a single number to enter, this section now lets you enter a list of points on a drag coefficient curve.  These points are made up of drag coefficient values ("Y") at user defined values of the independent variable ("X").  The independent variable of the curve can be altitude,  dynamic pressure, mach number, atmospheric density, atmospheric pressure, and body-fixed velocity.  You can see the points currently entered in the list box to the left.

The points are interpolated between using the selected method.  Here in this picture, a particular type of cubic spline interpolation is selected.  Other options include a linear interpolation and other types of splines.

Extrapolation is always "nearest neighbor" so if you go off your entered points, the code will automatically use the drag coefficient at the highest or lower independent variable value that you provided.

You can plot your curves to see how the interpolation will impact the currently entered points and interpolation method:

KNKogJY.png

The green diamonds are the entered points, the white line is the interpolation between them, and the nearest neighbor extrapolation is visible to the left and right extremes of the plot.

I hope this adds some flexibility to LVD aerodynamics modeling and removes the need to create a ton of non-sequential events to update the drag coefficient manually.

Let me know what you think! :)

Link to comment
Share on other sites

7 minutes ago, Arrowstar said:

I hope this adds some flexibility to LVD aerodynamics modeling and removes the need to create a ton of non-sequential events to update the drag coefficient manually.

Let me know what you think!

*KERMIT FLAIL*

Also FAR is coming out with the ability to log data soon. I just tested the dev branch and have a CSV of every value from the FAR Data window, including Cd

I am about to be in heaven

Edited by Drew Kerman
Link to comment
Share on other sites

Just now, Drew Kerman said:

*KERMIT FLAIL*

:lol:

2 minutes ago, Drew Kerman said:

Also FAR is coming out with the ability to log data soon. I just tested the dev branch and have a CSV of every value from the FAR Data window, including Cd

I am about to be in heaven

Would CSV import into that listbox be useful then?

Link to comment
Share on other sites

45 minutes ago, Drew Kerman said:

I'm just going to say sure why not - but I'm not going to be disappointed if it's not a thing

It only took 20 minutes so I added it.  Right click on the listbox with all the points and select the Import CSV File menu that comes up.  Your CSV file needs two columns.  The first is the independent variable values, the second is the drag coefficient values.  Any other columns are ignored.  You must have at least two rows of valid Cd data.

Edited by Arrowstar
Link to comment
Share on other sites

Hi everyone,

Tonight I've built the KSPTOT v1.6.5 pre-release 10.  Here's the change log:

  • LVD: Changed drag model such that drag coefficient is now entered as set of points which are interpolated over.  Drag coefficient data may be imported from a CSV file.
  • LVD: Added a new, fifth order fixed step integrator, ODE5.  See below for more information.
  • LVD: Added drag area to graphical analysis outputs.
  • LVD: Added Cntrl-F shortcut to remove or re-added event from optimization.
  • MA: Resolved issue with plotting periapsis crossings.

What's a fixed step size integrator?

Thus far, all of the integrators available in LVD are part of a family of "adaptive step size" integrators.  This means that the integrator automatically adjusts the size of each step it takes when running through the equations of motion in order to control of the integration error. On the other hand, a fixed step size integrator uses a predetermined step size to run through the equations of motion with no adjustment to control error.

Why use a fixed step size integrator?

Adaptive step size integrators are generally more accurate than fixed step size integrators.  However, this often comes at the cost of high CPU cost for short integrations because the integrator needs to take very small steps initially in order to get a feel for the tolerance of the equations of motion.  A fixed step size integrator, however, simply takes the step size associated with it, thus eliminating this cost.

The take away is that for short integrations (relative to the time scale of the problem) where high fidelity is not needed, the fixed step size integrators can often outperform their adaptive step size cousins by non-trivial margins.  The ODE5 integrator I implemented here was able to offer a 33% increase in total propagation speed in one of the example LVD mission cases with minimal loss of accuracy, just by selectively applying this integrator in suitable locations.

How should I use ODE5?

When building a mission, always start with the ODE45 or ODE113 integrators for your events.  If you notice that your mission is running slowly, go through each event, right-click on the integrator drop-down menu, and select the option that lets you pick the fastest integrator.  ODE5 should be reasonably fast for many short events, so pick that option when it's clear that it provides superior performance. 

After this, adjust the step size in the integrator options manually such that your final state for that event is roughly equal to what you were seeing with ODE45 or ODE113.  How close is required is up to you as the analyst. :) 

A Warning

  1. I wrote the ODE5 integrator from scratch, it is not a MATLAB built in function.  If you find any bugs with ODE5 when using it, please let me know.  In particular, the event detection and output function handling is all me, so if events seem to be missing their termination conditions, please let me know.
  2. Step sizes that are too large can cause ODE5 to diverge and produce nonsensical results.  This is a new behavior from the other existing integrators, where divergence basically could not happen because of the built in error control.  If you notice your spacecraft trajectory doing weird things on an event with ODE5 enabled, shrink the step size until the solution stabilizes.
Link to comment
Share on other sites

On 3/6/2020 at 10:50 PM, Arrowstar said:

Tonight I've built the KSPTOT v1.6.5 pre-release 10.

new drag modeling a breaking change in LVD tho that makes it incompatible with previous builds? I tried to load a PR9 LVD file in PR10 and it failed. I saw that the Set Drag Aero event was still in the selection box for event actions - even tho clicking on it did nothing I figured it was maybe there for backwards compatibility. If not, then heads up - it's still there :P

Log:

Spoiler

Error using SetDragAeroPropertiesAction.openEditActionUI (line 92)
Error setting property 'CdIndepVar' of class 'LaunchVehicleAeroState':
Invalid data type. Value must be AeroIndepVar or be convertible to AeroIndepVar.

Error in lvd_editEventGUI>addActionButton_Callback (line 281)


Error in gui_mainfcn (line 95)


Error in lvd_editEventGUI (line 42)


Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)lvd_editEventGUI('addActionButton_Callback',hObject,eventdata,guidata(hObject))

Error using uiwait (line 81)
Error while evaluating UIControl Callback.

Error using SetDragAeroPropertiesAction.openEditActionUI (line 92)
Error setting property 'CdIndepVar' of class 'LaunchVehicleAeroState':
Invalid data type. Value must be AeroIndepVar or be convertible to AeroIndepVar.

Error in lvd_editEventGUI>addActionButton_Callback (line 281)


Error in gui_mainfcn (line 95)


Error in lvd_editEventGUI (line 42)


Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)lvd_editEventGUI('addActionButton_Callback',hObject,eventdata,guidata(hObject))

Error using uiwait (line 81)
Error while evaluating UIControl Callback.

Starting parallel pool (parpool) using the 'local' profile ...
connected to 4 workers.
Error using SetDragAeroPropertiesAction/executeAction (line 37)
Error setting property 'CdIndepVar' of class 'LaunchVehicleAeroState':
Invalid data type. Value must be AeroIndepVar or be convertible to AeroIndepVar.

Error in LaunchVehicleEvent/cleanupEvent (line 149)


Error in LaunchVehicleScript/executeScript (line 213)


Error in ma_LvdMainGUI>propagateScript (line 130)


Error in ma_LvdMainGUI>openMissionPlanMenu_Callback (line 771)


Error in ma_LvdMainGUI>openMissionPlanToolbar_ClickedCallback (line 903)


Error in gui_mainfcn (line 95)


Error in ma_LvdMainGUI (line 42)


Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)ma_LvdMainGUI('openMissionPlanToolbar_ClickedCallback',hObject,eventdata,guidata(hObject))

Error using waitforallfiguresclosed (line 9)
Error while evaluating PushTool ClickedCallback.

 

 

Link to comment
Share on other sites

4 hours ago, Drew Kerman said:

new drag modeling a breaking change in LVD tho that makes it incompatible with previous builds? I tried to load a PR9 LVD file in PR10 and it failed. I saw that the Set Drag Aero event was still in the selection box for event actions - even tho clicking on it did nothing I figured it was maybe there for backwards compatibility. If not, then heads up - it's still there :P

Log:

  Reveal hidden contents

Error using SetDragAeroPropertiesAction.openEditActionUI (line 92)
Error setting property 'CdIndepVar' of class 'LaunchVehicleAeroState':
Invalid data type. Value must be AeroIndepVar or be convertible to AeroIndepVar.

Error in lvd_editEventGUI>addActionButton_Callback (line 281)


Error in gui_mainfcn (line 95)


Error in lvd_editEventGUI (line 42)


Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)lvd_editEventGUI('addActionButton_Callback',hObject,eventdata,guidata(hObject))

Error using uiwait (line 81)
Error while evaluating UIControl Callback.

Error using SetDragAeroPropertiesAction.openEditActionUI (line 92)
Error setting property 'CdIndepVar' of class 'LaunchVehicleAeroState':
Invalid data type. Value must be AeroIndepVar or be convertible to AeroIndepVar.

Error in lvd_editEventGUI>addActionButton_Callback (line 281)


Error in gui_mainfcn (line 95)


Error in lvd_editEventGUI (line 42)


Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)lvd_editEventGUI('addActionButton_Callback',hObject,eventdata,guidata(hObject))

Error using uiwait (line 81)
Error while evaluating UIControl Callback.

Starting parallel pool (parpool) using the 'local' profile ...
connected to 4 workers.
Error using SetDragAeroPropertiesAction/executeAction (line 37)
Error setting property 'CdIndepVar' of class 'LaunchVehicleAeroState':
Invalid data type. Value must be AeroIndepVar or be convertible to AeroIndepVar.

Error in LaunchVehicleEvent/cleanupEvent (line 149)


Error in LaunchVehicleScript/executeScript (line 213)


Error in ma_LvdMainGUI>propagateScript (line 130)


Error in ma_LvdMainGUI>openMissionPlanMenu_Callback (line 771)


Error in ma_LvdMainGUI>openMissionPlanToolbar_ClickedCallback (line 903)


Error in gui_mainfcn (line 95)


Error in ma_LvdMainGUI (line 42)


Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)ma_LvdMainGUI('openMissionPlanToolbar_ClickedCallback',hObject,eventdata,guidata(hObject))

Error using waitforallfiguresclosed (line 9)
Error while evaluating PushTool ClickedCallback.

 

 

Thanks for the report!  You found a bug.  Everything related to the new drag code should be backwards compatible.  The code is supposed to take the old Cd values that are in the set drag action and update it to use the new interpolated scheme.  The Set Drag action is definitely supposed to be around still. :)

Anyway, I fixed the issue and I'm rebuilding the code now.  I'll update the previous PR10 zip file with the fix when it's built and edit this post then.

EDIT: Should be good to go, redownload PR10.

Edited by Arrowstar
Link to comment
Share on other sites

Just now, Drew Kerman said:

Yup much better thanks.

Also is it just me or did the icon change?

TEiGr4x.png

Not just you.  I've been having some issues recently with MATLAB's packaging tool, and the error always seems to be that it can't find the icon for the software.  I need to try and fix that for the next release.

Link to comment
Share on other sites

great mod! Im still learning but will be great

I am using RSS+ principia and tred to change input into plug in, but in the bodies.ini the file is laking of several bodies, like uranus, neptune, pluto. Is anything that I did wrong?

Link to comment
Share on other sites

3 hours ago, robertordf said:

great mod! Im still learning but will be great

I am using RSS+ principia and tred to change input into plug in, but in the bodies.ini the file is laking of several bodies, like uranus, neptune, pluto. Is anything that I did wrong?

Can you post a link to your bodies.ini file?

Link to comment
Share on other sites

@Arrowstar I don't like asking this but while I don't need the "in/out tangent" curves to be implemented for this upcoming mission at the end of the month, I do need to know if you can do them at some point or not. Again, I do not need LVD for this upcoming mission I just need to know whether I can use LVD with the BetterSRB curves at some point, otherwise I will make my own and stick to that. But until I know either way I can't do anything :P

Also in case you missed OhioBob replying to me, my request of making the curves go beyond 100% is no longer a thing that's needed

Edited by Drew Kerman
Link to comment
Share on other sites

2 hours ago, Drew Kerman said:

@Arrowstar I don't like asking this but while I don't need the "in/out tangent" curves to be implemented for this upcoming mission at the end of the month, I do need to know if you can do them at some point or not. Again, I do not need LVD for this upcoming mission I just need to know whether I can use LVD with the BetterSRB curves at some point, otherwise I will make my own and stick to that. But until I know either way I can't do anything :P

Tangents doesn't look like it's going to be possible, sorry.  The curve fitting code I use doesn't support them.  That said, if you get the absolute values of the points in there, it should be close enough I would think for what you're doing.  Give it a try, anyway, and see if it works. :)

Link to comment
Share on other sites

12 hours ago, Matthia said:

@Arrowstar

In the LVD tutorial, page 11, a refference is made to an excel file, where can i find this file?

("The Excel file that was used to generate this table is included with this tutorial for your perusal as needed."

 

Looks like I removed that file from the package.  I'm guessing that when I created the Vehicle Sizing Tool in KSPTOT, that spreadsheet (which did the same thing as VST and was its inspiration) was taken out.  For the moment, just keep trucking on the tutorial.  The spreadsheet was only informational. :)

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