Jump to content

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


Recommended Posts

4 hours ago, Arrowstar said:

Hi everyone,

Tonight I'm pushing out KSPTOT v1.6.7 pre-release 7.  Here's the change log with some welcome updates:

Cool! I started it up. I guess it has bodies.ini built in? loaded the mun.mat fine, what is the orange plume? failed steering optimization attempts?  At first graphical analysis plots of altitude seemed to show nothing, but after running optimize mission the plots all had data.

hmm it wanted network access, said something about starting parallel workers, firewall popped, and it seemed to run anyway before I'd decided what to do.

 

I copied your mun.mat, closed LDV, loaded my bodies.ini which has Kerbin replaced by Mars data, opened LDV, loaded munCopy.mat, edited vehicle initial state to set it's frame to Kerbin (Mars), zeroed out all the lat lon alt velocities that appeared, save & close. I get a warning that drag model is disabled on events that exist in the atmos (Event 1) and that Min alt -1.0 has been reached or exceeded. I can make #2 go away by setting alt to 100 km, but that makes #1 go away also like I'm above the atmos. I added an Action to set drag with even termination on sol transition (never) which made the aero warning go away - is that the right thing to do?

Edited by DBowman
more info
Link to comment
Share on other sites

9 hours ago, Arrowstar said:

Hi everyone,

Tonight I'm pushing out KSPTOT v1.6.7 pre-release 7.  Here's the change log with some welcome updates:

  • LVD: Fixed bug with the time slider sucking up a bunch of CPU time after sliding it around a bunch.
  • The missing parentID lines of the SolarSystemBodies.ini file have been added.
  • LVD: Added a linear tangent steering model to the available options in LVD.  This is a great way to get an optimal ascent from the surface of a body to space, as the linear tangent steering law is actually derived directly from optimal control theory.  As of now, only "pitch" type angles can use this steering.
    • The linear tangent steering law is: tan(pitch_angle) = a*t + b, where t is time after the steering law is initiated and a and b are constants.
    • There is a new lvd example MAT file that shows how to use it, and best of all, shows how it can be used to get off of the Mun in a single event!  I've included this in the pre-release.
  • MA/LVD: Added a flight path angle graphical analysis task and constraint.  For reasons that I still want to understand better, setting up your launch vehicle orbit insertion targets as radius/velocity/flight path angle works way better with an optimizer than asking for SMA/eccentricity or apogee/perigee.  I've noticed this in my professional life too. :)
  • There may be some performance improvements with computing atmospheric temperatures over the previous PR, but I've had trouble determining if they're real or not, so your mileage may vary.

Please let me know if you have any questions or find any bugs, especially with the new linear tangent steering code.  Thanks!

I can't even launch LVD on this version.  The loading msgbox appears, and a few moments later I get a beep and this output on the log:

./run_KSPTrajectoryOptimizationTool.sh /usr/local/MATLAB/R2017b/v93        
------------------------------------------
Setting up environment variables
---
LD_LIBRARY_PATH is .:/usr/local/MATLAB/R2017b/v93/runtime/glnxa64:/usr/local/MATLAB/R2017b/v93/bin/glnxa64:/usr/local/MATLAB/R2017b/v93/sys/os/glnxa64:/usr/local/MATLAB/R2017b/v93/sys/opengl/lib/glnxa64






Subscript indices must either be real positive integers or logicals.

Error in colorFromColorMap (line 5)


Error in ma_initOrbPlot (line 17)


Error in Generic3DTrajectoryViewType/plotStateLog (line 228)


Error in LaunchVehicleViewProfile/plotTrajectory (line 88)


Error in LaunchVehicleViewSettings/plotTrajectoryWithActiveViewProfile (line 25)


Error in lvd_processData (line 14)


Error in ma_LvdMainGUI>ma_LvdMainGUI_OpeningFcn (line 124)


Error in gui_mainfcn (line 220)


Error in ma_LvdMainGUI (line 40)


