Giter VIP home page Giter VIP logo

arrowstar / ksptot Goto Github PK

View Code? Open in Web Editor NEW
85.0 6.0 13.0 1.03 GB

KSP Trajectory Optimization Tool

License: Other

MATLAB 54.99% Objective-C 0.01% C 1.27% Batchfile 0.04% M 0.07% C++ 0.06% AMPL 0.35% HTML 0.65% Shell 0.01% Ruby 0.01% JetBrains MPS 42.46% KerboScript 0.10%
astrodynamics astrodynamics-calculations astronomical-algorithms ksp ksp-kos ksp-mods orbital-dynamics space-mission space-mission-design kerbal-space-program kerbalspaceprogram trajectory-analysis trajectory-optimization

ksptot's Introduction

Open in MATLAB Online

ksptot's People

Contributors

arrowstar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ksptot's Issues

Missing key in dictionary when running createDragData.ks

Attempting to create drag profiles for an Eve lander using Ren0k's Atmospheric Drag Project and the kOS scripts provided with TOT, I encountered a number of errors, the first one being that createDragData.ks (from TOT) tried to run a non-existent file "Telemetry.ks." After some tinkering, I figured out that Ren0k has (I think) updated his project in a way that restructures the directories, gets rid of Telemetry.ks, and puts required functions from it into different places (in particular I found I needed the contents of "Vectors.ks"

I have attached an edited version of the createDragData.ks* script (with edited instructions in the header) which runs without errors. I need to do some testing to figure out if the output .csv file has the correct information. I noticed that column D (which I see in the script holds CdACube) was all zeros after a test run on a ship I made, but maybe that's normal.

*As .txt because github doesn't like .ks and .txt runs anyways.
createDragData_MODIFIED.txt

Mission Architect won't iterate over coast event with anomaly

KSP TOT version - 1.6.2

Sometimes Mission Architect can't find more or less obvious solution. In attached example Optimizer is unable to find correct true anomaly and prograde dV for transmunar injection trajectory. This bug manifests itself in diffirent situations and only thing that helps is to manually set true anomaly insted of using it as optimization variable.

STR:
1
Setup following scenario:

  • use default initial state (Kerbin, SMA 700 km, e=0, i=0, raan=0, aop=0)
  • add coast to true anomaly event (true anomaly = 0, optimization range = [0, 360])
  • add dV maneuver (prograde dV=800, optimization range = [0, 1000])
  • add cost to periapsis event (reference body = Mun)
  • set optimization function to "minimize distance to body", applicable event=4, applicable body=Mun

2
Run optimization

3
Observe how optmization function value does not goes below 11300 km

Expected result:
Burn true anomaly after optimization = 140 degree, Maneuver prograde after optimization ~ 840 m\s

ksptot.log
bug-wont-iterate-over-true-anomaly.zip

Flyby Maneuver Sequencer and Mission Architect Discrepancy

For some reason when I run the Sequencer to find flybys to visit multiple planets from one burn at Kerbin, the DeltaV data it gives me produces a very different orbit in the Mission Architect from the orbits shown in the Squencer. This issue occurred for two different flybys so it wasn't a one time thing. If you'd like to see it in action the dates and flybys are as follows: around 2/211 (year/date) and Eve>Dres, and 3/50 Eve>Duna. Thank you for the awesome program.

AeroBraking Help

So I am trying to aerobrake around jool. My altitude PE is at 106km which is defiantly inside the atmosphere but according to Mission Architect, It says it can't plan the aerobrake because I am not inside the atmosphere. I was wondering if I am doing something wrong or is they way I have setup not designed to calculate this. If you would like I can upload the .mat file for the plan. I have tried adding a coast after PE using a delta T and Next AP neither worked. Tried moving the aerobrake before Next PE Thanks for this tool made my cheap rocket designs easier to plan
untitled

P.S Sometimes it will do it but when I go to change it because the AP is not around where I would like it then goes back to this. Aka 106 PE was working and give me a AP of 206km but when I bump the PE up it no longer works

Mission Animator child bodies too small

I've been using the Mission Animator in some system-wide views and noticed the child bodies feature suffers from the same impairment the figure rendering used to have - they render too small to be seen at that scale. They should also be replaced by markers if the view gets far enough away.

Some Problems

_20190112143118

there some problems on the GUI ,also i can't set the launch window open

Remote host address is not persistent in MCC Real Time System "Select Vessel" window.

KSP TOT version - 1.6.2

