• Stars
    star
    122
  • Rank 290,316 (Top 6 %)
  • Language
    C++
  • License
    MIT License
  • Created over 6 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Multi-language multirotor flight simulator using UnrealEngine

About

MulticopterSim is a simple multicopter flight simulator using Unreal Engine. It runs on Windows, using sockets to communicate stick demands, vehicle state and camera images with flight-control programs written in various languages. This approach supports rapid prototyping of flight-control algorithms without having to recompile the simulator itself.

Prerequisites

Hardware

I am currently developing MulticopterSim on an HP Z440 workstation with 32GB RAM and NVIDIA GeForce GTX 1080 Ti. It may however be possible to develop on a less β€œloaded” machine – see here for the minimum requirements recommended by Unreal Engine.

For a realistic flying experience, you will also likely want some sort of game controller or R/C transmitter. MulticopterSim currently supports the following controllers through the Joystick class:

  • PS4 controller
  • XBox One controller
  • XBox 360 controller
  • XBox 360 controller clone
  • PS3 controller clone
  • Logitech Extreme Pro 3D joystick
  • Logitech F310 gamepad
  • FrSky Taranis TX9 RC transmitter with mini USB cable
  • FrSky XSR-Sim dongle
  • Spektrum WS1000 dongle
  • Great Planes RealFlight Interlink

If you don't have a controller, MulticopterSim will use input from the numeric keypad on your keyboard (make sure that NumLock is turned on!) The key mappings are based on those used in Microsoft Flight Simulator.

Toolchain

You will need Unreal Engine 5 (UE5) and Visual Studio C++. I am attempting to use the latest versions, which as of the time of this writing are UE5.2.0 and Visual Studio 2022. To install UE5 and Visual Studio, follow the directions here.

Building

  1. Clone this repository.

  2. Right-click on the Simulator/MulticopterSim.uproject file and select Generate Visual Studio project file to generate a .sln file

  3. Double-click on the resulting MulticopterSim.sln file to launch VisualStudio. The first time you do this, you may have to wait a few minutes while Visual Studio parses up all of the UE5 files needed to build the project.

  4. In VisualStudio, hit the F5 key to build the project and launch UnrealEditor.

  5. In UnrealEditor, select one of the maps in Content Drawer/MulticopterSim/Maps. Then open the Content/C++ Classes/MulticopterSim/vehicles folder and drag the Phantom pawn into the map.

  6. To enable interaction outside of the editor, the first time you run the simulator you will want to go to Edit -> Editor Preferences -> Performance and disable the option Use Less CPU when in Background:

Testing

Clone the SimFlightControl repository. Run the launch.py script in SimFlightControl/python/. It will tell you to hit the Play button back in the simulator. When you hit the button, the vehicle should rise quickly to an altitude of 10 meters.

Image processing

If you have Python OpenCV installed on your computer, you can try out the simulated camera feature of MulticopterSim by un-commenting the vehicle.addCamera() line in the source code. Running the Python launch program again, you should see a 640x480 image showing edge detection in OpenCV. This feature can be glitchy the first time you try it.

Design principles

The core of MulticopterSim is the C++ VehicleThread class. This class provides support for running the vehicle dynamics and the PID control regime on its own thread, after it first disables the built-in physics in UE5. The dynamics used are based directly on the model presented in this paper, written as a standalone, header-only C++ class that can be easily adapted for other simulators and applications if desired. This class also supports different frame configurations (quadcopter, hexacopter) via virtual methods.

The Camera class can be instantiated to transmit the images collected by a simulated gimbal-mounted camera on the vehicle, using a library like OpenCV. Computer-vision algorithms running in a Camera subclass can then be used as input to the PID control running in the VehicleThread. The following figure illustrates this arrangement, using a traditional cascade-control (slow outer loop / fast inner loop) diagram:

Citing MulticopterSim

Please cite MulticopterSim as:

@ARTICLE{10.3389/fnbot.2020.00016,
AUTHOR={Levy, Simon D.},   
TITLE={Robustness Through Simplicity: A Minimalist Gateway to Neurorobotic Flight},      
JOURNAL={Frontiers in Neurorobotics},      
VOLUME={14},           
YEAR={2020},      
URL={https://www.frontiersin.org/articles/10.3389/fnbot.2020.00016},       
DOI={10.3389/fnbot.2020.00016},      
ISSN={1662-5218}
}

More Repositories

1

TinyEKF

Lightweight C/C++ Extended Kalman Filter with Python for prototyping
Python
979
star
2

BreezySLAM

Simple, efficient, open-source package for Simultaneous Localization and Mapping
C
758
star
3

Hackflight

Minimalist flight-control toolkit for makers
C++
283
star
4

AirSimTensorFlow

A simple example of using Microsoft AirSim to train a TensorFlow neural net on collision avoidance
Python
231
star
5

SensorFusion

A simple Matlab example of sensor fusion using a Kalman filter
MATLAB
151
star
6

OpenCV-Python-Hacks

Optical flow and other tricks in OpenCV
Python
93
star
7

RPiAdHocWiFi

Simple ad-hoc wireless network support for Raspberry Pi
Shell
90
star
8

GooMPy

Google Maps in Python
Python
83
star
9

neat-gym

Neuro-evolution for OpenAI Gym environments
Python
55
star
10

ARDroneAutoPylot

Auto-Pilot the Parrot AR.Drone from Python (or Matlab or C)
C
43
star
11

RealtimePlotter

Python real-time scrolling multi-plot over time
Python
40
star
12

PyQuadSim

A open-source quadrotor simulator in Python for Linux [NO LONGER SUPPORTED]
Python
38
star
13

OpenCV_GStreamer

Simple C++ example of using OpenCV with GStreamer
C++
37
star
14

UE4_OpenCV

Simple example of adding machine vision to UnrealEngine4 with OpenCV
C++
35
star
15

PyRoboViz

Simple Python tool for 2D visualization of robot pose and map
Python
34
star
16

USFS

Cross-platform libraries for the EM7180 Ultimate Sensor Fusion Solution
C++
30
star
17

CppSockets

Simple cross-platform socket support for C++
C++
28
star
18

VL53L5CX

Arduino library for ST Microelectronics VL53L5CX multizone Time-of-Flight ranging sensor
C
27
star
19

gym-copter

Gymnasium environment for reinforcement learning with multicopters
Python
27
star
20

NeatoPylot

Auto-Pilot the Neato XV-11 from Python
Python
26
star
21

RoverPylot

Pilot the Brookstone Rover 2.0 and Rover Revolution from Python
Python
22
star
22

BreezyCreate2

Ultra-simple Python API for iRobot Create 2
Python
21
star
23

BreezySTM32

Arduino-like API for for STM32-based flight controllers [NO LONGER SUPPORTED]
C
18
star
24

PySticks

Python API for flying with a game controller
Python
17
star
25

m021v4l2

Capture images from Leopard Imaging LI-USB30-M021 camera on Linux
C
17
star
26

PyPX4Flow

A simple Python package for reading from the PX4Flow optical-flow sensor
Python
17
star
27

AndroidBluetoothClient

Simple Bluetooth socket client for Android
Java
14
star
28

ISCPP

Introduction to Scientific Computing and Programming in Python
Python
13
star
29

UBX_Parser

C++ parser for binary UBX GPS messages with Arduino example
C++
12
star
30

PS2X_lib

Arduino Playstation2 library with compiler warnings fixed
C++
11
star
31

BreezyArduCAM

A simple Arduino API for the ArduCAM Mini
C
11
star
32

xvlidar

A simple Python class for reading from GetSurreal's XV Lidar Controller
Python
11
star
33

BreezyLidar

BreezyLidar - Simple, efficient, Lidar access in Python and C++
C
10
star
34

MSPPG

Multiwii Serial Protocol Parser Generator
10
star
35

CrossPlatformDataBus

Cross-platform C++ support for I2C and SPI devices
C++
9
star
36

RoboFirmwareToolkit

Simple C++ Robot Firmware Toolkit for makers
C++
9
star
37

DshotSTM32

DSHOT protocol library for STM32 microcontrollers
C++
8
star
38

DSMRX

Cross-platform interrupt-based C++ library for Spektrum DSM receivers
C++
7
star
39

PMW3901

Arduino library for PMW3901 optical flow sensor
C++
6
star
40

LambdaFlight

Haskell-based flight controller with support for SITL simulation
C
6
star
41

PyMaxBotix

A cross-platform Python package for reading from MaxBotix ulatrasonic distance sensors
Python
6
star
42

ArduRust32

Calling Rust code from an Arduino sketch on STM32 microcontrollers
Python
6
star
43

TinyFlight

Minimalist flight-control firmware with simulator
C++
6
star
44

ArduEye

Arduino libraries and support for Centeye vision chips
C++
5
star
45

RXInterrupt

Interrupt-driven PWM RC receiver handling for Arduino
C++
5
star
46

TwoStepFilter

English translation of Jung Keun Lee's Two-step Kalman/Complementary Filter for Estimation of Vertical Position
TeX
5
star
47

PAA3905

Arduino library for the Pesky Products PAA3905 optical flow camera
C++
5
star
48

CA

Cellular automata in Matlab
MATLAB
5
star
49

pidcontroller

Simple example of an altitude-hold PID controller in Python
Python
5
star
50

kbhit

A Python class implementing KBHIT, the standard keyboard-interrupt poller
Python
5
star
51

AirSimCar

Quickstart for driving the car in Microsoft AirSim
Python
4
star
52

OpticalFlow

Simple header-only C++ library for optical flow
C++
4
star
53

BMI270-SPI

Simple Arduino library for the Bosch BMI270 inertial measurement unit over the SPI bus
C
3
star
54

ES-Gym

Evolutionary Strategies in PyTorch for OpenAI Gym environments
Python
3
star
55

NMEA

NMEA parsing in C++ with Arduino example
C++
3
star
56

vsarobot

VSA Behavior-Based Robot Demo with V-REP
C++
3
star
57

BreezyRobotArm

A simple Python library for controlling robot arms
Python
3
star
58

PythonSockets

Simple socket examples in Python
Python
3
star
59

MPU6x00

Arduino library for InvenSense MPU6000/6500 IMU using SPI bus
C++
3
star
60

Besties

Simple serial communication between Arduino Mega and its new BFF, ODROID XU4 with Shifter Shield
Arduino
2
star
61

HackflightGCS

Windows executable for Hackflight Ground Control Station
2
star
62

gym-mygame

A template for making your own OpenAI Gym game environment
Python
2
star
63

SUEAP

Suite of Evolutionary Algorithms in Parallel for Matlab and Python
MATLAB
2
star
64

FreeSixIMU2

An updated version of the FreeSixIMU library that works with the Arduino Due
C++
2
star
65

LateralInhibition

Matlab software for Levy & Gayler (2009) "Lateral Inhibition" in a Fully Distributed Connectionist Architecture
MATLAB
2
star
66

NengoCPP

Example of how to call the Nengo neural simulator from C++
C++
2
star
67

ArduinoTools

Useful sketches for Arduino-compatible microcontrollers
Makefile
2
star
68

MS5637

Cross-platform C++ library for the MS5637 barometer
C++
2
star
69

arduino-STM32L4

Arduino support for STM32L4 Flight Controllers
C
2
star
70

TinyNEF

Simple implementation of the Neural Engineering Framework
Python
2
star
71

MB1242

Cross-platform C++ library for for MaxBotix MB1242 sonar
C++
2
star
72

LSM6DSM

Cross-platform C++ library for the STMicroelectronics LSM6DSM Inertial Measurement Unit
C++
1
star
73

simondlevy.github.io

JavaScript
1
star
74

bolt-esc

ESC board for Crazyflie Bolt 1.1
1
star
75

simdvs

Simple Python-based Dynamic Vision Sensor simulator
Python
1
star
76

MultirotorDynamics

Multirotor dynamics in Matlab, Python, and C++
MATLAB
1
star
77

BotBoarduino_CH3R_PS2

Cleaned-up version of Lynxmotion BoardBoarduino code for CH3-R hexapod robot
Arduino
1
star
78

ArduinoPrintf

A C-like printf() function for the Arduino
C++
1
star
79

PyGCSUDP

Python API and joystick example for OpenPilot Ground Control Station UDP connection: fly OP with a joystick!
Python
1
star
80

STM32F4_MPU6000

Reading from the MPU6000 IMU using the STM32F405 MCU
C++
1
star
81

WaveshareOLED

Arduino library for Waveshare 1.5" OLED RGB display
C++
1
star
82

huffcode

Simple Huffman code implementation in Python
Python
1
star
83

MAVLinkAutoPylot

Python support for autopilot on MAVLink-based flight controllers
Python
1
star
84

Hackflight-VREP

VREP-based flight simulator using the Hackflight flight control firmware
C++
1
star
85

eDVS

Arduino / Python support for the iniVation eDVS sensor
Python
1
star
86

PECON

Parallel Evaluation CONntroller: Run Matlab in Parallel on your Multicore PC or Unix Cluster
MATLAB
1
star
87

CPPMRX

Bare-bones Arduino library for reading from CPPM receivers
C++
1
star
88

HackflightCPP

C++ flight-control toolkit for makers
Java
1
star
89

WinJSTest

A little Windows console program for testing joysticks , game controllers, and similar devices
C++
1
star
90

CMA-Gym

CMA-ES for OpenAI gym environments
Python
1
star
91

Centeye

Moved to https://github.com/simondlevy/ArduEye
1
star