Error in mainGUI>launchVehicleDesignerMenu_Callback (line 916)


Error in gui_mainfcn (line 95)


Error in mainGUI (line 42)


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

Error using waitforallfiguresclosed (line 9)
Error while evaluating Menu Callback.

 

Just starting KSP-TOT and trying to open LVD will lead to that ^

Link to comment
Share on other sites

7 hours ago, DBowman said:

I copied your mun.mat, closed LDV, loaded my bodies.ini which has Kerbin replaced by Mars data, opened LDV, loaded munCopy.mat, edited vehicle initial state to set it's frame to Kerbin (Mars), zeroed out all the lat lon alt velocities that appeared, save & close. I get a warning that drag model is disabled on events that exist in the atmos (Event 1) and that Min alt -1.0 has been reached or exceeded. I can make #2 go away by setting alt to 100 km, but that makes #1 go away also like I'm above the atmos. I added an Action to set drag with even termination on sol transition (never) which made the aero warning go away - is that the right thing to do?

The first warning is because I disabled the drag model when this was for the Mun, since calling that needlessly just slows the simulation down a bit.  You need to turn it back on for Mars.  The second (min altitude reached) is because you're crashing.  Makes sense, the steering was set up for a munar mission but you're on a completely different body now.  Play around with adjusting the a term in the linear tangent steering law until you get something that gets you out of the atmosphere.

2 hours ago, vitorboschi said:

I can't even launch LVD on this version.  The loading msgbox appears, and a few moments later I get a beep and this output on the log:


./run_KSPTrajectoryOptimizationTool.sh /usr/local/MATLAB/R2017b/v93        
------------------------------------------
Setting up environment variables
---
LD_LIBRARY_PATH is .:/usr/local/MATLAB/R2017b/v93/runtime/glnxa64:/usr/local/MATLAB/R2017b/v93/bin/glnxa64:/usr/local/MATLAB/R2017b/v93/sys/os/glnxa64:/usr/local/MATLAB/R2017b/v93/sys/opengl/lib/glnxa64






Subscript indices must either be real positive integers or logicals.

Error in colorFromColorMap (line 5)


Error in ma_initOrbPlot (line 17)


Error in Generic3DTrajectoryViewType/plotStateLog (line 228)


Error in LaunchVehicleViewProfile/plotTrajectory (line 88)


Error in LaunchVehicleViewSettings/plotTrajectoryWithActiveViewProfile (line 25)


Error in lvd_processData (line 14)


Error in ma_LvdMainGUI>ma_LvdMainGUI_OpeningFcn (line 124)


Error in gui_mainfcn (line 220)


Error in ma_LvdMainGUI (line 40)


Error in mainGUI>launchVehicleDesignerMenu_Callback (line 916)


Error in gui_mainfcn (line 95)


Error in mainGUI (line 42)


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

Error using waitforallfiguresclosed (line 9)
Error while evaluating Menu Callback.

 

Just starting KSP-TOT and trying to open LVD will lead to that ^

I have seen this before but I can't reliably reproduce it.  In any event, it usually only happens once.  Try starting LVD again and it should be okay.  I'll keep digging into what might be causing it...

Link to comment
Share on other sites

@Arrowstar some more info about the problem:

- it seems like I can reliably reproduce it here (happened 5 of 5 tries)

- Happens only the first time I try to open LVD after launching KSP-TOT. If I try a second time, it seems to load the window, but something is broken. No events are shown when I load an example (tried a few) and the graph is not drawn. There's also this error log:

Reference to non-existent field 'hDispAxesTimeSlider'.

Error in ma_LvdMainGUI>propagateScript (line 188)


Error in ma_LvdMainGUI>runScriptMenu_Callback (line 1627)


Error in gui_mainfcn (line 95)


Error in ma_LvdMainGUI (line 42)


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

Error using waitforallfiguresclosed (line 9)
Error while evaluating Menu Callback.

 

Maybe the issue is related to the changes you made on the time slider?

 

In any case, let me know if there's anything I can try to help you finding the problem.

