Kerbal Space Program - Unity Robotic Controller

So I was going to buy myself a hexapod kit, but turns out they cost thousands of dollars, so I built one in my favorite game, Kerbal Space Program. Lots of mechs have been made in the game, some even that walk using simple sequencers to run the robotics. This is incredibly time consuming however, so I decided to develop my own Unity Controller.

I developed a ksp/unity “bridge” using .net memory mapped files which allow me to send values between the two applications, which makes for much, much quicker development. KSP is built targeting .NET 3.5, which doesnt support memory mapped files, so I start a custom process that handles the bridge, then use simple input/output from inside KSP. Overall this technique is pretty efficient, allowing KSP to stay 50+ FPS. My next goal is to send a camera feed from KSP into Unity, so I can view KSP in unity, allowing VR piloting.

So that’s the bridge. In terms of robotics, the legs feature custom written IK code, which sets the servos in KSP. The blue skeleton is the actual servo position, and the red is the IK skeleton it is moving towards. Each servo has it’s own PID controller, which sets the speed of the servo every frame, based on the error between the actual position, and desired IK position. The walking script is some simple logic to move the targets for the legs. Each leg must be at its target before the next walk cycle begins. The target is set along the y axis in order to adjust the hip height to it’s desired position.

I have also rigged the “neck” with IK, to keep the head at a constant position. No video of that yet, but shortly. This will also help control COM on quadrapods.

Thanks for checking it out, I hope this flies here. I have a post over on the KSP forum but its a space exploration game, so mechs don’t always get a lot of attention. I worked super hard on this so I just wanted to show it off. Feel free to hit me with any questions. Lots more updates will be coming.

[size=2][font=Roboto, Helvetica Neue, Helvetica, Arial, sans-serif][highlight=#ffffff]TODO[/highlight][/font]
[font=Roboto, Helvetica Neue, Helvetica, Arial, sans-serif][highlight=#ffffff]
]Veering while walking/:m]
]Turning in place/:m]
]Ground scanning/:m]
]Traversing slopes/:m]
]VR implementations/:m]
]Quadrapod/Bipedal Mech/:m]
(anyone know if you can post gfycat?)
gfycat.com/HeavyIdealAmericanalligator[/highlight][/font][/size]
[size=2][font=Roboto, Helvetica Neue, Helvetica, Arial, sans-serif][highlight=#ffffff]gfycat.com/BlaringAssuredCommongonolek[/highlight][/font][/size]
[font=Roboto, Helvetica Neue, Helvetica, Arial, sans-serif][/font]
https://www.youtube.com/watch?v=qtR280F4g4k[font=Roboto, Helvetica Neue, Helvetica, Arial, sans-serif][/font]
https://www.youtube.com/watch?v=N7ZHFMBv7-Q[size=2][font=Roboto, Helvetica Neue, Helvetica, Arial, sans-serif][highlight=#ffffff]
[/highlight][/font][/size]
https://www.youtube.com/watch?v=EDwlRwMckks
[font=Roboto, Helvetica Neue, Helvetica, Arial, sans-serif][/font]
[font=Roboto, Helvetica Neue, Helvetica, Arial, sans-serif][/font]
[font=Roboto, Helvetica Neue, Helvetica, Arial, sans-serif][/font]
[font=Roboto, Helvetica Neue, Helvetica, Arial, sans-serif][/font]
[font=Roboto, Helvetica Neue, Helvetica, Arial, sans-serif][/font]

Wow, very impressive work! Please do keep us updated as you progress.

Will do. Say scharette, is there any way I could get this moved to the Hexapod Forum? Didn’t see that when I first posted. Thanks.

I rigged the neck up with IK to create a steady gimbal arm,and finally got around to course correction while walking, which allowed the hexapod to walk the full length of the runway in about 15 minutes. I wrote some simple stride length adjustment code, which allows setting the desired stride length for both the right and left legs at the beginning of each stride. The actual steering is adjusted by a PID loop which decreases one side’s stride length by a percentage of its default length. So my stride length is 2 meters, and the steering PID can shorten that by up to 5%.

You can see in output log in my top video, at the beginning of every step cycle it prints the error, and what the stride is being adjusted by. Right now its just set to go straight, but when I start adjusting the launch vector, I will be able to control which direction the mech will travel. The stride length, PID settings, and max % can all be tweaked from my custom editor. I have been using it to do speed tests, which is why the rockets got lost.

Next up is slope navigation. If you watch to the end of the video you’ll see how great it is at it right now.

Hey,

. Certainly. Moved it here. Let me know if you prefer another spot.

That sounds great. Looking forward to when you hit the VR implementation… :wink:

Sincerely,

My gf was gone so I worked on this pretty much non stop over the weekend. (Also why the recording actually has sound). The hexapod now has full terrain mapping and navigation capabilities. Instead of using the vessel height to position the ground and foot targets, each foot target is now placed on the ground directly beneath it.

Each hip target is now set according to the ground position of it’t foot. There are two ways of setting the hip targets. Right now the hip targets are set at the average height of all the foot ground positions plus the target height. I’ve realized since recording the video it would be best to just set the hip targets so that the vessel is always the target height above the ground. Or some combination of the two. The first method helps going up hill, while the second is preferable for down hill. Also setting the hip height half way between the highest (foot ground + target height) and the lowest would be the way to insure each foot has the best chance of hitting it’s target when going over extremely rugged terrain.

The vessel also knows if it is traversing up a hill, is level, or traversing down a hill, and sets the color of the ground accordingly. Right now nothing changes according to that, but eventually the gait will respond to the different slopes. I tried taking it out to the mountains but I still need to find a way to orient the gyroscope to a level surface, even when the launch point is not level. The triangle begin drawn on the ground represents the leg group that is actually moving the hexapod forward.

Building the terrain mapping box was pretty difficult, as there are 36 vertices being set each frame. It took a while but it was definitely worth it.

Developing this process I found a couple of big mistakes in the gate code, which have now been fixed. The stride is now much smoother and more efficient than it used to be. I haven’t done a top speed test yet after the fixes, but average speeds have picked up across the board. Still lots of tuning to be done.

Next up is steering.

Thanks for the move. I for sure will. I really want to get to this guy, but the hexapod is taking up all my time. I will control it just like I control this Iron Man suit I was testing. I am using a touch controller to control the arm.

gfycat.com/gifs/detail/openplushangelfish

Pretty cool update. Keep up the good work!