AshishKumar4 / AirSimRCplusplus

A System to allow integration of unsupported Radio Controllers with Microsoft AirSim Simulator for Unreal Engine 4 without any coding required, as well as provide general APIs for handling Real Drones.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use any Radio Controller easily with AirSimRC++

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.

For the Architecture, check the bottom note

Usage:

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 Architecture is as follows

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.

About

A System to allow integration of unsupported Radio Controllers with Microsoft AirSim Simulator for Unreal Engine 4 without any coding required, as well as provide general APIs for handling Real Drones.

License:GNU General Public License v3.0


Languages

Language:C++ 70.5%Language:Python 22.1%Language:Makefile 4.9%Language:C 2.5%