Link to comment
Share on other sites

2 minutes ago, vitorboschi said:

@Arrowstar some more info about the problem:

- it seems like I can reliably reproduce it here (happened 5 of 5 tries)

- Happens only the first time I try to open LVD after launching KSP-TOT. If I try a second time, it seems to load the window, but something is broken. No events are shown when I load an example (tried a few) and the graph is not drawn. There's also this error log:


Reference to non-existent field 'hDispAxesTimeSlider'.

Error in ma_LvdMainGUI>propagateScript (line 188)


Error in ma_LvdMainGUI>runScriptMenu_Callback (line 1627)


Error in gui_mainfcn (line 95)


Error in ma_LvdMainGUI (line 42)


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

Error using waitforallfiguresclosed (line 9)
Error while evaluating Menu Callback.

 

Maybe the issue is related to the changes you made on the time slider?

 

In any case, let me know if there's anything I can try to help you finding the problem.

Yeah, when LVD errors on load,  you'll see that broken UI.  Are you able to get LVD to properly load at all?

Link to comment
Share on other sites

3 minutes ago, Arrowstar said:

Yeah, when LVD errors on load,  you'll see that broken UI.  Are you able to get LVD to properly load at all?

No, the problem happened every single time. A bit more info: LVD window doesn't show up at the 1st, 3rd, 5th.... tries. On the others, the window does show up, but it's broken, as I described.

Link to comment
Share on other sites

9 minutes ago, vitorboschi said:

No, the problem happened every single time. A bit more info: LVD window doesn't show up at the 1st, 3rd, 5th.... tries. On the others, the window does show up, but it's broken, as I described.

Alright, I'm working on what is hopefully a fix and I should have a new build of PR7 up soon-ish for you to test.

Link to comment
Share on other sites

59 minutes ago, vitorboschi said:

No, the problem happened every single time. A bit more info: LVD window doesn't show up at the 1st, 3rd, 5th.... tries. On the others, the window does show up, but it's broken, as I described.

Okay, try downloading PR7 again and see if it works.  I've updated the Windows binary.

Link to comment
Share on other sites

Well, learning about what's wrong and how to see what's wrong, but still stuck...

I added a "Drag" sequential even to turn it on, I didn't see where you had turned it off.

Using the graphs I can see that the vehicle starts at 0 and sinks from there. The pitch angle is a constant 85 degrees, which seems "okay for now". I looked at throttle and it's set constant at around 22%, so the TWR starts at 0.265 and increases as prop is burnt. 3 t m0 so for Mars 11,133 kN required for TWR 1, throttle 0.22*35kN = 7,700 kN should be higher than 0.26 TWR. hmm Atmospheric pressure is 101 kPa.

So it looks like it thinks it's on actual Kerbin, even through I am pretty sure I loaded up a bodies.ini where Kerbin had Mars data pasted over it (because of the hang when starting with ).

I quit out completely. Started KSPTOT. Loaded Mars bodies. Started LDV, it said "trying to do something with parallel workers", I could see the initial SMA was 1600 odd which fits Mars, when the workers dialog disappeared it did some calcs, and SMA had changed to 300 - fitting actual Kerbin. Does the LDV or the mission somehow have some cached bodies info? I reset the vehicle initial state frame to Mun then Kerbin again, it "finds" KSP Kerbin SMA.

Place a SolarSytem bodies.ini in the directory, restart KEPTOT. Load bodies.ini, see Earth and Mars in the porckchop window,  compute a porkchop fine, start LDV, the please wait dialog pops, ..... seems to hang

I put bodies.ini and MMAV.mat (your lunar thing minimally modified) here https://drive.google.com/file/d/1JumVLQtyLIBADzxow4aRu5LKL3V0zAV-/view?usp=sharing

log shows:

Operands to the || and && operators must be convertible to logical scalar values.

Error in KSPTOT_BodyInfo/getParBodyInfo (line 115)


