Giter VIP home page Giter VIP logo

krpc's Introduction

kRPC - Remote Procedure Calls for Kerbal Space Program

ci docs

kRPC allows you to control Kerbal Space Program from scripts running outside of the game, and comes with client libraries for many popular languages.

Contributing

Contributions to kRPC are very welcome. Please refer to this guide.

KSP2

kRPC is coming to KSP2! Notice: I am not actively developing this, due to lack of time. If you would like to contribute PRs or take over the project please get in touch on Discord.

You can find it in the new kRPC2 repository here: https://github.com/krpc/krpc2

Links for Developers

krpc's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

krpc's Issues

resources.resource_names missing

Documented here: https://github.com/djungelorm/krpc/wiki/SpaceCenter-Service#properties-6

C:\Apps\Python27\python.exe 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]
>>> import krpc
>>> ksp = krpc.connect(name='Launch to orbit')
>>> space_center = ksp.space_center
>>> vessel = space_center.active_vessel
>>> resources = vessel.resources
>>> print resources
<krpc.types.Resources object at 0x029C3A30>
>>> print resources.resource_names
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'Resources' object has no attribute 'resource_names'

Vectors for maneuver nodes

Need to extend the node API to better support passing vectors.

Also Node.Vector only returns vectors in the maneuver reference frame. Should support other frames of reference.

For example, setting a maneuver node's burn direction to a given vector in a given reference frame.

Streams

A problem with RPCs is that to wait until something happens, you have to actively poll for it. The inclusion of an events publish/subscribe system improve this - although this a feature for the far future and is quite a distraction for the core aims of this project.

Basic services

Add basic services:

  • Simple autopiloting commands - e.g. execute manoever node, set heading
  • Querying all sorts of vessel data such as resources, parts, atmospheric flight data...
  • Manoever node editing commands
  • Provide read/write access to object properties in the public KSP API (i.e. FlightGlobals etc.)

UI for customising server settings

Change address and port from the UI

Design:

  • Address is a text field with an adjacent check box for "any"
  • Port is a text field for an integer
  • Validate each keypress in the text fields so invalid characters don't appear
  • Might need a workaround for Linux where text-input causes stage activation etc.

Proxy objects

Add proxy object support. Classes annotated with [KRPCClass] are made available to clients via a unique uint64 identifier.

Design:

  • Methods in a class are annotated with [KRPCMethod] and they appear as a remote procedure call named ClassName_MethodName with an attribute Class.Method(MethodName) so that clients know its a class method (and not a procedure that happens to be called the same thing). These procedures take a uint64 object identifier as the first parameter, followed by the methods parameters.
  • Properties in a class are annotated with [KRPCProperty] and appear as RPCs named ClassName_get_PropertyName and ClassName_set_PropertyName, with attributes Class.Property.Get(PropertyName) and Class.Property.Set(PropertyName) respectively. These procedures take a uint64 object identifier as the first parameter (followed by another parameter for the setter).
  • Instances of a class can be passed as parameter values and return values. The type of the parameter / return type is uint64 (the unique id of the object) but the procedure has an attribute indicating what class the identifier refers to (e.g. ReturnType.Class(ClassName) or ParameterType(1).Class(ClassName))
    Could also provide helper classes in the to make implementing them in the server easier. E.g. a generic way of storing state.
  • You can mix and match the above as you like, e.g. have a property whose type is a class.
  • Construction of objects must happen in a some other procedure call that returns an instance of the object. You can't call a class' constructor directly. (Change this?)
  • Destruction of objects is handled by the service code, NOT the server code. Whenever an object is passed to a client, a reference is kept to it in the ObjectStore class so that a client doesn't find that the instance magically vanishes. However, service code has the option of calling ObjectStore.RemoveInstance to allow instances to be garbage collected (and the service will need to make sure that calling this makes sense - i.e. that the client isn't expecting the object to exist)

Save window state

Including visibility and position.

Visible should reset to true if Toolbar API plugin isn't installed - otherwise you won't be able to open the window.

Shutdown behaviour

Need to check that shutdown behaviour works properly.

E.g. exiting flight mode, crashing the vessel, ...

Syntactic sugar for service code

Allow services authors to define an RPC as a public static function that takes parameters of non-protobuffer types, and have requests automatically decoded to fit them.

Would need to attribute the RPC with the type of the request protocol buffer, e.g. KRPCProcedure[input=MessageType]

Schema auto-discovery

Currently any schemas must be put in the python client install directory as: krpc/schema/MySchema.py

Need to auto-generate these from the server, or similar.

Support more action groups

"according to the description, you support only action groups 1 to 9. It would be nice to have support for all ten numeric action groups, as well as for the special action groups like gear or abort. (maybe map the latter to indices > 10 with an enum?)"

Automated service documentation

A tool that takes an assembly for a service, and constructs a list of all procedures etc. to go in the wiki. Should make documentation easier and less error prone.

Rover control

Need API for driving rovers.

On branch feature/wheel-controls

Allow null values

Should be able to pass null/None values between client and server.

For example, setting the heading for basic autopiloting to nothing from a python client:
Control.Heading = None

GUI Service

A service that lets you create windows and display info. Essentially exposing Unity's GUI commands as RPCs.

Icons don't appear

On windows, the close button icon doesn't appear. The button is blank.

Add dropdown for server ip addresses

Scan the local network interfaces for their IP addresses, and populate a dropdown menu in the UI to set the server IP.

You should also be able to manually specify the IP address via a text field (for example, if scanning the interfaces doesn't find them all for some reason).

Parts API

Add API for examining the parts of a vessel.

Implementation on branch feature/parts

Documentation of procedures

The server should pass C# documentation applied to kRPC procedures through to the client (e.g. to set the docstring for a procedure)

Can't be done by reflection - as the C# compiler strips out comments.
Could generate an XML doc file from the code and distribute that with the DLL.

Support for collections

Need support for passing collections of objects as parameters and return values.

Procedures on the server can have parameter/return values of type IList<T> or IDictionary<K,V>. The server then converts these collections to/form protocol buffer messages of type KRPC.List and KRPC.Dictionary to be passed on the wire. Additional type information required by the client to encode/decode these protobuf messages to native types (e.g. python list or dict) are retrieved from the server via the GetServices RPC (using procedure attributes).

Other notes:

  • Need support for nested collections
  • Restrict the type for keys to dictionaries to a sensible subset of kRPC types
  • Needs to handle memory management for collections of instances of kRPCClass classes

Server does not stop immediately

On windows, server does not clean up resources immediately when stop server is clicked. The address/port remains in use until some time later after which the server can be started again.

Realism mode - signal delay and rate limiting

The following would add to the realism of the mod as a "mission control" mod:

  • Limiting the number of RPCs executed per second (i.e. the computational power of the vessel)
  • Rate limiting the bytes sent to/from the server (the communication bandwidth)
  • Signal delay (communication latency)

And parameters for these last two could integrate with RemoteTech.

Enum support

Allow enumeration types, both those defined in C# and in .proto files

UI activity console

Add a window that shows client activity. Should be useful for debugging scripts.

Design:

  • Tabbed window, with one tab per client.
  • When clients disconnet their tab remains, but can then be closed.
  • Each entry in the log is a one line description of the RPC with a +/- to show/hide more details of the input/output data
  • Highlight RPCs that caused errors
  • Timestamp the logs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.