This quickstart gets you started developing MAVSDK C++ core applications on macOS and Ubuntu Linux. It demonstrates how to run a simple MAVSDK example against a simulated vehicle, and observe the operation using the console and in a ground station.
First install the MAVSDK library on your platform
- MacOS: Install Homebrew and use it to install the library:
brew install mavsdk
- Ubuntu: Download the .deb file for your system from MAVSDK releases and install it using
sudo dpkg -i mavsdk_0.24.0_ubuntu18.04_amd64.deb
To use other platforms or programming languages see: Installation.
You will also to install a build toolchain to compile your code.
However the required dependencies (e.g.
cmake, compiler) are installed as part of setting up the simulator (next step).
The easiest way to try out MAVSDK is to run one of the MAVSDK examples against a simulated version of the vehicle.
To set up and run the PX4 JMAVSim multicopter simulator on MacOS or Ubuntu:
- Get the PX4 flight stack source code using git (you may need to install git for your platform):
# Download PX4 Source Code git clone https://github.com/PX4/Firmware.git --recursive cd Firmware
Install the PX4 development environment (for building the simulator):
ulimit -S -n 2048 # Common dependencies brew tap PX4/px4 brew install px4-dev # Make sure you have Python 3 installed. brew install python3 # install required packages using pip3 pip3 install --user pyserial empy toml numpy pandas jinja2 pyyaml pyros-genmsg # Install SITL simulation with jMAVSim: brew tap AdoptOpenJDK/openjdk brew cask install adoptopenjdk8 brew install px4-sim-jmavsim
- Ubuntu Linux (18.04):
bash ./Tools/setup/ubuntu.sh --no-nuttx
- Run the simulator from the Firmware directory using the terminal:
HEADLESS=1 make px4_sitl jmavsim
You can use QGroundControl to connect the simulator and observe vehicle movement and behaviour while the examples are running. QGroundControl will automatically connect to the PX4 simulation as soon as it is started.
See QGroundControl > Download and Install for information about setting up QGroundControl on your platform.
The examples are stored as part of the projects source code. Get them using git in a terminal:
git clone https://github.com/mavlink/MAVSDK.git --recursive cd MAVSDK
Build the takeoff and land example:
cd example/takeoff_land/ mkdir build && cd build cmake .. make
First start PX4 in SITL (Simulation) and QGroundControl as described above.
Then run the example app (from the example/takeoff_land/build directory) as shown:
The MAVSDK application should connect to PX4, and you will be able to observe the example running in the SDK terminal, SITL terminal, and/or QGroundControl. The expected behaviour is shown here: Example: Takeoff and Land.
The first argument above is the connection string (
udp://:14540). This is the standard PX4 UDP port for connecting to offboard APIs.
Once MAVSDK is installed we recommend you: