djungelorm

[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)

Recommended Posts

 

@djungelorm You sir, are a genius. Just sayin'. I've nothing constructive to say, just wanted to share my total admiration for this amazing mod :)

I took a bit of a break from ksp, and today I finally got an itch for it. Decided to try something new, and to my shame I never played with scripting mods (neither krpc not kos). And since @djungelorm offers to write in languages that are known to people I decided to fool around with krpc.

First obvious (and completely not clichéd) idea that came to mind was "let's do a grasshopper". Sound easy enough. Say we burn for 200 metres, start to fall, then slam on the throttle for suicide burn. Here we go:

As you can see it was a utter success. Next step is to poweslide on top of vehicle assembly building :P

Share this post


Link to post
Share on other sites
On 6/19/2018 at 1:11 PM, Freshmeat said:

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.

Not possible currently sorry! I've added an issue on github to get this added: https://github.com/krpc/krpc/issues/484

Share this post


Link to post
Share on other sites

Thanks a lot. I am very impressed by the work you have done, and can do most of the basic stuff with kRPC already. Looking forward to go ahead with advanced stuff.

Share this post


Link to post
Share on other sites

Somehow AVC (not mini-AVC) still mentions that this version was made to run on 1.4.3.  I guess it's checking against an online repository... but where?

Share this post


Link to post
Share on other sites
2 minutes ago, Kerbart said:

Somehow AVC (not mini-AVC) still mentions that this version was made to run on 1.4.3.  I guess it's checking against an online repository... but where?

