This software stack allows you to integrate any Radio Controller hasle-free, to use with Unreal Engine 4 based AirSim Simulator as well as to provide extended APIs for general use.
Wanted to use your Radio Controller but its not supported by AirSim? or just wanted to get data from a Radio Controller to a PC for god knows what reason? Well this might just end your search.
AirSimRC++ allows you to connect your random radio controller to a PC, via an intermediate Arduino (or stm8/32 or any other microcontroller really), and provide a useful set of APIs and tools to do stuff with the data, for example, connect to the AirSim Simulator of Unreal Engine 4, without EXPLICITLY coding for a new RX.
First upload the ArduinoInterface sketch onto an arduino board (or stm etc.). Tweak the serial speed as the max available on that board.
Connect the board to the Reciever, All signal pins on PWM pins of the Arduino. If required, change the pin layout in the sketch as necessary.
Launch Unreal Engine 4 and a project configured with AirSim, and hit 'Play'
Execute the AirSimControls.py script (rom the AirSim Handler folder) using Python 3. Terminal -> python3 AirSimControls.py
Open a terminal in the ManualController Directory and type make to compile and generate binaries.
Switch on the Radio controller and make sure it is binded to the reciever.
Execute the ManualController Binary.
Procedures to calibrate the controller follows. First both joysticks to bottom, then top, then left then right then leave in middle. Then Wait for 5 seconds for the procedure to finish.
Following the steps, You should now be able to fly the MultiCopter using the controller, intuitively. Report any bugs/problems if found.
The Radio Reciever is connected to an Arduino, with provided Code uploaded on it. The Radio Reciever sends data recieved from the transmitter via PWM signals. Arduino then writes the data onto a Serial port as stream to a PC attached.
The ManualController Program reads from this Serial port, unpacks the data, calibrates it when needed, and applies some signal processing to sanitize and smoothen it, and converts it into a range of 0-255. ManualController program then connects to a local server, created by the AirSimControls.py and begins sending RX data over via sockets.
The AirSimControls.py is a Python 3 script that connects to the AirSim module running along Unreal Engine 4, sets up a local server, listens for RX data from ManualController, and then calls AirSim's internal APIs to forward the commands and thus control the virtual drone as if real.
One might wonder why so much trouble setting up local servers and passing data via sockets. well, This code is a part of a greater project, where I needed to control a Real Drone, via a PC itself. This ManualController was developed to just test all the protocols and APIs involved. And to test the offboard side of things, I created a simple 'Drone Emulating' server, which mimicked the Drone's APIs that I had developed, but instead of commanding a real drone, commanded a virtual one in Unreal Engine itself. I thought this can be useful for someone as a standalone system itself, thus this. The overhead of data transfers isn't significant as compared to the main bottleneck, which is the Reciever to Arduino communication, which can't be optimized. Still, Suggestions, Bug alerts and possible fixes as well as any optimization you well are welcomed, Do open a pull request.