Jump to content

MechJeb for KSP2


kithylin

Recommended Posts

I'm just hoping they're going to release the API documentation before mod support is actually released.

And I REALLY hope they communicate things, I get it, it's the weekend after release, they need the weekend off.

But I do hope we get at least weekly dev updates
 

Link to comment
Share on other sites

On 2/25/2023 at 1:01 PM, Jim DiGriz said:

My thoughts though are that I'd rather build something so that WASM code built in other languages could run against KSP2 (kind of kRPC without the socket communication)

I kinda liked the “remote” aspect of kRPC. It kinda forced the code to be asynchronous, which will likely make it easier to make better use of multiple CPU cores. Might have an impact on multiplayer, too, depending on how it gets implemented and if there are any rules on where plugins get “hosted” and such.

Link to comment
Share on other sites

On 2/26/2023 at 10:19 PM, EndAllFilms said:

Y not?

  1. cause issa joke
  2. More seriously, it's still too early for something as big as MechJeb to be made yet. We don't even know what sort of modding API and tools we're getting yet. It's literally been only 5 days since first release.
Link to comment
Share on other sites

On 2/26/2023 at 2:43 AM, RKunze said:

I think we should at least try to come up with a common host interface for both, so that the same WASM code that powers a e.g. "cheaty" ascent guidance can be run on the "gamey" version as well (provided the simulated computer in the "gamey" version is powerful enough).

Yeah, that is a distinct possibility to have a generic WASM bridge to build mods on top of.

On 2/26/2023 at 2:43 AM, RKunze said:

you pretty much have to use wasmtime-dotnet (or do you know of any other portable dotnet embedded WASM runtime?).

I did about 10 minutes of looking around so far, I did find a few more attempts at it but wasmtime I think looked the most mature.

On 2/26/2023 at 2:43 AM, RKunze said:

I'm actually very interested in that as well, ever since I read a paper on a closed-loop generic atmospheric ascent guidance algorithm based on optimal control that claimed to be "implementable on a simple embedded system". Tried to implement it in kOS, even, but gave up after I realized I would have to a) port all the math libraries from matrix multiplication on up and b) the kOS VM is at least and order of magnitude slower than a "simple embedded system" anyway.

PS: Maybe we should take that discussion to a different thread as it isn't about MechJeb per se?

Yeah doing something like PVG on kOS wouldn't work because its too slow for numerical methods like that.

What I would suggest these days for a simple launcher would be to model an ascent with a fixed heading and pitchover maneuver following a zero-AoA gravity turn (so two parameters there) followed by a fixed transition (altitude or something like that) to a bilinear tangent law of the form A + B t where those are vectors that determine the heading vector which is just the unit vector in that direction (so 6 parameters plus a normalization constraint on the magnitude of the 6-vector [A B] being equal to 1), plus the end time of the ascent as a final parameter.  Feed that into RKF45 or DOPRI45 and integrate that with a drag model and then feed the constraints on the terminal position into a nonlinear solver like the SQP method that alglib has now.  That ascent won't be optimal in the mathematical sense, but it will be near optimal and should converge reasonably well without needing an overly precise guess, and the AoA constraint through the bulk of the atmosphere will nullify most of the highly nonlinear issues with the atmosphere.

Doing full optimal control theory based ascents is probably the wrong approach and the mathematical approach in PVG absolutely fails to be able to deal with the atmosphere.  I have some Matlab code where I finally managed to get an optimal control approach working, but it took me years and would require implementing finite differencing (like Matlab's bvp5c) in C#, which alglib doesn't have, and I don't know if there's any battle tested implementations out there.

A better approach for a launcher using very modern algorithms would probably use Picard Iterations or PIPG with convex optimization -- which will be much less of a mathematical dead-end:

https://www.sciencedirect.com/science/article/abs/pii/S1270963821007446

https://arc.aiaa.org/doi/10.2514/6.2022-0951

https://arc.aiaa.org/doi/abs/10.2514/1.A35194

That should lead you down the road of dealing with direct optimization and ~1,000x1,000 sparse matricies though.  But I think alglib now has a sparse convex QP solver that would be appropriate.

This might be straying off topic, but its definitely difficult to jam experimental stuff like this into MJ right now.

Edited by Jim DiGriz
Link to comment
Share on other sites

On 2/26/2023 at 3:34 PM, sarbian said:


A MJ for KSP 2 would benefit from a more modular architecture instead of being monolithic (even if the current code has some modularity)

Yeah if MJ3 or whatever was an explicitly modular framework so that the autopilots were external to the core codebase -- allowing stuff like the rover/aircraft/landing/ascent/etc autopilots to be hosted "externally" and potentially managed by other developers that might be very interesting.

Then the core parts of MJ would provide core math support, core support for data from VesselState, core support for computing maneuvers, along with attitude control , the stagecontroller, thrustcontroller and common UI elements.

I can see obvious downsides to doing that as well as the internal API becomes public and breakages would require coordination, and some mods might have to be abandoned by the core API unless some LGG adopted them.

At the same time it would allow customization of what MJ could do and the simplest plugin might only be data readouts without any autopilots.

I don't know what the right answer is, but at the same time the scripting autopilot got kind of dumped into MJ and then rotted and never improved, and that seems wrong.

Edited by Jim DiGriz
Link to comment
Share on other sites

I would really love to thirdly-thousa-millionth this suggestion, but it's far too early for something like this.  As users have mentioned here and elsewhere, maneuver nodes are an issue and need to be fixed.  So why mess with creating a mod for something that is going to get fixed and very well may end up with some of the functionality that people want out of MJ anyhow?

Disclaimer:  It has been stated that MJ is not going to be part of stock KSP2, so my statement above is with zero knowledge of anything.  However, we don't know what fixes are coming, or what features those fixes will entail.  Until we know, developing MJ for KSP2 - which will take a serious amount of time anyhow - is folly.

Link to comment
Share on other sites

Since theres been a lot of technical talk, bringing up WASM and other scripting potentialities, I'd like to point out that there might be a built in scripting language. I haven't dumped things into any tools to check this, but two DLLs stood out to me when looking around for a half remembered late night fix for frustratingly wobbly rockets (I was looking for and eventually found the PhysicsSettings.json) but I came across these two: "Kerbal Space Program 2\KSP2_x64_Data\Plugins\x86_64\LuaPipePlugin.dll" and "Kerbal Space Program 2\KSP2_x64_Data\Plugins\x86_64\LuaPipePlugin64.dll"... not a guarantee because who knows what it is or what its doing (I sure don't, because as i mentioned, I haven't bothered to decompile anything or look that deep)  but "Lua" is a scripting language often used for adding modding and scripting into a game.  A couple minutes google searching didn't bring up much beyond some roblox stuff, and a lot of generic Lua and C# type info, and some Moon# stuff,  but the point still stands... if that's is a Lua scripting plugin then that might be how mod support will work, and if the mods support is via Lua, then theres at least the possibility of some "logic" being able to be scripted using Lua. Subject to whatever limitations are added as Lua can be quite heavily constrained and they might put a lot of constraints on it to keep the mods "safe" for multiplayer or something like that...

Just some thoughts, my 2c, etc. Thought I should point it out before anyone's enthusiasm leads them to invested time in WASM or anything else beyond the obviously applicable C# (cause its Unity) when we don't know enough yet. 

Edited by TechDragon
I accidentally my words
Link to comment
Share on other sites

On 2/25/2023 at 9:54 AM, sarbian said:

It seems that you interpret a 1 word joke a bit too seriously.

There will not be a MechJeb for KSP for a while for the simple fact that we have no official modding support. The current modding tools we have 24h after the release works to do quick hack of some of the game structure but are not (currently) usable to write something like MJ. And the current game performance and bugs make does not motivate me to work on mods for now.

So no, not MechJeb for now.

 

LEGEND

Link to comment
Share on other sites

Yeah,  while were still suffering from wobbly rockets and performance issues, ascent guidance is sorely needed. I've had a few failures that based on KSP1 experiences, I suspect would have worked if I I had been able to ride the throttle correctly... which is very had to do by hand when the game is basically in ultra slow motion, but MechJeb was always a champ at controlling that sort of "this rocket is so big KSP will lag when you launch it"

Link to comment
Share on other sites

1 hour ago, TechDragon said:

Yeah,  while were still suffering from wobbly rockets and performance issues, ascent guidance is sorely needed. I've had a few failures that based on KSP1 experiences, I suspect would have worked if I I had been able to ride the throttle correctly... which is very had to do by hand when the game is basically in ultra slow motion, but MechJeb was always a champ at controlling that sort of "this rocket is so big KSP will lag when you launch it"

Speak for yourself: I have managed to construct and launch into space even 1200-part ships in KSP 2 and I have even constructed an entire space station on the launch pad and sent that into orbit. I have a ship that is in orbit around Kerbin in KSP 2 and has 54,000 delta-v of fuel left not counting the 4500 delta-v in the small lander mounted on top of it. I have managed to fumble my way through manual deep space navigation and make it to land on Duna in KSP 2 and I have orbited Jool and it's moons. It's difficult but doable.  I hope we get Maneuver Planner some day to make this task easier as the ships we can make in the new game are amazing. 

Link to comment
Share on other sites

7 hours ago, kithylin said:

Speak for yourself: I have managed to construct and launch into space even 1200-part ships in KSP 2 and I have even constructed an entire space station on the launch pad and sent that into orbit. I have a ship that is in orbit around Kerbin in KSP 2 and has 54,000 delta-v of fuel left not counting the 4500 delta-v in the small lander mounted on top of it. I have managed to fumble my way through manual deep space navigation and make it to land on Duna in KSP 2 and I have orbited Jool and it's moons. It's difficult but doable.  I hope we get Maneuver Planner some day to make this task easier as the ships we can make in the new game are amazing. 

Lets see a video proof of what youve made in ksp2 cause im calling shenanigans.

Link to comment
Share on other sites

I would like to add a request for the addition of some level of automation tool for ascent guidance..etc. Knowing that I have enough delta-v to get where I'm going, but having no way to know when I'm at max q, makes my launches to orbit rather wasteful... I think the Devs should consider adopting at least a minimal native tool for this.

 

Link to comment
Share on other sites

On 3/4/2023 at 10:00 AM, Temeriki said:

Lets see a video proof of what youve made in ksp2 cause im calling shenanigans.

I don't even have to prove anything. Just go to google and search for: KSP 2 youtube <planet>, people have already been to all the planets in KSP2. KSP2 isn't special. It's just KSP1 with a new GUI. If people could make it to the planets in KSP 1 they can do it again in KSP2. It's not even difficult if you have a few thousand hours of experience with KSP 1.

Edited by kithylin
Link to comment
Share on other sites

On 3/6/2023 at 6:42 PM, Edward Bustamante said:

Knowing that I have enough delta-v to get where I'm going, but having no way to know when I'm at max q, makes my launches to orbit rather wasteful... I think the Devs should consider adopting at least a minimal native tool for this.

 

This is already in the base game for KSP 2. While you are in the VAB there is a button at the bottom you can click on where you select the destination and it will tell you if you have enough Delta-V to get there. It's new in the new game. Also it was described and shown in the tutorial things you have to click on when you started the game. This is just a suggestion here but: perhaps maybe in the future it might be a good idea to read those early game tutorial messages instead of just clicking on them to get the message off the screen.

EDIT: I edited my comment to word it more politely.

Edited by kithylin
Link to comment
Share on other sites

21 hours ago, kithylin said:

This is already in the base game for KSP 2. While you are in the VAB there is a button at the bottom you can click on where you select the destination and it will tell you if you have enough Delta-V to get there. It's new in the new game. Also it was described and shown in the tutorial things you have to click on when you started the game. Perhaps maybe you want to read those things instead of just clicking on them to get the message off the screen.

There is a mod for staging that gives far more information, and I highly recommend it.

[snip]

Edited by Snark
Redacted by moderator
Link to comment
Share on other sites

Some content has been removed due to people making personal remarks.

Folks, please don't make things personal.  Address the post, not the poster.  It is not your place to comment on other people's attitude or behavior.  If they say something you disagree with, you can respond to what they said-- but it's not okay to go after the person themselves, regardless of how much you may dislike their behavior.  If you think someone is behaving so egregiously that they're violating forum rules, then by all means file a report and the moderator team will have a look.  Beyond that, though, please keep the personal remarks to yourself.

Thank you for your understanding.

Link to comment
Share on other sites

So, I'm of two minds about this. I don't want (nor have I ever used) a lot of the stuff some people LOVE about MJ (like Smart A.S.S., or automated docking for instance). But the stuff I do miss the most is the stuff that I REALLY miss - Ascent Guidance, Rendezvous Planner, and Maneuver Planner. I was also quite fond - especially in late-game situations - of the Transfer Window planner.  Landing Guidance (especially for vacuum bodies or bodies with really thin atmospheres) was also pretty darn handy for my Mun and Minmus bases. 

After the first few thousand LKO launches and Duna transfers, there's only so much gravity-turn wrangling and manual maneuver node twiddling I find bearable. 

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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