For our Adaptive Control & Reinforcement Learning class, our assignment was to design controllers for a simulated helicopter. However, the visualization was only through MATLAB graphs, which prompted myself and my teammate Joydeep Biswas to create a simple OpenGL helicopter simulation to visualize our controllers. Recently, our professor requested it, so we spent some time making it into a nice little package. We swapped to using Plinth, a 3D game engine developed by two of my friends Pyry Matikainen and Prasanna Velagapudi. NOTE: Plinth requires OpenGL 2.0 and Shader Model 2.0, so most likely you'll need a decent graphics card. My Thinkpad x201 integrated graphics can handle it, although it seems like a lot of the rendering is done in software and the shadows are a bit wonky.
Our helicopter simulation is very basic, with just a gunship model that spins the blades. It works on Windows, Linux, and Mac. You can set 6-DOF positions for the helicopter from MATLAB or any network interface and record frames to XVID avis.
To run the helicopter simulation in download our helicopter simulation zip file (~15 MB).
To move the camera angle around in the helicopter visualization, click and drag the left or right mouse buttons. Left mouse controls rotation; right mouse controls pan + zoom. You can also use WASD to move the camera around. To move the camera vertically, use ctrl (down) and space (up). Alternatively, you can set the 6-DOF position of the camera with the MATLAB script heliSetCameraPosition.
A few experimental abilities are available with the F1-F4 keys. F2 turns on motion blurring. F3 turns on a fancier version that renders 10 frames for each frame (so you have to have a good graphics card). F1 and F4 turn off the normal and fancy versions of the motion blurring, respectively.
Plinth uses Horde3D combined with Lua scripts for most of the heavy lifting. Edit game\testmaster.lua if you want to modify the helicopter visualization. Most things can be done through that one Lua script. One of the great things about Plinth is you can use Putty to telnet and execute custom Lua commands. This is how MATLAB is able to communicate and control the simulation. See plinth.bat and the assorted MATLAB scripts to find out more about how the socket communication works. It’s pretty simple, except make sure to whitelist the connecting IP in Plinth.bat before trying to connect.
If an error occurs, check the log files log.txt and Horde3D_Log.html.
On integrated graphics, shadows seem to act up. Thus, if you experience problems with weird shadows, you can disable them by changing ShadowMapCountI from 3 to 0 in game\testmaster.lua. So line 42 should read:
h3d:SetNodeParamI(self.light, h3d.H3DLight.ShadowMapCountI, 0)
The current visualization is themed on an ice plain with a sunset, however this might not be for everybody. Plinth can swap out models and textures. Another possible configuration already in the simulation is the thunderstorms + rocks visualization. You just need to rename two folders and a file in the zip file. Rename textures\ambientMap_thunderstorm.dds to textures\ambientMap.dds, and models\skybox_thunderstorms to models\skybox, and textures\models_rocks to textures\models. That should turn the visualization to the one on the right. Further customizations can be made in game\testmaster.lua..
We provide Mac and Linux (x86 and x64) binaries and run shell scripts. It isn’t well tested, but seems to work.