Jump to content

[1.5.x to 1.2.2] kRPC: Control the game using C#, C++, Java, Lua, Python, Ruby, Haskell, C (Arduino)... (v0.4.8, 28th October 2018)


djungelorm
 Share

Recommended Posts

On 9/15/2020 at 8:51 PM, CanisLupus518 said:

I installed the 0.4.8 version of the mod using CKAN after temporarily enabling 1.5 compatibility. It seems to work in KSP 1.10.1. Ihave not tested every API, but so far I am able to get orbital telemetry without an issue

yes I did it the same way. And it works. I am only scared that it is not supported any longer since I base my gaming console on it.

Link to comment
Share on other sites

Hello,

On 11/5/2020 at 11:47 AM, blueisaak said:

yes I did it the same way. And it works. I am only scared that it is not supported any longer since I base my gaming console on it.

Did you connect via Serial or via TCP?

I'm using KSP 1.10.1.2939 and trying to connect an Arduino Uno so I have to connect via a serial port.

I tried the simplest example, and it compiles great on Arduino IDE but then it doesn't connect . Something's in the mod is probably broken with this version of KSP... Which isn't surprising if it hasn't been updated since October 2018. 

#include <krpc.h>
#include <krpc/services/krpc.h>
#include <krpc/services/space_center.h>

HardwareSerial *conn;

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);

  conn = &Serial;
  // Open the serial port connection
  krpc_open(&conn, NULL);
  
  // Set up communication with the server
  while (krpc_connect(conn, "Arduino Example") != KRPC_OK);

  // Indicate succesful connection by lighting the on-board LED
  digitalWrite(LED_BUILTIN, HIGH);
}

void loop()
{
  
}

I'll try with another version of KSP, since I really want real switches and buttons.

BTW, this is what I'm working on (yes the holes for the buttons are terribly spaced: the manufacturing process is still... in progress haha):

IMG-20201107-210547.jpg

Link to comment
Share on other sites

  • 4 weeks later...

Hello, I've been playing with kOS for several months and am wanting to branch out a bit and kRPC has been recommended by some smart guys.  I'm running on linux, but could go to windows if required (hopefully not though).  I do wonder about the lack of updates since 2018; is it being actively maintained with regards to newer versions?  I'm currently running 1.10.1 but am not glued to that. 

tl;dr questions:

  • Is linux a problem with kRPC?
  • Is kRPC being (or will be soon) actively maintained  for current versions of KSP?
  • What is the "best" KSP version for kRPC?
  • Is there Trajectories support?

Thanks

 

Link to comment
Share on other sites

  • 1 month later...
On 7/22/2020 at 10:08 AM, blueisaak said:

I saw on git that there is a build for 1.9.

May I ask where you saw that? The list of releases on GitHub only seems to list the ones CKAN has, the latest of which only mentions KSP 1.5.1:

On 8/29/2020 at 7:00 AM, darthgently said:

I, too, only see CKAN presenting an apparent old version and am not sure if this is because CKAN isn't up to speed or if CKAN hasn't deemed the later versions compatible and the git version is 'beta'.  The forum seems fairly quiet

Are you saying it's an "apparent old version" because @blueisaaksaid so, or because you found this "git version" yourself? If the latter, may I inquire as to where it is?

Link to comment
Share on other sites

  • 2 months later...
On 1/27/2021 at 10:54 AM, HebaruSan said:

May I ask where you saw that? The list of releases on GitHub only seems to list the ones CKAN has, the latest of which only mentions KSP 1.5.1:

Are you saying it's an "apparent old version" because @blueisaaksaid so, or because you found this "git version" yourself? If the latter, may I inquire as to where it is?

The KRPC discord is fairly active. I dabbled around with this fork (NOT master release): Release build for ksp 1.8.0 - 1.9.0 · haeena/krpc · GitHub but the Unity version in KSP changed with 1.9 so some of the UI stuff such as drawing vectors isn't working right now. I just saw someone just did an 11.x fork but I am in the process now of trying it so can't speak to it. 

Edit: Yahoo, the 1.11 fork I found has working UI elements! Canvases and vector lines are working again! (Maybe someone fixed them some time ago, but anyhow they work again!)

Github fork: Release 0.49-1.11 · nullprofile/krpc · GitHub

Edited by aeroeng14
Updated with 1.11 fork test results.
Link to comment
Share on other sites

14 minutes ago, aeroeng14 said:

The KRPC discord is fairly active. I dabbled around with this fork (NOT master release): Release build for ksp 1.8.0 - 1.9.0 · haeena/krpc · GitHub but the Unity version in KSP changed with 1.9 so some of the UI stuff such as drawing vectors isn't working right now. I just saw someone just did an 11.x fork but I am in the process now of trying it so can't speak to it. 

Ahh, I see, thanks. I guess this is as good a time as any to try to set some user expectations:

