-
Posts
24 -
Joined
-
Last visited
Content Type
Profiles
Forums
Developer Articles
KSP2 Release Notes
Everything posted by SPD13
-
Hi folks, I have a quick question for those of you using MechJeb as i am trying to find the best process to launch a ship from Kerbin to Duna using MechJeb. What i am doing: 1. On the launchpad, enter in map mode, select Duna as Target 2. On the Ascent guidance module, click on "Launch at interplanetary window", click on "engage autopilot". Mechjeb warps to the launch window and liftoff. 3. Once in Orbit, I click on "Maneuver planner" and "Transfer to another planet" My problem: The transfer maneuver sets a node more than 1year in the future!! The warp takes forever as the engine needs to use full simulation. What am i doing wrong?
-
I was thinking about this wiki : http://wiki.mechjeb.com/index.php?title=Manual This is where the "online manual" button of the module is landing Thanks Not sure why... i did not explore the game enough to understand CommNet limitations. It should not have an impact as mechjeb is executed locally on the vessel.
-
Hi, This should be possible. Once you are on Eve's trajectory, you set the following actions: - "Time" => "Warp to" and select "SOI change". This will wait until you enter Eve's SOI. - "Target" => "Target body" and select "Duna". - "Trajectory" => "Manoeuver" and select "Hohmann transfer to target" - "Trajectory" => "Execute node" and select "next node". This will execute the manoeuver previously set @sarbian Do you mind opening a Wiki access for me on the documentation so I can document the features of the Scripting module?
-
Hi @sarbian Sorry, i've been off for a while. Lots of changes happening in my life :-) I see you upgraded Mechjeb to 1.3 and thank you for it! The last release does not contains all the latest script module features, especially the boolean logic programming features so I sent you a merge request with the last upgrade. I tested it on 1.3. I think it's also time for me to write a little bit of documentation about the module. I will try to update the wiki manual.
-
Sorry for the late Reply. I have been pretty busy (had a baby ). That was the first option i considered. As a software engineer, I love kOS and the idea to be able to write lines of code to control KSP, but my idea was to provide something for people that does not know/want to write code to automate tasks. That's the reason why my script module offers far less possibility than kOS but it can be controlled from the UI. The screenshot below can give you an idea of what i tried to do: And the video below demonstrate it working I tried to be as less intrusive as i can in the mechjeb code. That's the reason why exposing mechjeb functions for kOS should be a combined effort with @sarbian, the main MechJeb developer. Yes, I have 8 slots. We can name the slots and load/save the list of actions. Sure. And that's something i can dive in a near future. That's one of the reason i considered a bridge between my system and kOS to offer the opportunity to connect both together. sure the "if" logic is something that does not exists for the moment in my MechJeb script system. Yes, i like this implementation, i will try to modify the code to look like what you suggest. That would be wonderful. I'm not proud with the way i used to wait until the command is executed.
-
Good point. I'll do this.
-
Hi, Just a quick note to let you know i added a feature in the scripting module i developed for MechJeb. With the latest version, you can run an IR sequence from a script action in MechJeb. It means for example you can use the MechJeb Ascent Guidance and then automatically deploy something using IR Sequencer when you are in orbit. Hope you enjoy !
-
Hi @hvacengi, Thank you for your message and for the details about how to connect MJ and kOS. Some Background: I created a "scripting" module for MechJeb, intended to automate MechJeb tasks (Ascent guidance, docking autopilot, ...) and basic flight or control tasks (Target a body, Target a docking port, crew transfer, ...) to create fully autonomous flights. I'm done with most of the basic MechJeb tasks and now i would like to integrate tasks that could control additional plugins. I started with IR Sequencer and kOS. My target with kOS: Be able to send a command to a processor and monitor the task execution to be able to wait for completion. How i did that: Step 1: Check if kOS is installed to enable the kOS features in MJ foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { else if (assembly.FullName.Contains("kOS")) { this.compatiblePluginsInstalled.Add("kOS"); } } This will check for the assembly Step 2: Identify kOS processors foreach (Vessel vessel in FlightGlobals.Vessels) { if (vessel.state != Vessel.State.DEAD) { foreach (Part part in vessel.Parts) { foreach (PartModule module in part.Modules) { if (module.moduleName.Contains("kOSProcessor")) { //add the processor to a list this.kosModules.Add(module); } } } } } Step 3: When the action is triggered, use reflection to send the command on the Interpreter of ShareObjects inside the kOSProcessor module. if (this.selectedPartIndex < this.kosModules.Count) { if (openTerminal) { //Invoke "OpenWindow" on the kOSProcessor module to open the terminal window this.kosModules[this.selectedPartIndex].GetType().InvokeMember("OpenWindow", System.Reflection.BindingFlags.InvokeMethod, null, this.kosModules[this.selectedPartIndex], null); } //Catch the SharedObjects on the kOSProcessor module var sharedObjects = this.kosModules[this.selectedPartIndex].GetType().GetField("shared", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(this.kosModules[this.selectedPartIndex]); if (sharedObjects != null) { //Catch the Interpreter in SharedObjects var interpreter = sharedObjects.GetType().GetProperty("Interpreter").GetValue(sharedObjects, null); if (interpreter != null) { //Send the command to the Interpreter interpreter.GetType().InvokeMember("ProcessCommand", System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance, null, interpreter, new object[] { command }); ... Step 4: Wait for the action to complete. Here, i used a "trick". I regularly watch for the result of "IsWaitingCommand" on the interpreter object. Not very clean, but it the only way i found to know a command has been completed. public bool isCPUActive(object module) { var sharedObjects = this.kosModules[this.selectedPartIndex].GetType().GetField("shared", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(this.kosModules[this.selectedPartIndex]); if (sharedObjects != null) { var interpreter = sharedObjects.GetType().GetProperty("Interpreter").GetValue(sharedObjects, null); if (interpreter != null) { //We check if the interpreter is waiting to know if our program has been executed bool waiting = (bool)interpreter.GetType().InvokeMember("IsWaitingForCommand", System.Reflection.BindingFlags.InvokeMethod, null, interpreter, null); if (waiting) { //Action ended ! return true; } } } return false; } I know reflection is not very clean, but it's very convenient as it greatly simplifies the setup for the user and creates no dependency between both plugins. Anyway, the way you describe seems really cleaner and i will try to have a look. Thank you for your feedback.
-
Hello, Thank you for your feedback. I only have MechJeb and IR installed. MechJeb has been tested and working, no problem here. I reinstalled IR from scratch (IR + IR Sequencer + Rework), using the latest beta released, flagged as "1.2" compatible. my log file below: here I checked and i have an error that should be related to IR [ERR 10:12:47.717] ADDON BINDER: Cannot resolve assembly: KSPUtil, Culture=neutral, PublicKeyToken=null [ERR 10:12:47.718] ADDON BINDER: Cannot resolve assembly: KSPUtil, Culture=neutral, PublicKeyToken=null [ERR 10:12:47.721] AssemblyLoader: Exception loading 'IRSurfaceSampler': System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded. at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool) at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0 at AssemblyLoader.LoadAssemblies () [0x00000] in <filename unknown>:0 Best
-
What do you consider as the best way to create a communication between two plugins? My target is to be able to fire a method call on plugin B when i'm inside plugin A code. My first idea is to use, from plugin A AssemblyLoader.loadedAssemblies to get the list of loaded assembly modules. Catch the module B assembly using the name m.DeclaringType.Assembly.GetName().Name and use the method Invoke to call methods on it. Is is the safest way to create a functionality in plugin A without altering plugin B ?
-
Hi, IR Sequence does not work for me. I'm on KSP 1.2, i installed all the latest versions: IR 2.0.6, IR Sequencer 1.0.1, Rework 1.1.2 When clicking on the toolbar to activate the sequencer, i receive the following warning message in the logs: "Coroutine couldn't be started because the game object 'SequencerUISettingsWindowPrefab(Clone)' is inactive !" Does anybody already had this problem? Thank you for your help
-
Indentify a "probe" part
SPD13 replied to SPD13's topic in KSP1 C# Plugin Development Help and Support
Works Great ! i just check " if (part.HasModule<ModuleCommand>()) " The only problem is that MechJeb part has a ModuleCommand. I filtered it : " if (part.HasModule<ModuleCommand>() && !part.name.Contains("mumech")) " Thank you again for your help -
Hi, I would like to be able to identify all the parts that when separated can be considered as a controllable ship. I can identify command modules with the following routine: foreach (Part part in vessel.Parts) { if (part.CrewCapacity > 0) { controllableParts.Add(part); controllablePartsNames.Add(part.partInfo.title); } } but i also want to be able to identify unmanned probes. What attribute of the "Part" object can i use to check if it's a probe ? Thank you for your help
-
Open Shield on Docking Port
SPD13 replied to SPD13's topic in KSP1 C# Plugin Development Help and Support
Haha, i found a way "deployAnimator.Progress" is "0" when closed and "1" when opened. -
Open Shield on Docking Port
SPD13 replied to SPD13's topic in KSP1 C# Plugin Development Help and Support
Edit: hmm... no, in fact "deployPercent" is always "100", even when the shield is closed... -
Open Shield on Docking Port
SPD13 replied to SPD13's topic in KSP1 C# Plugin Development Help and Support
Geat! Thank you @sarbian On the ModuleDockingNode, there is a " deployAnimator " and i can call the "Toggle()" method on it to open/close the shield. The " deployPercent " on the animator will tell if the shield is open (100) or closed (0). The " actionAvailable " will tell if this is a shielded dock or not. -
Hello, I am working on the script module for MechJeb to automate flights using the excellent MechJeb module. I am facing a problem: How can i programmatically open the Shield of a shielded Docking Port? Is this a function of the "Part" or a function of the "ModuleDockingNode"? Thank you for your help