Error in KSPTOT_BodyInfo/getCachedSoIRadius (line 149)


Error in getSoITransitionOdeEvents (line 31)


Error in AbstractPropagator.odeEvents (line 81)


Error in ForceModelPropagator>@(t,y)AbstractPropagator.odeEvents(t,y,eventInitStateLogEntry,eventTermCondFuncHandle,termCondDir,maxT,checkForSoITrans,nonSeqTermConds,nonSeqTermCauses,minAltitude,celBodyData) (line 61)


Error in ForceModelPropagator/callEventsFcn (line 70)


Error in LaunchVehicleSimulationDriver/integrateOneEvent (line 119)


Error in LaunchVehicleEvent/executeEvent (line 162)


Error in LaunchVehicleScript/executeScript (line 293)


Error in ma_LvdMainGUI>propagateScript (line 175)


Error in ma_LvdMainGUI>runScript (line 150)


Error in ma_LvdMainGUI>ma_LvdMainGUI_OpeningFcn (line 123)


Error in gui_mainfcn (line 220)


Error in ma_LvdMainGUI (line 40)


Error in mainGUI>launchVehicleDesignerMenu_Callback (line 916)


Error in gui_mainfcn (line 95)


Error in mainGUI (line 42)


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

Error using waitforallfiguresclosed (line 9)
Error while evaluating Menu Callback.

 I added Kerbin to my Solar System bodies.ini - that let LDV start up. But the Edit Initial State set from options popup is full of KSP solar system! So I guess that is where the "cached Kerbin" was coming from?

Link to comment
Share on other sites

8 hours ago, DBowman said:

Well, learning about what's wrong and how to see what's wrong, but still stuck...

I added a "Drag" sequential even to turn it on, I didn't see where you had turned it off.

Using the graphs I can see that the vehicle starts at 0 and sinks from there. The pitch angle is a constant 85 degrees, which seems "okay for now". I looked at throttle and it's set constant at around 22%, so the TWR starts at 0.265 and increases as prop is burnt. 3 t m0 so for Mars 11,133 kN required for TWR 1, throttle 0.22*35kN = 7,700 kN should be higher than 0.26 TWR. hmm Atmospheric pressure is 101 kPa.

So it looks like it thinks it's on actual Kerbin, even through I am pretty sure I loaded up a bodies.ini where Kerbin had Mars data pasted over it (because of the hang when starting with ).

I quit out completely. Started KSPTOT. Loaded Mars bodies. Started LDV, it said "trying to do something with parallel workers", I could see the initial SMA was 1600 odd which fits Mars, when the workers dialog disappeared it did some calcs, and SMA had changed to 300 - fitting actual Kerbin. Does the LDV or the mission somehow have some cached bodies info? I reset the vehicle initial state frame to Mun then Kerbin again, it "finds" KSP Kerbin SMA.

Place a SolarSytem bodies.ini in the directory, restart KEPTOT. Load bodies.ini, see Earth and Mars in the porckchop window,  compute a porkchop fine, start LDV, the please wait dialog pops, ..... seems to hang

I put bodies.ini and MMAV.mat (your lunar thing minimally modified) here https://drive.google.com/file/d/1JumVLQtyLIBADzxow4aRu5LKL3V0zAV-/view?usp=sharing

log shows:

Operands to the || and && operators must be convertible to logical scalar values.

Error in KSPTOT_BodyInfo/getParBodyInfo (line 115)


Error in KSPTOT_BodyInfo/getCachedSoIRadius (line 149)


Error in getSoITransitionOdeEvents (line 31)


Error in AbstractPropagator.odeEvents (line 81)


Error in ForceModelPropagator>@(t,y)AbstractPropagator.odeEvents(t,y,eventInitStateLogEntry,eventTermCondFuncHandle,termCondDir,maxT,checkForSoITrans,nonSeqTermConds,nonSeqTermCauses,minAltitude,celBodyData) (line 61)


Error in ForceModelPropagator/callEventsFcn (line 70)