The CKAN bot does not subscribe to random Discords to eavesdrop on user chats about the latest recompiles that they're sharing. Unless somebody announces they're adopting the mod and sets up a forum thread or a SpaceDock page or submits an issue or a pull request to NetKAN, builds like that will not show up in CKAN.

Link to comment
Share on other sites

4 minutes ago, HebaruSan said:

Ahh, I see, thanks. I guess this is as good a time as any to try to set some user expectations:

The CKAN bot does not subscribe to random Discords to eavesdrop on user chats about the latest recompiles that they're sharing. Unless somebody announces they're adopting the mod and sets up a forum thread or a SpaceDock page or submits an issue or a pull request to NetKAN, builds like that will not show up in CKAN.

Very true. These are as far as I know not official in any way and obviously why CKAN didn't pick them up.

Link to comment
Share on other sites

  • 4 months later...

I've started on a 'final' features complete update fork.   

So far I've added support for:
stock robotics
rotating docking ports
  blinking lights
stock alarm clock
the wheel upgrades
 resource drains
and autostruts.

You can grab a preliminary version at https://github.com/artwhaley/krpc/releases/tag/experimental

Unfortunately I'm building in windows and am just recompiling the DLLs, so I'm not able to rebuild the documentation and a few of the client files, but things should be named pretty self-explanatorily so it should at least all work for folks using python.   If anyone with the full build environment working wants to help out with documentation and the client libraries that require building...   I'd really appreciate it!   I'll try to eventually get around to setting up a linux laptop and making it work myself if nobody else can, but... 

If anyone finds bugs or has questions, please let me know!   I've made pull requests to both the main repo and to Null Profile who's been doing rebuilds...   but until someone more qualified takes over, I'll do my best to get things updated and finalized!  

Link to comment
Share on other sites

  • 2 months later...

For anyone trying to use LaunchOrbit java code from tutorials, there is a problem in every while loop. Basically lots of variables aren't declared as "volatile" which causes different threads to not be synchronized, and then your while loop keeps going on forever without doing anything. The reason for that is the JVM is allowed to assume that other threads do not change some of the variables during the loop. The proper fix would be to make them all "volatile", but you can also fix it more easily by adding the following at the start of every loop:

System.out.print(".");
System.out.print("\b");

This will add a dot and then delete it every time, but what it does is force syncrhronization which makes the loop work properly.

Edited by Cannon
Link to comment
Share on other sites

  • 10 months later...

Hi,

I'm using kRPC 0.4.8 on KSP 1.5.1 and I was wondering if it was possible to modify the RPC Rate. I'm stuck at 50 RPC/s. I tried to modify the advanced settings with no luck. I'm using the Java client.

Thanks

EDIT: Works fine on 1.9.1

Edited by Azerty
Link to comment
Share on other sites

12 hours ago, Azerty said:

Hi,

I'm using kRPC 0.4.8 on KSP 1.5.1 and I was wondering if it was possible to modify the RPC Rate. I'm stuck at 50 RPC/s. I tried to modify the advanced settings with no luck. I'm using the Java client.

Thanks

EDIT: Works fine on 1.9.1

Probably not as that looks like the physics tick rate in the game engine and all mods code functions by squeezing into that schedule.

I believe that physics engine heartbeat, whatever its limits are on your platform, is a hard limit, but could be wrong in some way

Edited by darthgently
Link to comment
Share on other sites

You are probably right because I think I read somewhere the physics simulation runs at 50Hz in KSP.

I assume something has changed regarding this matter between 1.5.1 and 1.9.1 because I'm not limited anymore. I can have spikes at 3000 RPC/s no problem.

Edited by Azerty
Link to comment
Share on other sites

4 hours ago, Azerty said:

You are probably right because I think I read somewhere the physics simulation runs at 50Hz in KSP.

I assume something has changed regarding this matter between 1.5.1 and 1.9.1 because I'm not limited anymore. I can have spikes at 3000 RPC/s no problem.

If it like kOS then it will fit as many things as it can in the 50hz slice it can.  If your RPC is low enough overhead I could see it s squeezing in more in a later version. 

Beware of reading data in one physics tick, but not acting on it until the next as this can introduce error.  I know about nothing concerning kRPC but look for a mechanism that allows you wait until the next tick so all data gathering and actions occur in the same tick. In kOS we look for the in game time to change. Someone more knowledgeable will chime in hopefully

Edited by darthgently
Link to comment
Share on other sites

  • 1 month later...

So for anyone wondering, there seems to be an active community still around this mod. AFAICT the current effort is best accessed here: https://github.com/nullprofile/krpc

In the releases you can find krpc recompiles for current versions of KSP, and under actions you can grab the CI builds of the current development which will also include new features found in stock, including those added by @artwhaley and mentioned by them in the post above.

I'm a bit allergic to hanging out on discord and apparently this is where people are so I don't know why no one officially adopted krpc or at least posts here from time to time, and I hope I don't step on anyone's toes by posting, but I'm very happy that krpc lives on and thought I'd share.

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...