STR:
1
Open KSP TOT and select

2
Select "MCC Real Time System" item from "KSP Real Time System" menu.

3
Type "192.168.1.1" (or any other address) into "Remote host" input field. Test connection.

4
Close and reopen KSP TOT

5
Note that when you go into MCC Real Time System "Select Vessel" window again, the Remote Host is reset to "localhost"

Why this is important option: KSP TOT is not very stable software and setting up Remote Host again and again when you using KSP TOT over LAN or Internet is frustrating.

Also, it woudn't be nice be able to change connection port (both in MCC settings somewhere and in KSPTOTConnect config).

Difference in LVD between 1.6.7 PR4 and PR5

I've noticed a large difference in LVD between PR4 and PR5 where PR5 appears to be broken. When opening the same file, PR5 starts from a different point and is unable to arrive at the same solution after optimization. I used LVD to create a mission with a gravity assist at Eve then 2 orbits before a gravity assist at Kerbin and then finally capture at Jool. The changes you made in 1.6.7 PR4 made this almost simple! The continuity constraints were violated but only by very small amounts. However, when I opened the same file in PR5, the starting position for the trajectory is very different, as seen in the images below, with PR4 on the left and PR5 on the right. The continuity constraints are now violated significantly.

PR4 to 5 diff

The starting point for the constraint violations in PR4:
constraints PR4

The starting point for the constraint violations in PR5:
constraints PR5

If I run an optimization on the file in PR5, this is about as close as I can get:
after opt

With constraints violated quite severely:
constraints PR5 after opt

TOT Connect needs updating for 1.1

Hi! Great tool; thanks for making it.

With the KSP 1.1 update, it seems that part(s) of TOT Connect no longer function. The 'upload selected DV maneuver' no longer works. No maneuver node is created in the game, and no error is reported either.

The debug menu in KSP says:

[Exception]: TypeLoadException: Could not load type 'Vector3d' from assembly 'Assembly-CSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

What I've tested and still works:

  • Get orbit of active vessel
  • Get masses of active vessel

P.S. You should add KSP TOT Connect as a github repository, or as a subfolder of this repository 😄

LVD applies changes to throttle/steering models in one event to throttle/steering models in another after loading saved mission

I set up a short Tylo lander ascent sequence in LVD involving two constant-thrust burns separated by a coast phase.
It has a sequence of 5 events: "Surface Stay," "Liftoff," "Ascent Stage 1 Burn," "Ascent Coast," and "Ascent Stage 2 Burn"
as well as a non-sequential event "Switch Steering Model."

The basic idea was that LVD would optimize the linear and accel terms of the steering models and the two constant throttle settings, and the coast duration so as to minimize mass in the Ascent Stage 1 tank while still achieving a certain minimum periapsis constraint at the end. This worked alright last night, with the optimizer finding a way to satisfy the constraints while lowering the tank mass. However, I noticed in pitch graphs that the rocket was doing flips at one point, obviously wasting delta-v. I thought I'd just fix it the next day, so saved it and closed TOT.

When I loaded the mission today, I made some adjustments to the bounds of the linear pitch term on the non-sequential steering event. I then ran the optimizer and noticed that it was optimizing more variables than it should have been. I stopped the optimizer, and started looking through the different events/actions. I noticed that for some reason LVD was now optimizing the steering model and throttle values in the Surface Stay, which should have been fixed constants pointing the rocket up relative to the surface with zero throttle. I fixed this, reran the optimizer, and saw it was now optimizing fewer variables than it should have been. Turned out the steering model values for the Switch Steering Model had been fixed to zero.
After several "fixes" I realized changes I applied to steering and throttle in one event
were being applied to the other events as well.
Deleting events and creating new ones does not seem to solve the problem.
There is an error in the log, however I think this may have simply been me clicking on the wrong close and save button (while a sub-window was still open), as it does not occur at the same frequency I was having the problem.
Log and LVD file below:
ksptot.log
https://drive.google.com/file/d/1AW6WJS8sXmxx6wvop4Ghl_Po_qlAKzyz/view?usp=sharing

Revs = 0 when actually >0

I haven't been able to work out a solid set of repro steps for this issue, but I have seen in pop up often while trying to recreate it. So it happens a lot, I just can't figure out a specific way to consistently trigger it.

The issue is that if I have a Coast event set to 1 for Revs Prior to Coast, at some point I will open the Edit Coast dialog for and it will show 0 for Revs Prior to Coast, yet Mission Architect will still render the orbit for 1 rev. If I just cancel out of the dialog nothing will change, but if I save the Rev value will reset to 0 as it was shown.

