Jump to content

Arrowstar

Members
  • Posts

    2,549
  • Joined

  • Last visited

Everything posted by Arrowstar

  1. Thanks for the report. I think I've got all of them fixed and I'll get a new build out ASAP. Turns out they were pretty straight forward.
  2. Hey there, @antipro! This is probably a question that's better off asked on the KSPTOT thread so we don't clutter up @Krafpy's thread here: That said, to answer your questions: The departure maneuver from Kerbin can be "uploaded" to KSP directly by right clicking the "DV Maneuver Information" text box. The other maneuvers can't be "uploaded" in that way, though it's something I could pretty easily add. There's a caveat though: the assumptions used in MFMS that make the calculations fast also simplifies the dynamics model quite a bit and there's going to need to be a fair bit of hand-tuning involved in order to get the maneuvers to work out. The better process flow is to use your MFMS designed trajectory as a starting point and then model the trajectory in higher fidelity using Launch Vehicle Designer (which, at this point, is less than aptly named since it does everything Mission Architect can do and more lol). LVD actually models the spheres of influence of the bodies, which MFMS and similar tools cannot do, and you'll get much more precise results. If you need help with this, check out the LVD example mission file "lvdExample_ToEelooViaJool_BackPropExample.mat" that ships with KSPTOT and ask questions over on the KSPTOT thread I linked to above. Thanks!
  3. Yes, you can do that, but you'll need to be very careful about trajectory continuity. You'll also need to re-optimize your flyby times, DSM times and delta-vs, and the rest of it, using the lower fidelity model as a starting point, because once you introduce the higher fidelity models, the answer will change. I think I maybe see a flaw in your thinking about this problem in general. Why do we use the zero radius SoI assumption, and the instantaneous flyby assumption, and Lambert arcs, and all that? It's because it lets us quickly explore the problem space, find reasonable trajectory concepts, and then implement them in a higher fidelity tool. No one in the "real world" uses software like yours or like my MFMS tool to actually plan a real mission: it's all about exploring the problem space. Once a trajectory engineer has identified a good trajectory, they always move up to tools that can provide higher fidelity dynamics, like my KSPTOT Mission Architect or Launch Vehicle Designer tools, and rework the trajectory there. Because of all that, while you can certainly add more fidelity to your code, at some point you'll have to break away from the Lambert arc assumption. By all means, definitely dive into handling finite sized SOIs and celestial body motion and finite duration flybys and the like! I just don't know how long you'll be able to keep your tool "simple" (and the underlying code simple!) if you do. It'll be an interesting science experiment to find out.
  4. I believe I've fixed the issue and have uploaded the new executables. Can you go to the first post and re-download KSPTOT from the link there? Once you've done that, please let me know if that resolves your issue. Thanks!
  5. Local gravity wells are modeled as zero radius SOI with instantaneous flybys. It simplifies the problem space down into a bunch of Lambert arcs while still producing reasonable results. If people want to model more accurate trajectories, that's what KSPTOT's Mission Architect (and really, Launch Vehicle Designer, which has mostly filled the role of MA for some time now) is for. LVD numerically integrates equations of motion to produce trajectories and can model discrete vehicle stages, tanks, engines, electrical systems, and can propagate forwards and backwards in time to help make it easier to find those multiple gravity assist trajectories.
  6. Okay so I haven't had a chance to go through and really think about what you said earlier but I do have some thoughts. I'm not talking about multiple revolutions, I'm talking about the concept that every Lambert's problem, even the single rev cases, all have two solutions: one where the transfer angle is greater than 180 deg and one where it's less than 180 deg. If you're only using one of those solutions everywhere then you're going to have an issue because short way and long way can have radically different delta-v. Looking at the lambert code you're using, I think the input flag is the "const int &cw" input, though I've run into the ESA ACT's Lambert solver before and I've never been a big fan of their "clockwise" / "counterclockwise" notation. Anyway, what are you using for that parameter and have you tried changing it to verify that it works the way you think it does? I guess on top of that, you might consider playing around with the automatic bounding of the time of flight variables as well, if I'm reading your post correctly. It can be hard to pick generalized bounds that work for all cases. It might be worthwhile allowing the user to specify the upper and lower bounds for time of flight between bodies. That's all I've got for now, there's a lot of math to look at lol.
  7. So I tried a Kerbin - Eve - Jool - Eeloo flyby with your software tonight and compared it to KSPTOT. I end up with a total mission delta-v of 2.5 km/s. Yours seems to settle pretty consistently around 5.5 km/s - 6.0 km/s. A few questions that might help debug a bit: How many individuals are in your DE population? How are you bounding the optimization variables? Does your Lambert solver consider both long way and short way trajectories?
  8. By the way, everyone, I should mention that it's likely that we won't spend a lot of time on MATLAB R2021a. I've gotten a chance to play with the R2021b pre-release in a professional environment and there are some enticing new functions and functionality that I think I might want to bring into KSPTOT, especially Launch Vehicle Designer. I don't think I can say what right now (pre-release NDA) but when it releases next month I'll have a better idea of if it will be worth it. Stay tuned.
  9. Hi everyone! This morning I'm happy to announce the release of KSP Trajectory Optimization Tool v1.6.8! This is a major release that primarily focuses on adding additional functionality to Launch Vehicle Designer (LVD). A couple of the more interesting new items in LVD are: The "Halo Orbit Constructor". This is a tool that allows users of Principia and other "N-body" gravity mods to generate approximations for halo orbit that can then be easily exported to the rest of LVD for mission design and planning purposes. The "geometry system". This is a component of LVD which allows users to define and work with geometric elements in their LVD scenarios for graphical/view, optimization, vehicle steering, and Graphical Analysis. You can read more here. Celestial bodies can now be numerically integrated. This is useful when using "N-body" gravity mods such as Principia as they don't use the two-body motion for celestial bodies that stock KSP does. This release also showcases the migration of many of the KSPTOT user interface windows to MATLAB's new App Designer framework. Finally, and perhaps most importantly, this release migrates KSPTOT to MATLAB R2021a! The new LVD UI in the App Designer framework Here's the full change log: LVD: The function to export a kOS CSV file has been updated to allow users to select the event(s) they want to export. LVD: Introduction of the geometry system. Points, vectors, planes, angles, coordinate systems, and reference frames are now all user definable and can be integrated with views, optimization, and Graphical Analysis. LVD: The "launch vehicle" menu is now called "scenario," and the "edit launch vehicle" menu beneath it is now called "edit vehicle configuration." LVD: Added three new constraints: ground object elevation, azimuth, and range. MA: Mission Animator now properly rotates central celestial bodies. LVD: Added a new vector, vector projected onto a plane, to the geometry system. LVD: A few bug fixes and performance improvements. LVD: T2W throttle model now checks minimum throttle T2W as well as maximum. LVD: Sim Driver now warns if integrator output event index (ie) is empty. LVD: When editing non-seq events, the event UI now greys out any non-relevant widgets. LVD: Added a flight path angle event termination condition. LVD: Added a new "vector magnitude" constraint type. LVD: Added a new "angle magnitude" constraint type. Upgrade MATLAB version to R2021a. LVD: Incorporation of surrogate optimizer as an optimization method. LVD: New optimizer output for NOMAD and PatternSearch optimizers. LVD: Different steering models can be selected for each Euler angle now using the Selectable Model steering mode. LVD: All constraints now support the ability to evaluate themselves relative to the value of the same quantity at the end of another event. This is in addition to evaluating them relative to fixed bounds as well. Fixed an issue with importing the UT from KSPTOTConnect into the main KSPTOT user interface (the porkchop plot). LVD: Bug fixes to the 3rd body gravity model. LVD: Bug fixes to optimizing Cartesian elements. LVD: Graphical Analysis is now using the App Designer framework and sports a new look. LVD: All fluid types are now their own GA tasks. Main KSPTOT user interface window is now ported over to App Designer framework. LVD: Constraints and objective functions now are aware of and respect user selected reference frames when evaluating values. LVD: Added halo orbit examples. The L2 halo orbit example is a full mission from low Kerbin orbit to the halo orbit around the Mun! LVD: Added third body gravity validator that checks to see if third body gravity sources are active with no force model or if the 3rd body gravity force model is active with no bodies. LVD: Extrema, Calculus Calculation objects, ground objects, and geometry objects now respect reference frames when computing their values. LVD: View Settings dialog now moved over to App Designer framework and sports a new look! LVD: Added Halo Orbit Constructor tool (Tools -> Halo Orbit Constructor menu) LVD: Performance improvements to frame conversions. LVD: GA task list area now has a search box. LVD: Formal continuity constraints are replaced with state comparison constraints for position, velocity, and time. LVD: Event termination conditions now have ref frame awareness. LVD: Halo Orbit Constructor now shows arrival/departure transfer orbits too. LVD: Event actions can now be executed before or after propagation on events. LVD: Constraints can now be evaluated at either the initial state or final state of an event. Same goes for the state comparison constraints and the node of the comparison event. Converted a whole bunch of the standalone analysis tools (MFMS, RMS, OTBOC, etc) over to the App Designer framework. Celestial bodies can now be propagated using numerical integration in addition to two body propagation. LVD: Added an Open Recent Mission item to File menu LVD: Migrated main UI and numerous other UIs to App Designer framework. There are still a number of LVD UIs that still need to be migrated, but this is a start. LVD: Plotting state logs should now be a bit faster due to updated frame rotation behavior. Added UI progress bars when opening all tools from main KSPTOT UI. LVD: Major change to the Set Kinematic State action and the associated GUI. You can now set the states of the individual vehicle components, including stages, engines, tanks (and their associated tank masses!), electrical powers sources, sinks, and storage (including battery state of charge). Astrodynamics Tools UI migrated to App Designer framework LVD: Edit Event UI migrated to App Designer framework. LVD: Edit Event UI now has buttons to cycle back and forth through the events list. LVD: Edit Event Termination Condition UI migrated to App Designer framework. LVD: Non Sequential Event UI migrated to App Designer framework. LVD: Plugins can now be used as objective functions, constraints, and graphical analysis output. LVD: All UIs should now render centered on the screen. LVD: Double clicking an available task in GA now adds it to the list of tasks. LVD: Outputting the propagation time to console now includes a breakdown of time needed for propagation and actions. LVD: Missing LVD cases don't show up in the recent cases list (File menu) anymore. Numerous bug fixes and performance enhancements, especially in LVD. NOTE: If you are upgrading from KSPTOT v1.6.7 or earlier, you MUST download the R2021a MATLAB Compiler Runtime (MCR)! KSPTOT v1.6.8 will not run without this! You can find the R201a MCR download for your platform here: https://www.mathworks.com/products/compiler/matlab-runtime.html Finally, if you enjoy using KSPTOT and its many applications (the Porkchop Plotter, Multi-Flyby Maneuver Sequencer, Mission Architect, Launch Vehicle Designer, and all the rest), please consider buying me a coffee via my Ko-Fi account to support KSPTOT's development. As I note in the first post of this thread, KSPTOT is a labor of love that I have put many, many hundreds of hours into for the benefit of the KSP community. The best part of it for me, aside from knowing that KSPTOT is the premier mission design tool for KSP, is all the thank you notes I've received over the years. I offer this as another way to say "Thank you!", if you so desire. As usual, the release can be downloaded from the first post of this thread. Please let me know if you have any questions or find any bugs. Thanks, and happy orbiting!
  10. Powered flybys are a bit challenging, I agree. The idea is basically to figure out what the delta-v vector at flyby periapsis is that connects your inbound and outbound trajectories. I admit it took me a few weeks of getting the math worked out back in the day, but it works well now. I've actually considered adding DSMs to my software but powered flybys work pretty well and I just haven't been interested in doing it yet. I use a genetic algorithm as well. I've tried a few global optimization algorithms but GAs (or DE, same thing basically) seem to work the best. I definitely found that Direct Search methods and MATLAB's "Global Search" methods didn't work nearly as well.
  11. This is pretty neat, good work. It's interesting you went down the DSM route instead of the powered flyby route like I do in KSPTOT's MFMS tool. Was there a reason for that decision? Btw, did MFMS inspire any of this? It looks very similar in some ways lol.
  12. Hi everyone, This morning I've built KSPTOT v1.6.8 pre-release 11. This is a relatively minor update to PR10 that includes some bug fixes and one new feature: LVD plugins can now be used as constraints, objective functions, and Graphical Analysis output. I'll explain more below, but here's the change log: LVD: Plugins can now be used as objective functions, constraints, and graphical analysis output. LVD: All UIs should now render centered on the screen. LVD: Double clicking an available task in GA now adds it to the list of tasks. LVD: Outputting the propagation time to console now includes a breakdown of time needed for propagation and actions. LVD: Missing LVD cases don't show up in the recent cases list (File menu) anymore. This is the last PR before the final v1.6.8 release and I consider this PR to be a release candidate for the full release. I could really use some help testing LVD to make sure there aren't any boneheaded bugs in it. If you find any, please let me know ASAP! Thank you! So let's talk about using plugins as constraints, objective functions, and as Graphical Analysis output for a bit. First, how does one go about setting up a plugin for use like this? It's quite easy really. Let's start with an example and I'll walk through it. The code for this plugin is as follows: %We can use comments in plugin code if(execLoc == LvdPluginExecLocEnum.BeforeProp) kGmu = lvdData.celBodyData.kerbin.gm; %get Kerbin grav parameter str = sprintf('This note was set by a plugin.\n\nKerbin GM: %0.6f\n\nPlugin last executed at: %s', kGmu, datestr(now())); lvdData.notes = str; %set the string in the notes field userData = struct(); %create a structure for use with user data userData.T = []; elseif(execLoc == LvdPluginExecLocEnum.AfterTimestep && not(strcmpi(flag,'init')) && not(strcmpi(flag,'done'))) arry = userData.T; arry(end+1,:) = [t(1), y(1)]; %add time and first element of state to the user data userData.T = arry; elseif(execLoc == LvdPluginExecLocEnum.AfterProp) writetable(array2table(userData.T),'test.csv'); %print user data to file test.csv elseif(execLoc == LvdPluginExecLocEnum.Constraint || execLoc == LvdPluginExecLocEnum.GraphAnalysis) ue = stateLogEntry.getCartesianElementSetRepresentation().convertToUniversalElementSet().convertToFrame(frame); value = ue.c3; end In all plugin code, the execLoc variable is used to tell the code where it's being executed. See the line near the bottom where we test the following: execLoc == LvdPluginExecLocEnum.Constraint || execLoc == LvdPluginExecLocEnum.GraphAnalysis? That is testing if the plugin is used as a Constraint (or objective function) or as a Graphical Analysis task. You'll notice that code block creates a value called "value" that is populated by the current C3 value of the spacecraft orbit. That's the output that will be used as a constraint or objective function or Graphical Analysis output. To use plugins in this manner, you basically need to populate a variable with the name "value" with some scalar double value. Note that all data in KSPTOT is in units of kilometers, seconds, radians, and metric tons. Finally, note that there are two new inputs into the plugin function call to be aware of. The final two inputs are "stateLogEntry" and "frame". The first is the relevant spacecraft state that should be used for evaluation. Basically, if your plugin computes C3 energy like mine does here, then it ought to compute the C3 for that state and that's the value that should be returned. Frame tells you what reference frame values should be computed in, if it's applicable. Using plugins in this capacity is just a matter of adding a Constraint or Objective Function of the type "plugin value." For example: You'll notice our example plugin is used here by selecting it at the top in the "Plugin" field. You must have at least one plugin available to create a plugin value constraint or objective function. Speaking of which, here's that same plugin used as part of an objective function. Finally, let's talk about using plugins as part of Graphical Analysis. If you have at least one plugin, you can create a task like this in GA: When we go to plot that task and compare it to actual C3, we'll see we get the same thing: This proves that our plugin is working correctly and is providing the same information as the built in data type. Of course we could have programmed our plugin to provide any data type! This was just selected as an example. So what do you think? Could this sort of functionality be useful to you? If so, how? Please let me know, and happy orbiting!
  13. This afternoon I've built KSPTOT v1.6.8 pre-release 10. This is a pretty major pre-release update with the following changes in the change log: LVD: Major change to the Set Kinematic State action and the associated GUI. You can now set the states of the individual vehicle components, including stages, engines, tanks (and their associated tank masses!), electrical powers sources, sinks, and storage (including battery state of charge). Astrodynamics Tools UI migrated to App Designer framework Edit Event UI migrated to App Designer framework. Edit Event UI now has buttons to cycle back and forth through the events list. Edit Event Termination Condition UI migrated to App Designer framework. Non Sequential Event UI migrated to App Designer framework. The first bullet point on this list really needs to be checked by more people than me, so if you find any bugs, please let me know!
  14. Yep, it's a combination of two things probably: The zero-radius SoI assumption that goes into MFMS and most of the other sort of similar calculations. Basically, KSP models actual, finite-sized SoIs when the game is running, but MFMS and other similar tools just assume that the SoI radius of Earth is 0. This simplifies a ton of math but introduces some error; and It's possible that something funny happened with the code that tries to sync up the mean anomaly of your vehicle at the start with the departure mean anomaly to figure out how long to coast before burning. I would try to hit the departure true anomaly and not worry about the time so much, to be honest. The true anomaly is going to be more accurate. If you can create a high-res video that shows what you described, please do! I'll take a look and see if anything is broken. Thanks!
  15. Thanks for the shout out! Yes, KSPTOT can do all sorts of fun stuff, including what @Razgriz1 mentioned and more. Anyone interested should come visit us on the KSPTOT forum thread for more information and to get help in learning the software.
  16. Thanks, @Drew Kerman! This is basically correct. @dlrk, if you have any particular questions, please let me know. Thanks!
  17. By the way, if you re-download your file that I provided back to you yesterday, you'll see that I've managed to find an even better solution that saves something like 3 mT of propellant. I did this by: Perturbing the trajectory by 1% or so a few times; Switching the optimizer to NOMAD and letting that run until it had converged on something, more or less; and then Switching back to FMINCON and using the SQP algorithm to get the final trajectory. Take a look and let me know if you have any questions.
  18. Thanks for sharing KSPTOT! I'm the author. If anyone is interested in modeling fun 3/4/N body orbits in Launch Vehicle Designer (LVD), please be sure to grab the latest pre-release of KSPTOT, v1.6.8 PR9. You'll also need to download and install the MATLAB Compiler Runtime R2021a. Let me know if you have any questions!
  19. Yes, the purpose of the constraints is to tell the optimizer to achieve particular things about the trajectory while also trying to minimize or maximize some quantity. The purpose of scale factors is to make the numerical side of the problem easier for the optimizer. Optimizers like to have objective functions and constraints whose values are between -1 and 1 generally. (They also like to have variables whose values are between -1 and 1 too, but I actually handle that under the hood without the user needing to worry about it.) Scale factors work by dividing the actual value of the constraint by that number. It has the added value of making the value of each constraint roughly the same order of magnitude when the optimizer sees it, meaning that you won't have some constraints be "more important" than others just by virtue of their natural numeric magnitudes (e.g. position vector values are usually a lot bigger than velocity vector values). Oh yes, I did forget that. I just set the propagator back to Force Model. You could achieve a similar effect by setting the integrator output step size to a positive number, maybe 10000 seconds for the longer coast periods. Yes, that's the one.
  20. I've fixed up your mission a bit. Here's what I changed: I set the objective function to be maximize total spacecraft mass. You had it set to minimize, which would try to make the optimizer use more fuel. I set the constraint scale factors. The position constraints got scaled by 1E5, the velocity constraints by 10, and the time constraints got scaled by 1E6. This is really important to do in order to make FMINCON work better. I set the Events Plotting Style to "View All" and not "View By SoI Grouping". This way you can see all events in one go, which is really helpful for these kinds of missions. You edit this in the View settings. I ran the optimizer (FMINCON) and let it converge, which it did fairly quickly. Here's your mission back. Let me know if you can't open it in LVD (if it throws an error or whatever). I'm using what's basically v1.6.8 pre-release 9, which I would highly encourage you to download and try out if you're not already.
  21. The Epoch of the Set Kinematic State action in Event 7 is 0.0 seconds. This is where that is coming from. You'll need to adjust this to get things to line up.
×
×
  • Create New...