Error in LaunchVehicleSimulationDriver/integrateOneEvent (line 119)


Error in LaunchVehicleEvent/executeEvent (line 162)


Error in LaunchVehicleScript/executeScript (line 293)


Error in ma_LvdMainGUI>propagateScript (line 175)


Error in ma_LvdMainGUI>runScript (line 150)


Error in ma_LvdMainGUI>ma_LvdMainGUI_OpeningFcn (line 123)


Error in gui_mainfcn (line 220)


Error in ma_LvdMainGUI (line 40)


Error in mainGUI>launchVehicleDesignerMenu_Callback (line 916)


Error in gui_mainfcn (line 95)


Error in mainGUI (line 42)


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

Error using waitforallfiguresclosed (line 9)
Error while evaluating Menu Callback.

 I added Kerbin to my Solar System bodies.ini - that let LDV start up. But the Edit Initial State set from options popup is full of KSP solar system! So I guess that is where the "cached Kerbin" was coming from?

A few things:

  1. The error you see is because the bodies.ini file is missing the parentID line for a body.  You need to add that: "parentID = 0" most likely, but just grab whatever you're using for the ID of the Sun.
  2. You can load bodies files from the main KSPTOT File menu.  There's no need to hack them or whatnot. :)
  3. Yes, LVD and MA cache their celestial body data so that changes the user makes to what's in memory at any given time don't disrupt the current mission plan.
Link to comment
Share on other sites

Could I ask a favor from a few people who use KSPTOT regularly?  I'm looking to decide whether or not its worth upgrading to MATLAB R2020b, which is the latest release.  The biggest driver here is performance in Launch Vehicle Designer.  Here's what I need:

  1. Download the KSPTOT v1.6.7 PR7 R2020b package.
  2. Navigate to the following page: https://www.mathworks.com/products/compiler/matlab-runtime.html
  3. Download from (2) the R2020b (9.9) MCR package for your operating system.
  4. Install the just downloaded MCR package.
  5. Open the R2020b PR7 package, unzip to a directory, and run the executable for your operating system as normal to start KSPTOT.
  6. Open LVD.
  7. Open the "lvdExample_TwoStageToOrbit.mat" file in LVD.
  8. Tap control-p a few times until the script run time shown in the information window stabilizes (should be 5-6 times at least).
  9. Paste those times here in a post.
  10. Repeat steps 5-9 with the R2017b KSPTOT v1.6.7 PR7 package (previously posted a few days ago).  The same MAT file used in step (7) should work for both versions of the pre-release.
  11. Please also post your operating system, CPU model, and amount of RAM if you could, please.

What I'm after is trying to see if there's any appreciable speed up or slow down in script execution time between the two versions.  If we see a good speed up, then it might be worth jumping versions.  If not, then it's probably not worth the time and resources to upgrade MATLAB.

Thanks for your help, everyone!

Link to comment
Share on other sites

35 minutes ago, Arrowstar said:

Could I ask a favor from a few people who use KSPTOT regularly?  I'm looking to decide whether or not its worth upgrading to MATLAB R2020b, which is the latest release.  The biggest driver here is performance in Launch Vehicle Designer.  Here's what I need:

  1. Download the KSPTOT v1.6.7 PR7 R2020b package.
  2. Navigate to the following page: https://www.mathworks.com/products/compiler/matlab-runtime.html
  3. Download from (2) the R2020b (9.9) MCR package for your operating system.
  4. Install the just downloaded MCR package.
  5. Open the R2020b PR7 package, unzip to a directory, and run the executable for your operating system as normal to start KSPTOT.
  6. Open LVD.
  7. Open the "lvdExample_TwoStageToOrbit.mat" file in LVD.
  8. Tap control-p a few times until the script run time shown in the information window stabilizes (should be 5-6 times at least).
  9. Paste those times here in a post.
  10. Repeat steps 5-9 with the R2017b KSPTOT v1.6.7 PR7 package (previously posted a few days ago).  The same MAT file used in step (7) should work for both versions of the pre-release.
  11. Please also post your operating system, CPU model, and amount of RAM if you could, please.