Here's the best I can give to set up MA for repro of the issue:

1 - set state by importing current active vessel data (the new feature you added).
2 - copy TA value
3 - save state
4 - create Coast to TA state and paste in TA value, set Revs to 1 and save

Once you've done that, sometimes I can immediately re-open the Edit Coast box and see 0 for Revs (even after creating a New file). If not, I've managed to trigger the issue in several other ways:

1 - edit the original state by importing new orbital data for the active vessel
2 - open the Edit Coast and changing the coast to Delta Time, then canceling out (Esc)
3 - various combinations of 1 & 2

Compute Departure Burn yields inefficient transfers

First of all, thank you for all your work on this tool. I tried to get into it but I ran into a number of issues. I tried to follow the Mission Architect tutorial for a simple transfer to Eve but I ran into problems:

  1. Computing the porkchop plot works as expected:
    grafik
  2. Now I click on "Compute Depature Burn". Here I run into the first issue: "Select Departure / Arrival Date" does not work - If I then click on the plot, I hear an error sound and nothing happens. However, I can enter the values of the clicked data point manually:
    grafik
  3. Clicking "Compute Departure Burn" and waiting 20 seconds yields the following:
    grafik

There is a clear discrepancy between the expected 1.100 m/s and the actual 1.900 m/s maneuvre. Also, the huge radial component could be avoided by simply executing the maneuvre a few minutes earlier on the orbit. Am I doing something wrong here?

I am using KSPTOT binaries v.1.6.9 and MATLAB runtime R2022a (9.12).

Calculated manuever values do not correspond with in-game values

I am trying to go to eve using the porkchop plot, however when I get to the final plugging in the manuever node, the imported manuever node does not arrive even closely to the predicted outcome. Here is a step by step of what I am doing:

I have a craft in orbit around kerbin at about 200kmx200km of altitude:
orbit

I punch in the vales and calculate the porkchop plot:
image

I compute the departure burn using my current orbit:
image

Already here something seems wrong because of that huge normal component:
image

I import the manuever using the import manuever tool using the values in the DV Manuever Information window:
image

But then ingame the manuever is completely off:
image

Could you tell me what I am doing wrong? Thanks

LVD: Leaving Kerbin SOI with 3000 m/s delta-v

I just tested LVD today and got my craft to leave Kerbin's SOI with 3000 m/s delta-v.

Engine Isp is 278.36 s (sea level and vacuum), payload mass is 2 t and fuel mass is 4 t.
So delta v = 278.36 s * 9.81 m/s^2 * ln(6/2) = 3000 m/s

The Wiki states as escape velocity over 3400 m/s (https://wiki.kerbalspaceprogram.com/wiki/Kerbin).

I didn't have time to figure out why it happens, but I noticed that the surface velocity is about an order of magnitude lower than it should be.

Here is the LVD file:
LeaveKerbinSOI.zip

linear lambert.m solver missing?

you've only got a ./helper_methods/astrodynamics/lambert.mexw64 file check in here, so on mac i get this:

is there a lambert.m for this anywhere?

Undefined function or variable 'lambert'.

Error in findOptimalDepartureArrivalObjFunc (line 13)
    [departVelocity,arrivalVelocity]=lambert(rVecD', rVecA', 1*timeOfFlight, numRevs, gmu);


Error in
findOptimalDepartArrivalFromPorkChop>@(arrivalUT,departUT)findOptimalDepartureArrivalObjFunc(arrivalUT,departUT,departBodyInfo,arrivalBodyInfo,gmu,quant2Opt)
(line 9)
    preFunc = @(arrivalUT, departUT) findOptimalDepartureArrivalObjFunc(arrivalUT, departUT, departBodyInfo, arrivalBodyInfo, gmu,
    quant2Opt);


Error in findOptimalDepartArrivalFromPorkChop>@(x)preFunc(x(1),x(2)) (line 10)
    objFunc = @(x) preFunc(x(1), x(2));


Error in fmincon (line 536)
      initVals.f = feval(funfcn{3},X,varargin{:});

Error in fmultistart

Error in MultiStart/run (line 268)
               fmultistart(problem,startPointSets,msoptions);

Error in multiStartCommonRun (line 18)
    [x,fval,exitflag,output,solutions] = run(ms,problem,numIter);


Error in findOptimalDepartArrivalFromPorkChop (line 47)
    [x,dv] = multiStartCommonRun(waitBarStr, tpoints, objFunc, x0, A, b, lb, ub, []);


Error in generatePorkChopPlot (line 75)
            [arrivalUT, departUT, dv] = findOptimalDepartArrivalFromPorkChop(ypos*(secInDay), xpos*(secInDay), departBodyInfo,
            arrivalBodyInfo, gmu, options.quant2Opt, departTimeArr, arrivalTimeArr);


Error in mainGUI>testPorkChopper_Callback (line 365)
        generatePorkChopPlot(handles.mainGUIFigure);

Error in gui_mainfcn (line 95)
        feval(varargin{:});

Error in mainGUI (line 42)
    gui_mainfcn(gui_State, varargin{:});

Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)mainGUI('testPorkChopper_Callback',hObject,eventdata,guidata(hObject))
 
