Jump to content

[1.8.x to 1.12.x] kRPC: Remote Procedure Call Server (v0.5.1, 2nd March 2023)


djungelorm

Recommended Posts

1 minute ago, Vikins said:

I need your help!

I can't install krps in Python 2.7.11

syntaxerro.jpg

I have already downloaded an zip archive with krpc0.3.3 version, but I don't understand where i have to unzip this file?

 

I need more detailed instruction.

Could you help me?

Looks like you are trying to run pip from within an interactive python session. You need to run it from plain-old command prompt. Also you don't need to download the zip manually. Pip will do that for you.

Steps:

1) Open Start -> cmd

2) Then run:

C:\Python27\Scripts\pip.exe install krpc

Hope that helps!

Link to comment
Share on other sites

9 hours ago, djungelorm said:

Steps:

1) Open Start -> cmd

2) Then run:

C:\Python27\Scripts\pip.exe install krpc

Hope that helps!

I tried to do this:

CMDerrorjp_8925181_21929687.jpg

Something went wrong.

 

Edited by Vikins
Link to comment
Share on other sites

9 minutes ago, Vikins said:

Something went wrong.

Ooo nasty. Looks very similar to this: https://github.com/pypa/pip/issues/2903 There is a bug in pip that means it doesn't work when there are Cyrillic characters in the computers hostname. Not sure how you could fix this... Maybe make sure you've got the latest version of pip, or try using python3? or change your hostname to use ascii characters until they fix it?

Link to comment
Share on other sites

4 hours ago, djungelorm said:

Ooo nasty. Looks very similar to this: https://github.com/pypa/pip/issues/2903 There is a bug in pip that means it doesn't work when there are Cyrillic characters in the computers hostname. Not sure how you could fix this... Maybe make sure you've got the latest version of pip, or try using python3? or change your hostname to use ascii characters until they fix it?

Thanks for your advice, i have install it.

Now I will try to use it - it is very interesting.

 

Link to comment
Share on other sites

Hi there,

I am on a mission to stop mods from trampling the MM cache, and this mod is on my list :)

I love this mod, but it appears to save settings into a config file in the wrong place, which means every time that file gets changed, MM has to do a full rebuild and can't load from cache.

Would it be possible please to move the config file for this mod into a "PluginData" directory so that it will be properly ignored by MM?

Thanks!

Link to comment
Share on other sites

3 minutes ago, Agathorn said:

Hi there,

I am on a mission to stop mods from trampling the MM cache, and this mod is on my list :)

I love this mod, but it appears to save settings into a config file in the wrong place, which means every time that file gets changed, MM has to do a full rebuild and can't load from cache.

Would it be possible please to move the config file for this mod into a "PluginData" directory so that it will be properly ignored by MM?

Thanks!

Certainly! Thanks for bringing this to my attention :)

Link to comment
Share on other sites

Dear djungelorm,

first of all i am really happy with this mod - you did a great job!!! :)

I am now using the Java API and it works like a charm.

Now I am trying to code sort of "distributed autonomous systems" (multiple vessels interacting with each other). I might well start to add some parts like sensors et al. later, but currently i am trying to implement interaction with the modules of a vessel. Here i am somehow not seing a way to set not boolean fields where as in the client UI they have sliders (like roverWheel1>ModuleWheelBrakes>Brakes).

Is this already possible and i oversee it in the documentation (which imho is really a pleasure to work with - tight and informative - well done)?

Is it also somehow possible to set the light color (lightR, ...) of lights in flight mode?

Thanks a lot again for your great mod!

Cheers

Ben

Link to comment
Share on other sites

The part module objects let you access arbitrary fields, events and actions for parts, so if there isn't direct API for it you can sometimes access functionality via that. Details can be found here: http://krpc.github.io/krpc/java/api/space-center/parts.html#module

Unfortunately this doesn't allow you to set light colors or brake strengths. It does allow you to read the brake strength from a field in ModuleWheelBrakes, but can't set it at the moment.

Adding some RPCs for light colors should be a trivial addition so I'll add that in the next release (which baring any last minute issues should be available in a few hours :) !). The APIs for wheels, landing legs etc. needs an overhaul to expose all the new 1.1 functionality. When 1.1 was released I just updated it so that the pre-existing functionality worked but haven't gotten around to adding the new features.

Link to comment
Share on other sites

4 minutes ago, djungelorm said:

The part module objects let you access arbitrary fields, events and actions for parts, so if there isn't direct API for it you can sometimes access functionality via that. Details can be found here: http://krpc.github.io/krpc/java/api/space-center/parts.html#module

Unfortunately this doesn't allow you to set light colors or brake strengths. It does allow you to read the brake strength from a field in ModuleWheelBrakes, but can't set it at the moment.

Adding some RPCs for light colors should be a trivial addition so I'll add that in the next release (which baring any last minute issues should be available in a few hours :) !). The APIs for wheels, landing legs etc. needs an overhaul to expose all the new 1.1 functionality. When 1.1 was released I just updated it so that the pre-existing functionality worked but haven't gotten around to adding the new features.