What I'm after is trying to see if there's any appreciable speed up or slow down in script execution time between the two versions.  If we see a good speed up, then it might be worth jumping versions.  If not, then it's probably not worth the time and resources to upgrade MATLAB.

Thanks for your help, everyone!

Sure, here are my results:

KSP TOT Launch Vehicle Designer v1.6.7 PR7 (R2017b)                                          
Written By Arrowstar (C) 2020                                                                
#############################################################################################
(14:30:47) Executed mission script in 0.095 seconds.                                         
(14:30:57) Loading mission case from                                                         
"/home/vitor/KSP-TOT/lvdExample_TwoStageToOrbit.mat"...Done.                                 
(14:31:10) Parallel optimization mode enabled.                                               
(14:31:15) Executed mission script in 2.486 seconds.                                         
(14:31:28) Executed mission script in 1.344 seconds.                                         
(14:31:34) Executed mission script in 1.272 seconds.                                         
(14:31:39) Executed mission script in 1.248 seconds.                                         
(14:31:44) Executed mission script in 1.294 seconds.                                         
(14:31:49) Executed mission script in 1.195 seconds.                                         
(14:31:58) Executed mission script in 1.187 seconds.                                         
(14:32:05) Executed mission script in 1.195 seconds.                                         
(14:32:14) Executed mission script in 1.197 seconds.


KSP TOT Launch Vehicle Designer v1.6.7 PR7 (R2020b)                                          
Written By Arrowstar (C) 2020                                                                
#############################################################################################
(14:34:33) Executed mission script in 0.087 seconds.                                         
(14:34:52) Loading mission case from                                                         
"/home/vitor/KSP-TOT/lvdExample_TwoStageToOrbit.mat"...Done.                                 
(14:35:05) Parallel optimization mode enabled.                                               
(14:35:09) Executed mission script in 2.666 seconds.                                         
(14:35:13) Executed mission script in 1.430 seconds.                                         
(14:35:16) Executed mission script in 1.244 seconds.                                         
(14:35:21) Executed mission script in 1.207 seconds.                                         
(14:35:24) Executed mission script in 1.288 seconds.                                         
(14:35:28) Executed mission script in 1.192 seconds.                                         
(14:35:35) Executed mission script in 1.199 seconds.                                         
(14:35:40) Executed mission script in 1.184 seconds.                                         
(14:35:45) Executed mission script in 1.187 seconds.      

Machine info:

RAM: 48 GB

CPU: Intel Core i7 7700K

OS: Linux 64 bits (Ubuntu 18.04)

Link to comment
Share on other sites

10 hours ago, Arrowstar said:

A few things:

  1. The error you see is because the bodies.ini file is missing the parentID line for a body.  You need to add that: "parentID = 0" most likely, but just grab whatever you're using for the ID of the Sun.
  2. You can load bodies files from the main KSPTOT File menu.  There's no need to hack them or whatnot. :)
  3. Yes, LVD and MA cache their celestial body data so that changes the user makes to what's in memory at any given time don't disrupt the current mission plan.

Thanks

2: yep I'd figured that out

1: parentID missing for Jupiter out, so I fixed those. Start KSPTOT: SolarSystem in porkchop plotter, open LVD: SolarSystem in vehicle initial state set frame options, Load your Mun .mat: KerbalSolarSystem in vehicle initial state set frame options. Um so how does one replace the solar system in an existing mission design? Do I need to start from scratch, replicating your mission .mat but in RealSolarSystem? Does that mean that if one is in the middle of designing a complex mission and discovers a small error in bodies (e.g. some pressure height error) then one has to start over?

Link to comment
Share on other sites

17 minutes ago, DBowman said:

Thanks

2: yep I'd figured that out