Error while evaluating UIControl Callback

KSPTOT Does not launch; no executable running on Linux

When attempting to run run_KSPTrajectoryOptimizationTool.sh, the linux console seems to crash, but in reality it exits.
If I enter the shell script file and remove the exit line, I get this error code:

Setting up environment variables
---
LD_LIBRARY_PATH is .:/usr/local/MATLAB/R2022a//runtime/glnxa64:/usr/local/MATLAB/R2022a//bin/glnxa64:/usr/local/MATLAB/R2022a//sys/os/glnxa64:/usr/local/MATLAB/R2022a//sys/opengl/lib/glnxa64
bash: /bin/KSPTrajectoryOptimizationTool: No such file or directory

Attempting to run the executable file also fails with no running process.
If I use the full path to the executable I get this error code:

Setting up environment variables
---
LD_LIBRARY_PATH is .:/usr/local/MATLAB/R2022a//runtime/glnxa64:/usr/local/MATLAB/R2022a//bin/glnxa64:/usr/local/MATLAB/R2022a//sys/os/glnxa64:/usr/local/MATLAB/R2022a//sys/opengl/lib/glnxa64
/home/dupiter/Documents/KSPTOT/KSPTOT-linux/KSPTrajectoryOptimizationTool: error while loading shared libraries: libmwlaunchermain.so: cannot open shared object file: No such file or directory

Operating System: Arch Linux
KDE Plasma Version: 5.27.6
KDE Frameworks Version: 5.107.0
Qt Version: 5.15.10
Kernel Version: 6.4.1-zen2-1-zen (64-bit)
Graphics Platform: X11
Processors: 6 × Intel® Core™ i5-9400F CPU @ 2.90GHz
Memory: 31.3 GiB of RAM
Graphics Processor: NVIDIA GeForce RTX 2060 SUPER/PCIe/SSE2

A little problem with the display.

I don't know if anyone has reported this problem, but when selecting a planet, it appears to disappear. But the data still loads fine. (I may not be explaining this very clearly though, I will use a video below to show what I mean.)

bugreport.mp4

But this tool is really powerful and great, but I'm still learning how to use it and it does cost a lot to learn.

Cannot extract manoeuvers (I think?) on Mac OS X

I have Matlab R2018a and by hook or by crook I managed to rebuild the app. The porkchop plot works fine; however, whenever I attempt to extract manoeuver vectors from that (either from the main screen, or from the multi-flyby screen) I get the following stack trace:

Index exceeds array bounds.

Error in doApplyProj (line 23)


Error in applyProjection (line 13)


Error in lambert (line 29)


Error in findOptimalDepartureArrivalObjFunc (line 13)

(output truncated)

I truncated at the first line that differs between both situations i.e. when attempting to extract from the multi-flyby screen I would get instead

Error in getMultiFlybyXferOrbits (line 41)

LVD fails optimization with tank mass as variable

Earlier today I optimized an ascent steering profile for a Tylo lander, and noticed it had quite a bit of delta-v leftover once in orbit. In the interest of efficiency, I decided to let LVD optimize the tank mass to make the lander as light as possible while still reaching orbit with some minimum periapsis. The optimizer popped up the score card almost immediately with a supposed constraint violation of zero. However, a quick look at the tanks for the two stages showed it had just drained both of them almost exactly to half full, and when I exited the vehicle config tab, the script updated to show the lander didn't even get close to orbit.
I thought perhaps I was optimizing too many variables at once (in total there were 11 I think), but through testing I figured out the issue was just from the tank optimization, and could be triggered with a very trivial mission

