Fun with Kerbal Space Program

So right before Christmas there was a new drop of KSP (Kerbal Space Program), and I’ve been playing it on/off again.  One thing that I’ve been amazed about is all of the pluggins.  One that caught my eye was KSPSerialIO, and it’s project page.  It’s mainly focused on using an Arduino based display/control system connected via a serial port.

So I thought I’d make some minor modification so I could talk to it locally.

KSPSerialIO data collection

KSPSerialIO data collection

KSP is a Unity3D program, which is very modular, and using C# you can write pluggin DLLs.  However Unity doesn’t use the native .NET framework on Windows, instead it uses Mono.  So things like named pipes, and message queues are out of the question.  However I was able to find netmq, a zeromq port in C#. Using a special branch (until it’s been mainlined) It will even work with Unity 3D/Mono as they are dependent on being .NET 3.5 compatible (not 2.0 or 4.0!)

So what do I have now?  A server program that the KSP pluggin can communicate with.  Right now it’s just telemetry data being sent to a console.  The next step is to send some commands back (blink the lights or something useful), and then see if I can get it tied into some named pipe so that any program that can open a file can control the craft.

Of course this uses floating point, so I’m going to have to see about how to deal with a binary representation of a float in C# to anything else.

A few minor tips.  First is that KSP takes a long time to load, and when you are crashing out, or constantly having to re-load to insert new versions of your DLL, it’s a real pain to be waiting the 2-3 minutes for it to load.  I found this plugin, ActiveTextureManagement, which compresses the textures.  Now it took me a good 20 minutes for my machine to do this, but once it was done it cut load time to around a minute and a half!

Another great thing to have is a RAM disk (well that, fast CPU/GPU, and plenty of RAM), so I used Softperfect’s RAM Disk. Steam doesn’t mind you copying a game off of disk, and running it off another disk.  I found this combination of a RAM disk + compressing the textures got me to loading in under a minute!

Although once KSP is loaded it’s in memory so most people probably won’t benefit much from it, but if you are constantly loading/unloading it greatly helps! (it feels a bit like experimenting with config.sys/autoexec.bat of the old days, and the difference even smartdrv could make).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.