1: parentID missing for Jupiter out, so I fixed those. Start KSPTOT: SolarSystem in porkchop plotter, open LVD: SolarSystem in vehicle initial state set frame options, Load your Mun .mat: KerbalSolarSystem in vehicle initial state set frame options. Um so how does one replace the solar system in an existing mission design? Do I need to start from scratch, replicating your mission .mat but in RealSolarSystem? Does that mean that if one is in the middle of designing a complex mission and discovers a small error in bodies (e.g. some pressure height error) then one has to start over?

You cannot replace a solar system in an existing mission because the various bodies that are in that solar system are referenced by various parts of the mission internally.  So yes, in general you do need to make sure that you get your solar system in order before starting a mission, or you will be starting over.

Now, that said, there is technically a way to edit parameters of the solar system using plugins (LVD: Plugins -> Manage Plugins).  For example, you can create a new plugin, set it to run prior to propagation, and then (for example) put the following code in it to adjust Jool's radius:

lvdData.celBodyData.jool.radius = 6000;

Run this one and then turn off the plugin, as the changes will be permanent in memory.  The various data structures are viewable through the "Show Plugin Data Explorer" button.  Plugins are written using MATLAB code and are executed by MATLAB like any other code in KSPTOT.

You can technically rewrite the whole solar system this way, including adding and removing bodies, but I'd caution you against doing this too extensively.  Plugins are unfiltered MATLAB code (with a few exceptions to make sure nothing malicious runs on a computer and deletes files or things like that).  They can corrupt your MAT file if you don't know what you're doing.

Link to comment
Share on other sites

3 hours ago, Arrowstar said:

You cannot replace a solar system in an existing mission because the various bodies that are in that solar system are referenced by various parts of the mission internally.  So yes, in general you do need to make sure that you get your solar system in order before starting a mission, or you will be starting over.

Now, that said, there is technically a way to edit parameters of the solar system using plugins (LVD: Plugins -> Manage Plugins).  For example, you can create a new plugin, set it to run prior to propagation, and then (for example) put the following code in it to adjust Jool's radius:


lvdData.celBodyData.jool.radius = 6000;

Run this one and then turn off the plugin, as the changes will be permanent in memory.  The various data structures are viewable through the "Show Plugin Data Explorer" button.  Plugins are written using MATLAB code and are executed by MATLAB like any other code in KSPTOT.

You can technically rewrite the whole solar system this way, including adding and removing bodies, but I'd caution you against doing this too extensively.  Plugins are unfiltered MATLAB code (with a few exceptions to make sure nothing malicious runs on a computer and deletes files or things like that).  They can corrupt your MAT file if you don't know what you're doing.

Ah, that is kind of what I was afraid of. In my case it's not too bad, the mission is a few actions/events and my vehicle is simple, but it would be hard on someone doing something complex  and finding a trivial error in the bodies file. I guess the "hack" you suggest would cover simple point errors.

Thanks for your help. I'll start one from scratch in RealSolarSystemBodies.ini. 

Do you want to take contributions to fleshing out the real solar system?

Mars pressure heights? Are the atmos temperatures likely to be significant? Mars is pretty thin? I just want to see an SSTO get up

Ceres I have in mine now.

Link to comment
Share on other sites

R2020b:

Quote

(00:30:42) Executed mission script in 4.089 seconds.                                         
(00:31:06) Executed mission script in 2.012 seconds.                                         
(00:31:09) Executed mission script in 1.273 seconds.                                         
(00:31:11) Executed mission script in 1.267 seconds.                                         
(00:31:13) Executed mission script in 1.396 seconds.                                         
(00:31:15) Executed mission script in 1.393 seconds.                                         
(00:31:23) Executed mission script in 1.166 seconds.                                         
(00:31:27) Executed mission script in 1.238 seconds.                                         
(00:31:30) Executed mission script in 1.188 seconds.                                       

R2017b:

Quote