Wow thanks for the quick answer :) I did already create my own parts now. I have a little GUI now allowing me to track the energylevel of the probe and call my new custom events of the new part. For that i am using the suggested module api to enumerate on the custom fields and send the events.

If there would be a general method to set a field with data i.e. setFloatField(0.3) or setStringField("Test") then this would be awesome! :)

As i said before i am planning to have sensor like distance analyzer, ... and so forth as a "real" robot would have them and then write a little ai remoting this. The next step will then be to provide a rest API over HTTP for it. So you can steer your stuff over a website (by that with your mobile, tablet and so forth - like have your navtablet app next to your desktop :)). it might be a little like a kerbalgotchi. could even be on twitch and user can steer probes in the game while streaming ... (just rough ideas!) ...

But in any way thanks for your reply and the mod!!!

Cheers

Ben

Link to comment
Share on other sites

I am happily working on my little autonomous rpc creatures :)

Currently i am facing a little issue as the java.util.List<ServoGroup> getServoGroups() of Infernal Robotics API http://krpc.github.io/krpc/java/api/infernal-robotics/infernal-robotics.html does not only return the Groups of the active vessel but all servo groups of the vessels which are in rendering distance. (i can work around it by renaming the servo groups on each vessel.)

I asked myself if it might be possible to get the Part from the Servo and the Servo from the Part? And perhaps also a Vessel from the ServoGroup?

Cheers

Ben

Link to comment
Share on other sites

v0.3.4 has been released! Here are the highlights:

  • Major server performance improvements. Finally got round to running the code through a profiler, and managed to significantly reduced the memory pressure caused by the main server loop. This means that the game no longer stutters every few seconds when the garbage collector kicks in.
  • Added functionality to draw lines, polygons and text in the game scene (http://krpc.github.io/krpc/csharp/api/drawing.html)
  • Added functionality to add and interact with custom UI elements. Tutorial here: http://krpc.github.io/krpc/tutorials/user-interface.html

The full changelog can be found here

@Survius - I've also added a getter and setter for light colors and methods to set fields in part modules. I've had a quick look at your Infernal Robotics issue - looks like you can get the vessel for a servo group, so should be able to add some APIs for getting the servo groups for a specific vessel. I'll investigate getting the part for a servo too. You also mentioned writing some sort of REST API to get interaction from a browser. I actually have a websockets server implemented (but hasn't made it into the release just yet). We just need to get a JS client to work and it'll be good to go. Websockets is a more suitable protocol for doing RPC calls from a browser. There's some discussion here if you're interested: https://github.com/krpc/krpc/issues/123

Link to comment
Share on other sites

I am just downloading the new 0.3.4 - thanks a lot for the setters on fields and the light color setters!!!

Also looking forward for the brand new User Interface API :)

Regarding the IR Servogroup to Vessel topic - i currently dont see the Method neither in the doc http://krpc.github.io/krpc/java/api/infernal-robotics/servo-group.html nor in the sources :/ ...

For the webserver topic the websocket topic is cool but i will in any way build an abstraction on top of it as i will run it wihtin my tomcat - it will have one connection to the game and then provide services to many users allowing them to simoultanously use vessels over it (still rough thoughts) - my "Synth REST API" :) (i am thinking if i might later contribute this as an additional mod to yours ).

I wrote a little mod allowing me to name parts and a little "controller" with wich can now configure my RPC Client from within the game. My first little challenge a self adjusting solarpanel with IR and a static panel is already working:

 

 

Link to comment
Share on other sites

Hi,

thank you for nice mod. Really like it, but when tried to get current game scene, it seems does not work.

Would it be possible to make it work, please?

>>> conn.krpc.current_game_scene
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'KRPC' object has no attribute 'current_game_scene'
>>>

Thank you.

J.

Link to comment
Share on other sites

On 5/26/2016 at 2:12 PM, Survius said:

I am just downloading the new 0.3.4 - thanks a lot for the setters on fields and the light color setters!!!

Also looking forward for the brand new User Interface API :)

Regarding the IR Servogroup to Vessel topic - i currently dont see the Method neither in the doc http://krpc.github.io/krpc/java/api/infernal-robotics/servo-group.html nor in the sources :/ ...

Unfortunately the servo's per vessel stuff didn't make it into 0.3.4 - you caught me just before I was going to release it - the color and field setters only just made it in! Will add this in 0.3.5.

On 5/27/2016 at 2:01 AM, joeindian said:

Hi,

thank you for nice mod. Really like it, but when tried to get current game scene, it seems does not work.

Would it be possible to make it work, please?

>>> conn.krpc.current_game_scene
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'KRPC' object has no attribute 'current_game_scene'
>>>

Thank you.

J.

Just tested this on KSP 1.1.2 with kRPC 0.3.4 and it worked fine for me! What version of the python client are you using?

4 hours ago, Keith Young said:

Thanks for such an awesome mod!

You figured this out then I take it :wink: I should have mentioned the 0.3.4 changelog that draw_direction and friends have been moved to the new Drawing service. The new API is documented here: http://krpc.github.io/krpc/python/api/drawing/drawing.html and an example here: http://krpc.github.io/krpc/tutorials/reference-frames.html#visual-debugging

