Simulation
The Flix drone simulator is based on Gazebo 11 and runs the firmware code in virtual physical environment.
Gazebo 11 works on Ubuntu 20.04 and used to work on macOS. However, on the recent macOS versions it seems to be broken, so Ubuntu 20.04 is recommended.
Installation
-
Clone the Flix repository using it:
git clone https://github.com/okalachev/flix.git && cd flix -
Install Arduino CLI:
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh -
Install Gazebo 11:
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list' wget https://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add - sudo apt-get update sudo apt-get install -y gazebo11 libgazebo11-devSet up your Gazebo environment variables:
echo "source /usr/share/gazebo/setup.sh" >> ~/.bashrc source ~/.bashrc -
Install SDL2 and other dependencies:
sudo apt-get update && sudo apt-get install build-essential libsdl2-dev -
Add your user to the
inputgroup to enable joystick support (you need to re-login after this command):sudo usermod -a -G input $USER -
Run the simulation:
make simulator
Usage
Just like the real drone, the simulator can be controlled using a USB remote control or a smartphone.
Control with smartphone
- Install QGroundControl mobile app on your smartphone. For iOS, use QGroundControl build from TAJISOFT.
- Connect your smartphone to the same Wi-Fi network as the machine running the simulator.
- If you're using a virtual machine, make sure that its network is set to the bridged mode with Wi-Fi adapter selected.
- Run the simulation.
- Open QGroundControl app. It should connect and begin showing the virtual drone's telemetry automatically.
- Go to the settings and enable Virtual Joystick. Auto-Center Throttle setting should be disabled.
- Use the virtual joystick to fly the drone!
Control with USB remote control
- Connect your USB remote control to the machine running the simulator.
- Run the simulation.
- Calibrate the RC using
crcommand in the command line interface. - Use the USB remote control to fly the drone!
Piloting
To start the flight, arm the drone moving the throttle stick to the bottom right position:
To disarm, move the throttle stick to the bottom left position:
See other piloting and usage details in general usage article.
Code structure
Flix simulator consists of the following components:
- Physical model of the drone in Gazebo format:
models/flix/flix.sdf. - Plugin for Gazebo:
simulator.cpp. The plugin is attached to the physical model. It receives stick positions from the controller, gets the data from the virtual sensors, and then passes this data to the Arduino code. - Arduino emulation:
Arduino.h. This file contains partial implementation of the Arduino API, that is working within Gazebo plugin environment.