daniel.hamel Posted April 12, 2018 Share Posted April 12, 2018 (edited) I'm trying to use the krpcmj addin on 1.4.2, i can get the .dll to compile using djungelorm 's pull request. What i cannot do is use any function of the addon in Python, I get an Object not referenced error. Can someone help point me in the right direction to fix this? I compiled using Visual Studio Community 2017 and referencing the required assemblies from my KSP install. I'm targeting .NET 4.5, could that be it? Also when I try to create the client library for C# im getting this: c:\Python27\Scripts>krpc-clientgen.exe -o krpcmj.cs --ksp=C:/users/Administrator/Desktop/ksp csharp KRPCMJ C:/Users/Administrator/Desktop/krpcmj-master/krpcmj/bin/Release/krpcmj.dll Error: Unhandled Exception: KRPC.Service.ServiceException: In service SpaceCenter: Service does not exist, when loading class at KRPC.Service.Scanner.Scanner.HandleError(IList`1 errors, String context, Exception exn) at KRPC.Service.Scanner.Scanner.GetServices(IList`1 errors) at ServiceDefinitions.MainClass.Main(String[] args) Edited April 12, 2018 by daniel.hamel Quote Link to comment Share on other sites More sharing options...
artwhaley Posted April 12, 2018 Share Posted April 12, 2018 I'm about 80% of the way through totally rewriting the krpcmj plugin to use reflection... the code as it is is a couple of years old... so I can't really hazard a guess as to all of the ways it might be broken. That said...from that error, first question... the mechjeb service is separate from the space center service... and that error says it's not found in the SpaceCenter service. Are you sending commands to the mechjeb service at conn.krpcmj? Quote Link to comment Share on other sites More sharing options...
daniel.hamel Posted April 12, 2018 Share Posted April 12, 2018 1 minute ago, artwhaley said: I'm about 80% of the way through totally rewriting the krpcmj plugin to use reflection... the code as it is is a couple of years old... so I can't really hazard a guess as to all of the ways it might be broken. That said...from that error, first question... the mechjeb service is separate from the space center service... and that error says it's not found in the SpaceCenter service. Are you sending commands to the mechjeb service at conn.krpcmj? Cool, the code is just trying to create a client library for C#. The code i'm using (trying in python as I can't get the client lib compiled) is import krpc; # Import Library conn=krpc.connect() # Setup Connection mj=conn.krpcmj # save a lot of repetetive typing sc=conn.space_center mj.apvessel=sc.active_vessel #assign apvessel for krpcmj vessel = conn.space_center.active_vessel vessel.name = "My Vessel" flight_info = vessel.flight() print (sc.active_vessel.orbit.periapsis_altitude) mj=conn.krpcmj print (mj.ascent_ap) Quote Link to comment Share on other sites More sharing options...
artwhaley Posted April 12, 2018 Share Posted April 12, 2018 That sure SHOULD work. Like I said, it's been so long since I've actually looked at it, that I'm not sure where the problem is - it could be a change in KRPC, or in MJ itself... Or it could be the .net version as you suggested? @djungelorm is way smarter than me, so I bet he has more useful input. I'll poke around later to see if I see something obvious. Quote Link to comment Share on other sites More sharing options...
daniel.hamel Posted April 13, 2018 Share Posted April 13, 2018 For your new plugin, what kind of timeframe are we talking about? And where can I subscribe for news? If we are talking about this month, might not be worth me fudging with the old one. If not, i wouldnt mind hosting a binary if I could get it working. Quote Link to comment Share on other sites More sharing options...
artwhaley Posted April 14, 2018 Share Posted April 14, 2018 I've only been neglecting it a couple of years! lol. I'll take a look to make sure the new version still compiles, then I'll get a Github repo up in the next few days.. The core functionality works, I'm just slow at trolling my way through the whole Mechjeb API. If memory serves, the ascent, landing, maneuver planning, node execution, docking, and rover autopilots are all essentially there. If I get it up on the internet, maybe someone with more free time than me will jump in and do some copy / paste and find/replace to help implement the missing modules! Quote Link to comment Share on other sites More sharing options...
daniel.hamel Posted April 14, 2018 Share Posted April 14, 2018 Hey, that is the most important things!, Really wasn't looking forward to coding the maneuver planner, especially for interplanetary transfers. Quote Link to comment Share on other sites More sharing options...
theblacktiger Posted April 22, 2018 Share Posted April 22, 2018 Hello all, I'm having trouble getting a value from a stream. Set up as such : periapsis = conn.add_stream(getattr, vessel.orbit, 'periapsis_altitude') print("periapsis stream = {}.".format(periapsis)) When I print the variable "periapsis", I get : <krpc.stream.Stream object at 0x0000025A7F3017B8> It is not a number, what it is actually ? an object type and a memory address I guess ? How to get the actual value ? I might have misunderstood something, if anyone have a clue about what's going on here, will be greatly appreciated. PS: Not sure where to ask for help regarding that issue, hope here is okay. Quote Link to comment Share on other sites More sharing options...
42. Posted April 22, 2018 Share Posted April 22, 2018 @theblacktiger Just call the stream with two parentheses, like you would a function without an argument; in your case, it would look like this: print("periapsis stream = {}.".format(periapsis())) The doc has a section on streams if you want more information: https://krpc.github.io/krpc/python/client.html#streaming-data-from-the-server Hope I could help! Quote Link to comment Share on other sites More sharing options...
theblacktiger Posted April 23, 2018 Share Posted April 23, 2018 Thank you 42. It work with the print. I'm still having issue printing it with appJar (GUI library) as it print a int that is not the periapsis or anything. Will find out eventually I guess. ;-) Quote Link to comment Share on other sites More sharing options...
SKYNЕT Posted April 24, 2018 Share Posted April 24, 2018 (edited) Hello! I want to use several buttons in the script, each will run its own algorithm. How can I distinguish between them? You can sample. Use python !!! def button_creat(self,color=(1,0,0),txt_title="Clear interface ",pos_x=100,pos_y=100,name_obj="id_button"): self.name_obj = name_obj self.button = self.panel.add_button(txt_title) self.button.rect_transform.position = (pos_x,pos_y) self.name_obj = self.conn.add_stream(getattr,self.button,"clicked") Edited April 24, 2018 by SKYNЕT Quote Link to comment Share on other sites More sharing options...
Bosun Posted April 30, 2018 Share Posted April 30, 2018 I had this installed in 1.2.2, just now getting back to it with 1.4. Installed the kRPC folder by copying contents into main director (Schema/GameData/etc, so it all got placed where specified), and re-installed the library with Command Prompt. Now I click on "Start Server" button but nothing happens, run a script, but of course Python throws an error that the machine refused the connection. Of course, I AM the Machine. But that's another story. What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
djungelorm Posted April 30, 2018 Author Share Posted April 30, 2018 9 hours ago, Bosun said: I had this installed in 1.2.2, just now getting back to it with 1.4. Installed the kRPC folder by copying contents into main director (Schema/GameData/etc, so it all got placed where specified), and re-installed the library with Command Prompt. Now I click on "Start Server" button but nothing happens, run a script, but of course Python throws an error that the machine refused the connection. Of course, I AM the Machine. But that's another story. What am I doing wrong? Strange... works fine for me with KSP 1.4.3. Can you post the contents of your player log to see if there are any exceptions being thrown? On Windows, it can be found in %USERPROFILE%\AppData\LocalLow\Squad\Kerbal Space Program\output_log.txt or on Linux in ~/.config/unity3d/Squad/Kerbal Space Program/Player.log Quote Link to comment Share on other sites More sharing options...
Bosun Posted May 1, 2018 Share Posted May 1, 2018 After a careful look, I have no such folder, nor such file, anywhere on my PC Quote Link to comment Share on other sites More sharing options...
Bosun Posted May 1, 2018 Share Posted May 1, 2018 I reloaded everything and now I get this error: Traceback (most recent call last): File "D:\KSP_win64\KSRPC\kRPC FIles\LaunchIntoOrbitEdited.py", line 9, in <module> conn = krpc.connect(name='Launch into orbit') File "D:\Python\lib\site-packages\krpc\__init__.py", line 36, in connect assert ok_message == Decoder.OK_MESSAGE AssertionError in Python after attempting to execute a script Quote Link to comment Share on other sites More sharing options...
djungelorm Posted May 1, 2018 Author Share Posted May 1, 2018 That error suggests that the server plugin is version 0.4.x but the client is to old to communicate with it. You need to update your python client library to version 0.4.x. If you installed it using pip you can run "pip install --upgrade krpc" to do this Quote Link to comment Share on other sites More sharing options...
Bosun Posted May 2, 2018 Share Posted May 2, 2018 (edited) Windows did not have Python listed as a pathway, had to go into system variables to change it back. I then had to delete my old client libraries and re-install from scratch. Edited May 2, 2018 by Bosun Quote Link to comment Share on other sites More sharing options...
sking06 Posted May 3, 2018 Share Posted May 3, 2018 I'm attempting to use Krpc with Kerbal 1.4.3, but receive the following message when starting KSP " Incompatible mods detected....Incompatible with 1.4.3....KRPC". Being a stubborn fool, I continue to march, but receive the following message when attempting to start the Krpc server... " Socket error ACCESS DENIED An attempt was made to access a socket in a way forbidden by it's access permissions". Just so you know, my level of knowledge about this stuff is somewhere below sea level, but any help would be appreciated. Thanks... Quote Link to comment Share on other sites More sharing options...
lushr Posted May 10, 2018 Share Posted May 10, 2018 Is there a way to directly control rocket gimbal and control surface activation on a per-part basis? I'm implementing a control system that needs to produce independent inputs to the engine and the aerodynamic controls, but can't figure out if there's an interface to do so. Quote Link to comment Share on other sites More sharing options...
CraigCottingham Posted May 14, 2018 Share Posted May 14, 2018 On 5/3/2018 at 12:51 PM, sking06 said: I'm attempting to use Krpc with Kerbal 1.4.3, but receive the following message when starting KSP " Incompatible mods detected....Incompatible with 1.4.3....KRPC". Being a stubborn fool, I continue to march, but receive the following message when attempting to start the Krpc server... " Socket error ACCESS DENIED An attempt was made to access a socket in a way forbidden by it's access permissions". What operating system? On macOS 10.13.4 (High Sierra), I get the "incompatible" warning, but otherwise the mod appears to work correctly. I think a default server starts automatically, or at least it did for me. Did you try to create an additional server, or did this error pop up on its own? Quote Link to comment Share on other sites More sharing options...
sking06 Posted May 14, 2018 Share Posted May 14, 2018 Hi Craig...Thanks for the reply. I'm on windows 10 and I also get the incompatible warning. What confused me (and I'm easily confused) was the error message. What it was really trying to tell me was that 50001 was already in use. Once I changed that it worked perfectly. What I'm trying to do is get the New Kepard space craft to work, but still not having any luck with that part. Quote Link to comment Share on other sites More sharing options...
Kron Posted May 30, 2018 Share Posted May 30, 2018 I'm having trouble getting reasonable results from simulate_aerodynamic_force_at. It seems to be missing a way to specify the vessel's orientation. The only thing I can think of is that maybe it uses a default orientation with respect to the reference frame, but I'm not sure how that would work with different reference frames. An example would be very helpful. Quote Link to comment Share on other sites More sharing options...
djungelorm Posted June 3, 2018 Author Share Posted June 3, 2018 I just released version 0.4.6. Mainly bug fixes: Removed that annoying incompatible warning with KSP 1.4.3 (as it works fine...) Added game mode, Science, reputation and funds properties LaunchVessel now correctly recovers any vessels on the pad and does all the other pre-flight checks Fixed science transmission Added API for removing stream/event callbacks in all client libraries Full changelog is available here: https://github.com/krpc/krpc/releases/tag/v0.4.6 On 5/30/2018 at 9:26 AM, Kron said: I'm having trouble getting reasonable results from simulate_aerodynamic_force_at. It seems to be missing a way to specify the vessel's orientation. The only thing I can think of is that maybe it uses a default orientation with respect to the reference frame, but I'm not sure how that would work with different reference frames. An example would be very helpful. The orientation used is the one specified when creating the flight object that you are calling simulate_aerodynamic_force_at. And if you don't specify a reference frame when you call vessel.flight() it defaults to the vessel's surface reference frame. To simulate aero forces using using a custom reference frame your code would need to look something like: ref_frame = ... flight = vessel.flight(ref_frame) return flight.simulate_aerodynamic_forces_at(...) Quote Link to comment Share on other sites More sharing options...
djungelorm Posted June 5, 2018 Author Share Posted June 5, 2018 PSA: We now have a Discord server for all things kRPC! Head over to https://discord.gg/c8c36UM to check it out. Quote Link to comment Share on other sites More sharing options...
Freshmeat Posted June 19, 2018 Share Posted June 19, 2018 Is there a way to switch between different IVA actors using kRPC? I fly a lot of IVA, and while kRPC has everything else I could dream of controlling, I cannot seem to find that in the docs. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.