(00:35:35) Executed mission script in 3.397 seconds.                                         
(00:35:44) Executed mission script in 1.566 seconds.                                         
(00:35:46) Executed mission script in 1.453 seconds.                                         
(00:35:48) Executed mission script in 1.290 seconds.                                         
(00:35:50) Executed mission script in 1.384 seconds.                                         
(00:35:52) Executed mission script in 1.269 seconds.                                         
(00:35:54) Executed mission script in 1.187 seconds.                                         
(00:35:56) Executed mission script in 1.250 seconds.                                         
(00:36:05) Executed mission script in 1.247 seconds.                                        

Win10 Pro x64
i7 4790K @ 4.2GHz
24GB RAM

Also, something happened to this LVD case file and it won't open. I rolled back all the way to 1.6.4 since I forgot when I made it but couldn't load it in anything. I know it ran fine the last time I used it so not sure what the heck happened to it

Link to comment
Share on other sites

Okay I loaded a SolarSytem bodies and tried to recreate your Mun LDV, but for Mars. I have shared them here

https://drive.google.com/file/d/1ae2BXL5JWITsOJX5t4bo2M37uDKTSQ8z/view?usp=sharing

well it seems to kind of end up somewhere... but I cannot figure out what is going on

Could you please take a look and see if you can help me out? I'm shooting for a 250x250 LMO

Link to comment
Share on other sites

9 hours ago, DBowman said:

Ah, that is kind of what I was afraid of. In my case it's not too bad, the mission is a few actions/events and my vehicle is simple, but it would be hard on someone doing something complex  and finding a trivial error in the bodies file. I guess the "hack" you suggest would cover simple point errors.

Thanks for your help. I'll start one from scratch in RealSolarSystemBodies.ini. 

Do you want to take contributions to fleshing out the real solar system?

Mars pressure heights? Are the atmos temperatures likely to be significant? Mars is pretty thin? I just want to see an SSTO get up

Ceres I have in mine now.

This is why I created a function to generate a bodies.ini file straight out of KSP.  Load KSP, get into the Flight Scene (where you can see a vehicle, maybe on the launch pad), and then in KSPTOT: File -> Create New Bodies File from KSP.  It pulls in all the relevant information for the solar system you're working with and then creates the text file for you so that you don't have to. :)

6 hours ago, DBowman said:

Okay I loaded a SolarSytem bodies and tried to recreate your Mun LDV, but for Mars. I have shared them here

https://drive.google.com/file/d/1ae2BXL5JWITsOJX5t4bo2M37uDKTSQ8z/view?usp=sharing

well it seems to kind of end up somewhere... but I cannot figure out what is going on

Could you please take a look and see if you can help me out? I'm shooting for a 250x250 LMO

I'll take a look.

Link to comment
Share on other sites

6 hours ago, DBowman said:

Okay I loaded a SolarSytem bodies and tried to recreate your Mun LDV, but for Mars. I have shared them here

https://drive.google.com/file/d/1ae2BXL5JWITsOJX5t4bo2M37uDKTSQ8z/view?usp=sharing

well it seems to kind of end up somewhere... but I cannot figure out what is going on

Could you please take a look and see if you can help me out? I'm shooting for a 250x250 LMO

There are a few issues with your file:

  1. Your radius constraint numbers look like altitudes.  Make it an altitude constraint instead.
  2. Your objective function is minimizing total vehicle mass when it should be maximizing it.
  3. Remove the "coast in orbit" event until you've got your ascent locked down.  It's just adding propagation time to the process.
  4. I don't think your vehicle has enough thrust or propellant mass to make this trajectory work.  You may want to look into that.
  5. I adjusted the minimum altitude the integrator tolerates to -1000 km because you were crashing during optimization so often.
  6. I added two events: an initial open-loop pitch over and a final fixed pitch rate event after the linear tangent steering. 
  7. I also adjusted the fmincon finite difference step size.  I had to play with this to get a decent idea of what it should be, but I think I got it nailed down now.

Anyway, I fixed up your ascent.  Take a look at the new MAT file here.  Keep in mind that what I did is only one way to do it, and you should play around to see if you can find a better way. 

Let me know if you have any other questions!

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