Step 1) Create new LVD mission
Step 2) Go to Scenario->Edit Vehicle Configuration->Tanks->First Stage Tank, check optimize, and give it some wiggle room (I did 0 to 8 mT, nicely balanced around the 4 mT default).
Step 3) Set the single event to have a termination condition of the duration being 0 seconds, if it does not have this already.
Step 4) Set the objective function to be to minimize total spacecraft mass at the end of the single event.
Step 5) Run the optimizer.

The optimizer will "converge," but when you go to Scenario->Vehicle Configuration, you will see that the tank mass has not been minimized, but instead been either unchanged or set to something near the middle of the available range. I have so far tested this with FMINCON (interior point and SQP), NOMAD, and Pattern Search, with similar end results

ksptot.log

LVD Objective Function: "Distance to Ref. Celestial Body" always equals -1

When trying to minimize distance to a body in LVD, it always equals -1.
I tried it in a fresh mission and this was the result:

image

Also there seems to be no way to add a second (or third) objective function. It just won't get added to the list.

Are these known bugs that are about to be resolved?

Thank you,
Josef

KSPTOT halts when loading bodies.ini

I have a custom set up rescaled 6.4x/10.625x solar system using Sigma Dimensions. I also am using Minor Planets Expansion pack. I generated a new bodies.ini file, however when opening that new bodies.ini file the progress bar stops at 622/1215 and does not proceed any further. Only remedy is to close the program.

Attached are the offending bodies.ini file and log file.
bodies.zip

LVD: Engines not being applied to correct stage, cannot be deleted

Using v1.6.8 release, when adding engines to the Vehicle Configuration menu sometimes they do not apply to the assigned stage specified in the "Edit Engine" UI. They seem to apply to the first stage instead. Closing the UI and reloading maintains the correct Assigned Stage value in the "Edit Engine" UI, but does not correctly update the Launch Vehicle Summary. Engines that do this cannot be deleted either.

image

It looks to mostly happen when an engine is created on one stage, and then later switched to another.

LVD file that has the issue:
https://drive.google.com/file/d/1gpTsFe9QL4UlMPntXEBdszwoX8G96zDp/view?usp=sharing

LOG from trying to delete an affected engine:
ksptot.log

MA: Problem switching between finite duration maneuver

When you switch between proscribed maneuvers the software does the transformation (for example between Proscribed Dv Orbital Vector - Proscribed Dv Orbital Spherical) , but when you switch between finite duration maneuvers (for example between ''Finite Duration Orbital Spherical'' - ''Finite Duration Orbital Vector'') the software does not do the transformation, and the boxes always keep the same values, so the ''azimuth'' value becomes the new ''Prograde Dv'' value.

Given Orbital Vectors is the only way to upload maneuvers to KSP and ''Orbital Spherical'' is the only way to optimize your trajectory for a given DV value... There is a problem there.

Edit: Maybe ''Orbital spherical'' isn't the only way to optimize for a given DV, not sure.

Help->About dialog does not open

ksptot version: 1.6.2
OS: Linux

The Help->About dialog does not open. An error appears in the console:

tuupertunut@tuupertunut-fuksilappari:~/Desktop/ksptot$ ./run_KSPTrajectoryOptimizationTool.sh /usr/local/MATLAB/R2017b
------------------------------------------
Setting up environment variables
---
LD_LIBRARY_PATH is .:/usr/local/MATLAB/R2017b/runtime/glnxa64:/usr/local/MATLAB/R2017b/bin/glnxa64:/usr/local/MATLAB/R2017b/sys/os/glnxa64:/usr/local/MATLAB/R2017b/sys/opengl/lib/glnxa64
Error using imread
File "images\testlogo.png" does not exist.

Error in imread


Error in helpAboutGUI>helpAboutGUI_OpeningFcn (line 66)


Error in gui_mainfcn (line 220)


Error in helpAboutGUI (line 42)


Error in mainGUI>aboutMenu_Callback (line 720)


Error in gui_mainfcn (line 95)


Error in mainGUI (line 42)


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

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

N-body Coast Guide?

You could add a small guide to how n-body coast works?

I have done some missions using standard coast at ksptot, but I have no idea how the n-body coast works, and when I replace the standard ones with the n-body I'm not able to make mission plans and everything goes crazy.

Could you at least give me a little explanation? As I said, I handle well with KSPTOT and I've read the tutorials. It would be great to be able to make my mission plans with Principia.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.