Link to comment
Share on other sites

Hi, regarding the missing method "current_game_scene" I thing, that this is really missing in the last release of kRPC mod. Kindly see the dump bellow:

Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import krpc
>>> conn = krpc.connect(name="Python kRPC")
>>>
>>>
>>> dir(conn.krpc)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_client', 'add_stream', 'get_services', 'get_status', 'remove_stream']
>>>
>>>
>>>
 All methods, but property "current_game _scene", are listed and works:

>>> conn.krpc.get_status()
version: "0.3.4"
bytes_read: 294
bytes_written: 848304
rpcs_executed: 3
max_time_per_update: 10000
adaptive_rate_control: true
blocking_recv: true
recv_timeout: 1000
time_per_rpc_update: 0.00102034467272
poll_time_per_rpc_update: 0.00100139586721
time_per_stream_update: 7.25567679183e-06

>>> conn.krpc.current_game_scene
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'KRPC' object has no attribute 'current_game_scene'
>>>

Thank yuou for your response and time. Really appreciate this mod and you effort.

J.

 

 

 

 

 

Link to comment
Share on other sites

@joeindian Looks like you might have an outdated version of the python client? There are a bunch of methods missing in your output from dir(conn.krpc) as well. Can you run the following to confirm:

import krpc
conn = krpc.connect()
print 'client version', krpc.__version__
print 'server version', conn.krpc.get_status().version
for service in conn.krpc.get_services().services:
    if service.name == 'KRPC':
        print 'KRPC procedures:', [x.name for x in service.procedures]
        print 'KRPC enumerations:', [x.name for x in service.enumerations]

If you installed the client using pip, you can upgrade to the latest version by running  pip install upgrade krpc

Link to comment
Share on other sites

Yep, it was as you said. Thanx a lot. Really appreciate you help.

Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import krpc
>>> conn = krpc.connect()
>>> print 'client version', krpc.__version__
client version 0.3.4
>>> print 'server version', conn.krpc.get_status().version
server version 0.3.4
>>> for service in conn.krpc.get_services().services:
...     if service.name == 'KRPC':
...             print 'KRPC procedures:', [x.name for x in service.procedures]
...             print 'KRPC enumerations:', [x.name for x in service.enumerations]
...
KRPC procedures: [u'GetStatus', u'GetServices', u'AddStream', u'RemoveStream', u'get_CurrentGameScene']
KRPC enumerations: [u'GameScene']
>>>
>>> conn.krpc.current_game_scene
<GameScene.flight: 1>
 

Best regards.

J.

 

Link to comment
Share on other sites

4 minutes ago, Mad_Scientist said:

Thanks you, @djungelorm, for this buitiful mode! 

I am creating a ksp board which will use your api, and wanted to ask you - what is the difference between surface_attitude and bedrock_attitude?

Thanks!

Thanks :) Surface altitude is above the land and surface of the sea, bedrock is above the land and the sea bed.

Link to comment
Share on other sites

It's me again. 

I am having problems with getting information about vessel's speed. Here is my code:

Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import krpc
>>> con = krpc.connect (name='test')
>>> v = con.space_center.active_vessel
>>> f = v.flight()
>>> f.speed
0.0
>>> v.name #The vessel was flying during the time
'Aeris 3A'

Is it only on my side? Windows 7, 64 bit. KSP 1.1.2 

Edited by Mad_Scientist
Link to comment
Share on other sites

2 hours ago, Mad_Scientist said:

It's me again. 

I am having problems with getting information about vessel's speed. Here is my code:


Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import krpc
>>> con = krpc.connect (name='test')
>>> v = con.space_center.active_vessel
>>> f = v.flight()
>>> f.speed
0.0
>>> v.name #The vessel was flying during the time
'Aeris 3A'

Is it only on my side? Windows 7, 64 bit. KSP 1.1.2 

Ahhhh this old chestnut :P The reference frame passed to vessel.flight() is fixed relative to the vessel => speed is 0.

There's a note about this in the docs: http://krpc.github.io/krpc/python/api/space-center/vessel.html#SpaceCenter.Vessel.flight

Also see here for an example: http://krpc.github.io/krpc/tutorials/reference-frames.html#orbital-speed

Link to comment
Share on other sites

1 minute ago, djungelorm said:

Ahhhh this old chestnut :P The reference frame passed to vessel.flight() is fixed relative to the vessel => speed is 0.

There's a note about this in the docs: http://krpc.github.io/krpc/python/api/space-center/vessel.html#SpaceCenter.Vessel.flight

Also see here for an example: http://krpc.github.io/krpc/tutorials/reference-frames.html#orbital-speed

Thanks, that explains everything. I am digging into that now!  You are the best, you know that?!

Link to comment
Share on other sites

30 minutes ago, acc said:

any chance to get javascript (node js) in?

We're working on it :) There is an experimental websockets server here: https://github.com/krpc/krpc/issues/123 There is no JS client yet as such, but if you don't mind doing the protocol buffer communication yourself it is usable.

There are also plans to add gRPC support which will enable use of many more languages too.

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