Thanks for spotting this, should be fixed now. (It's set on the KSP-AVC website by the mod developer, so I have to remember to bump the version manually when I do a new release...)

Share this post


Link to post
Share on other sites

Is the SpaceCenter API accessible from trom the Python or Ruby clients ?

If so, how ? 

I'm especially interested in the launch_vessel_from_sph  function.

If not, what would be necessary to add that API to one of the "scripting" clients (i.e. not C# or Java), if it's possible.

 

 

Share this post


Link to post
Share on other sites
On 9/19/2018 at 3:55 PM, mstram said:

Is the SpaceCenter API accessible from trom the Python or Ruby clients ?

If so, how ? 

I'm especially interested in the launch_vessel_from_sph  function.

If not, what would be necessary to add that API to one of the "scripting" clients (i.e. not C# or Java), if it's possible.

Yes, this is pretty basic functionality. Documentation on how to do this in the python client is here: https://krpc.github.io/krpc/python/client.html#calling-remote-procedures

Here's a python example calling launch_vessel_from_sph:

import krpc
conn = krpc.connect()
vessel = conn.space_center.launch_vessel_from_sph(...)
On 8/26/2018 at 1:27 PM, Genhis said:

Hi,

I created a new MechJeb service since krpcmj seems to be outdated.

@djungelorm Would you please add it to the kRPC website? https://genhis.github.io/KRPC.MechJeb/

Added! Sorry for the delay!

Share this post


Link to post
Share on other sites

What "state" does the game need to be in when calling  launch_vessel_from_sph  ?

** From experimenting, seems I need to launch a "dummy" aircraft on the runway (be in the "flight" mode, in order to execute the launch_vessel_from_sph function.   

Is there a way to launch a vessel from the "SpaceCenter" scene ?

 

Share this post


Link to post
Share on other sites

Yeah currently you have to be in the flight scene, it can't be from the space center scene. I am however working to address this short coming in the next release.

Share this post


Link to post
Share on other sites

Hi, 

I am trying to create my own controler for the game based upon KRPC. 

One of my goal is  to get the amount of fuel in a given stage, I have found a code in this topic based on "resources_in_decouple_stage" but it only returns 0.0.

here is the code :

import krpc
conn = krpc.connect()
vessel = conn.space_center.active_vessel


while True:

    stage = vessel.control.current_stage
    resources = vessel.resources_in_decouple_stage(stage, False)
    print (stage, "LFO =", resources.amount(" LiquidFuel"))

Do you know why ?

I am using pyhton 3.7 and the latest version of KSP and KRPC

Share this post


Link to post
Share on other sites
8 hours ago, malesquic said:

Hi, 

I am trying to create my own controler for the game based upon KRPC. 

One of my goal is  to get the amount of fuel in a given stage, I have found a code in this topic based on "resources_in_decouple_stage" but it only returns 0.0.

here is the code :

import krpc
conn = krpc.connect()
vessel = conn.space_center.active_vessel


while True:

    stage = vessel.control.current_stage
    resources = vessel.resources_in_decouple_stage(stage, False)
    print (stage, "LFO =", resources.amount(" LiquidFuel"))

Do you know why ?

I am using pyhton 3.7 and the latest version of KSP and KRPC

Looks like there is an erroneous space in your code. Try "LiquidFuel" instead of " LiquidFuel"

Share this post


Link to post
Share on other sites
10 hours ago, djungelorm said:

Looks like there is an erroneous space in your code. Try "LiquidFuel" instead of " LiquidFuel"

Indeed ^^ ,but unfortunately, it didn't change anything,  I still have the same problem :/

Also do you know how I could get the "surface" or "orbit" status that is diplayed on the navball ?

Share this post


Link to post
Share on other sites

I hope you don't mind if I barge in here and post this, but although I made LaserDist with kOS in mind, I know I've seen some people use LaserDist with kRPC too, so I thought I'd mention here that I just gave LaserDist an update that I think fixes that annoying phantom false positives problem it had for so long.  Further details in the linked post below:

 

Share this post


Link to post
Share on other sites

How would I go about getting the navball's current orientation/rotation for use in an external visualization of said ball? Would I have to get the vessel orientation based on the navball's current reference frame?

Share this post


Link to post
Share on other sites

kRPC v0.4.8 has been released!

The main new addition is that a lot of functionality is now accessible not just from the flight scene, but from other game scenes too! The documentation website also includes a note by every function indicating which scene(s) it is available in.

Support for KSP 1.5.1 and Infernal Robotics NEXT is also included in this release. The "NameTag" mod that allowed name tags to be shared between kRPC and kOS has also now been merged into kRPC, so the separate mod is no longer required.

A full change log is available here

Share this post


Link to post
Share on other sites
8 minutes ago, mstram said:

> kRPC v0.4.8 has been released!

Does it run on ksp 1.45 ?

Yep - it should work with any version of KSP from 1.2.2 and up

Share this post


Link to post
Share on other sites

Looks like the version on CKAN is only up to v0.4.7, and only says it's compatible up to 1.4.4.

 

Will there be an update for the CKAN version soon?

Share this post


Link to post
Share on other sites
9 hours ago, chaossands said:

Looks like the version on CKAN is only up to v0.4.7, and only says it's compatible up to 1.4.4.

 

Will there be an update for the CKAN version soon?

Hmmm something must be broken. It should be there. Will investigate.

@chaossands kRPC v0.4.8 is showing up for me in the latest version of ckan, and looks like it was successfully added to the meta data repository 10 days ago. Are you sure you have updated your ckan repository?

Share this post


Link to post
Share on other sites

Hi

Can I control  2 vessels, like landing 1st stage and let say perform circulation burn for 2nd ?

Share this post


Link to post
Share on other sites
20 hours ago, dakhr said:

Hi

Can I control  2 vessels, like landing 1st stage and let say perform circulation burn for 2nd ?

You can control as many vessels as you like, as long as the other vessels are within "physics range" of the active vessel (this is a restriction imposed by KSP, not kRPC). Off the top of my head I think this distance is about 25km. If a vessel moves outside that range, the game will unload it and it won't be controllable.

Annoyingly, doing a spacex style launch is kind of hard due to this restriction, as your vessels will be more than 25km away from each other. There are mods to increase the physics range but increasing it too much might cause issues for the game.

Share this post


Link to post
Share on other sites
On 11/9/2018 at 3:14 AM, djungelorm said:

Hmmm something must be broken. It should be there. Will investigate.

@chaossands kRPC v0.4.8 is showing up for me in the latest version of ckan, and looks like it was successfully added to the meta data repository 10 days ago. Are you sure you have updated your ckan repository?

I did but it must have failed to refresh. After trying it again yesterday, it showed the new version correctly and installed flawlessly. :-)

Share this post


Link to post
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.