Jump to content

Yet Another Remote Kontroller


c4ooo

Recommended Posts

YARK plugin can be be downloaded here.

 

Yet Another Remote Kontroller (YARK)

YARK is a plugin that allows for the remote control and flight data monitoring of vessels through a TCP socket connection. YARK could be used to build "remote" control panels powered by Raspberry PIs or other linux based computers with WIFI, or for writing remote control scripts. YARK isn't meant to be as extensive as kRPC, being tailored more for people making control panel rather then remote control scripts.

YARK is heavily based on, and wouldn't be possible without, @zitronen's KSPSerialIO plugin.

 

Some of YARK's features: 

  • Craft orientation (Pitch, Roll, Heading)
  • "11th" SAS mode, allowing you to point the vessel at an arbitrary vector (Experimental)
  • AxisInput (Controlling Throttle/Pitch/Roll/Yaw/TXYZ)
  • Control and monitoring of Action Group, SAS, RCS, Brakes etc.
  • Navball vectors (Prograde, Target, Maneuver)
  • Alt, Velocity, etc
  • Orbital Information
  • Fuel Levels
  • Getting and settings timewarp mode, SAS and speed modes, and other miscellaneous  stuff.

 

Using YARK

I have provided a set of C++ and Java bindings for using YARK, rather then trying to explain the protocol. Along with the bindings, I have also provided a sample script which should show how to use the bindings. The script simply checks if the rocket is falling and executes a simple abort procedure. The bindings might have slight differences between the Java and C++ versions, but should function the same.

Client documentation:

Spoiler

 

Class: Client

  • Client(): Constructor
  • void Connect(String IP, int PORT)Asynchronously Starts a new connection and returns
  • StatusPacket Status: Holds status information about the craft. (See here for members)
  • VesselPacket Vessel: Holds flight data about the craft. (See here for members)
  • ControlPacket Control: Used to control craft. (See here for members)
  • void SendControls(): Sends controls to YARK.
  • void WaitForConnection(): Halts until the client connects
  • int GetState(): Returns connection state (TCP_CONNECTING, TCP_CONNECTED,  or TCP_FAILED)
  • void SendControls(): Sends control packet to YARK server
  • void Shutdown(): Closes connection
  • String error: If GetState() == TCP_FAILED, holds an error message.

VesselPacket and ControlPacket also have some helper methods to, these should alleviate you having to do bitmath and such.

 

 

Configuring YARK: 

YARK has two settings found in the PluginData folder. The "TCPPort" field configures the port on which YARK hosts the server (defaults to 9999), and "UpdatesPerSecond" is the number of updates the server will attempt to send per second. If left zero, the server will simply send an update every frame. (UpdatesPerSecond defaults to 0/every-frame)

 

Compiling YARK:

YARK can be compiled like any other KSP plugin from the source code found here. Just point MSVS to the required unity reference DLLs, and make sure you compile for .NET 3.5.

 

Multi-Functional Display (MFD) (Main Thread)

The YARK-MFD is a multifunctional display written in c++ with openGL that uses YARK to fetch and display flight data. Read the main thread for more info.

Screenshot:

Spoiler

N6ARZbB.png

 

Edited by c4ooo
Link to comment
Share on other sites

On 7/23/2018 at 4:09 PM, Freshmeat said:

So, do you have documentation for this. I am in the process of rebuilding and would like to consider all alternatives.

I will try to have to have more or less finalized documentation by the end of this week. (Tomorrow I plan on fixing how the desktop-client renders the navball)

 

Right now, the current setup acts this way: 

Once the client connects, it will automatically start receiving packets from the server. Each packet starts with a 3 byte header. The first two bytes are always 0xDEAD (lame, I know :rolleyes:), and the third byte identifies what type of packet it is. The first type (0x01) is a "Status Packet", which notifies the client of whether there is a vessel currently in flight, and what name of that vessel is, and other "static" data about the vessel. It gets sent when the client first connects, when the flight starts/ends, or when the vessel is switched. The second type of packet (0x02) is the "Vessel Data Packet" which gets sent every frame, as long as there is a vessel in flight, and holds "dynamic" data about the vessel such as altitude, attitude, fuel, etc.

Edit:

not relevant

Edited by c4ooo
Link to comment
Share on other sites

EDIT:

Irrelevant 

Spoiler


OK so, I pushed the most recent code to github. (Well actually, I haven't pushed most of the Client because it uses a large SDL/openGL wrapper I wrote, and I think I will make that a separate repo.<sidetrack> All my c++ openGL projects use this wrapper in different stages of its development, and because I was always simply copy and pasting the wrapper from the previous project to the next, the whole thing is a huge mess. <sidetrack>)

https://github.com/c4ooo/YARK/tree/master/YARK_CLIENT/YARK_CLIENT/Client contains a very simple c++ TCP client to receive data from the plugin. If you wanted to use that code, you would have to write a main method, #including Client.h, and in which you would create a new Client() object , passing the appropriate params to the constructor. Once Client.state is equal to TCPCLIENT_CONNECTED, you can start reading the appropriate data from Client.status (the "static" data packet) and Client.dataIn (the "dynamic" data packet) and writing to Client.CP (the control packet). To actually send the control packet you need to call Client.SendControls(). 

The structs are defined in: https://github.com/c4ooo/YARK/blob/master/YARK_CLIENT/YARK_CLIENT/Client/Struts.h

Yea, I know everything is messy and confusing right now, but I will be working to clean it up as well as writing a proper documentation and stuff.

Ohh and, the plugin's server is started on port 9999, I will make this configurable ASAP.  

 

Edit:

Just a screenshot: :)

Spoiler

1AtDEWd.png


 

 

Edited by c4ooo
Link to comment
Share on other sites

  • 5 months later...

I hate to triple post, but it's been a while an I've made some changes. First of all, I have refactored most of the plugin code into separate files, and moved the MFD code into a separate repository. This should make everything easier for me to manage, and the refactor will allow me to add support for multiple client connections. when I get around to it. 

Secondly, I improved the protocol. Instead of trying to reexplain the protocol every time i change it, which probably has led to some confusion, I simply have created a set of Java and C++ bindings. The bindings come with an example script, and I think providing the bindings should make this plugin easy to work with.

I have added some features to YARK, such as an "11th" SAS mode that allows the client to specify a custom vector to point the ship at.

 

If anyone is confused by the helper methods in the ControlPacket Class/Struct, I will be happy to document them!

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