Documentation/F410 WikiEnglish · V6C
Browse documentation
Additional documentation

Download from:

Cross platform: Linux, macOS, Windows, Android, and iOS.

6 min read · English documentation

MAVSDK Introduction

MAVSDK is a collection of libraries in various programming languages for interacting with MAVLink systems such as drones, cameras, or ground control stations.
These libraries provide a simple API for managing one or multiple vehicles, offering programmatic access to vehicle information and telemetry, as well as control over missions, movement, and other operations.
The libraries can be used on companion computers onboard drones, or on ground stations and mobile devices.

MAVSDK Features

Cross-platform: Linux, macOS, Windows, Android, and iOS.

Multi-language: C++, Swift, Python, Java, Go, JavaScript, C#, Rust.

When in use, connections can be established via serial port, TCP, or UDP to control Pixhawk flight controllers. Prior to this, users can set up Pixhawk source code in Ubuntu and create simulators, then control simulated aircraft through MAVSDK.

About Our Maintained MAVSDK

Currently provided demos include:

Automatic takeoff and landing demo

Waypoint flight demo

Click-and-fly demo

We also provide an Ubuntu simulation development virtual machine to facilitate algorithm development, enabling developers to quickly start drone development. For better distinction, we call this PC-SDK. Android version SDK will be released subsequently.

Note

Beginners without understanding of drones or control coordinate systems should not run other demos. It is recommended that novices first run our simulation system after understanding drone control coordinate systems, familiarize themselves with drone operational characteristics, before attempting more complex demos.

Basic Concepts of Drone Control Coordinate Systems (Introduction)

Understanding NED Coordinates in Drones

Body Coordinate System: Fixed to the aircraft body, with origin at the center of gravity of the multirotor. The x-axis points toward the nose within the multirotor's symmetry plane (nose direction relates to + or X configuration). The z-axis lies in the aircraft symmetry plane, pointing vertically downward. The y-axis is determined by the right-hand rule.

Earth-Fixed Coordinate System: Typically uses the multirotor's takeoff position as origin. First align the x-axis horizontally in a specific direction, with z-axis perpendicular downward. Then determine y-axis using right-hand rule. For example, the NED coordinate system has x-axis pointing true North, y-axis East, and z-axis downward.

Aircraft Euler angles are based on conversions between these two coordinate systems: pitch+ for nose up, roll+ for right rotation, yaw+ for right yaw.

Relationship Between Yaw and Compass Heading

Compass headings are fixed: North=0°, East=90°, South=180°, West=270°.
Yaw angle is the current nose direction relative to true North (if using NED earth-fixed system).
For example, if vision system sends yaw=90° to flight controller via MAVROS using NED system, the nose points East.

If yaw=90° with nose pointing North, this indicates the earth-fixed system uses WND (West-North-Down).

PX4 uses NED earth-fixed coordinates where x,y,z directions remain fixed (except in Offboard mode where initial orientation after power-up is determined by yaw).

This example uses the END coordinate system with the power-up position as the origin (coordinates 0.0.0), based on the WGS84 system:

  • E (East) as Y-axis
  • N (North) as X-axis
  • D (Down) as Z-axis
    All positive values correspond to respective directions. Height (Z-axis) processing is inverted in this example.

QGroundControl's attitude sphere (top-right) displays coordinate (nose direction), heading (degrees), and attitude information.

ENU vs NED Difference

As shown:

Quick Start (Verified on Windows 11)

Aim to quickly verify drone communication and development environment

Note

Recommended for users with basic experience. Otherwise follow simulation steps.

Conduct tests in open outdoor areas, maintaining >10m distance from drone.

(For users familiar with drone operation, Ubuntu, or Python) Simulation is recommended for initial learning.

Prerequisites:
Python 3.7+, pip, QGC, mrvsdk_server, VSCode, git

Install MAVSDK via pip:

pip3 install mavsdk

Clone demo repository after installing git:

git clone https://gitee.com/amovlab1/mavsdk

Download MAVLink communication node mrvsdk_server:

https://github.com/mavlink/mavsdk/releases

For F410 base model:

  1. Connect ground station Ethernet to computer
  2. Set computer IP to 192.168.1.123
  3. Launch QGroundControl
  4. Double-click mrvsdk_server to establish communication node
  5. Refer to Data Link Configuration in Extended Help section

Successful connection:

In VSCode:

  1. Open takeoff-and-land.py
  2. Uncomment specified code (see comments)
  3. Run:
python ./takeoff-and-land.py

This executes takeoff/land commands. Remote controller can intervene during process.

Demo video:

Simulation Environment Setup

Two installation methods provided:

Choose either environment installation or image installation (recommended)

Image Installation

Download simulation image:

https://download.amovlab.com/F410/pixhawk%206c/Ubuntu/

After download:

  • Install via virtual machine/dual-boot/hardware
  • Image contains all required software
  • Refer to the AMOVLAB WeChat Official Account for tutorials

Environment Installation

  1. Install Ubuntu 20.04
  2. Create project directory and clone PX4-Autopilot:
mkdir px4_project
cd px4_project
git clone http://github.com/PX4/PX4-Autopilot
  1. Update submodules:
cd PX4-Autopilot/
git submodule update --init --recursive
  1. Run installation script:
cd ~
bash ./PX4-Autopilot/Tools/setup/ubuntu.sh
  1. System update:
sudo apt-get update
sudo apt-get upgrade
  1. Compile simulation:
cd PX4-Autopilot/
make px4_sitl jmavsim
  1. Install QGroundControl:
# Download from:
https://download.amovlab.com/F410/pixhawk%206c/UBUNTU20.04%E5%9C%B0%E9%9D%A2%E7%AB%99/
# Or official site:
https://docs.qgroundcontrol.com/master/en/getting_started/download_and_install.html

# Install dependencies:
sudo usermod -a -G dialout $USER
sudo apt-get remove modemmanager -y
sudo apt install gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-gl -y
sudo apt install libqt5gui5 -y
sudo apt install libfuse2 -y

# Run:
chmod +x ./QGroundControl.AppImage
./QGroundControl.AppImage
  1. Install MAVSDK:
pip3 install mavsdk
  1. Install VSCode:
https://code.visualstudio.com/Download
  1. Clone demos:
git clone https://gitee.com/amovlab1/mavsdk

Demo Introduction

Note

Real drone operation requires confirming remote control switch functions and failsafe mechanisms. First practice in simulation before real tests.

Demo1: takeoff-and-land.py

Automatic takeoff and landing:

  • Takeoff → 10s hover → landing
  • Displays GPS data and battery status
    Simulation result:

Demo2: miss.py

Waypoint mission:

  • Input parameters in END system (X,Y,Z, speed, hover time, heading)
  • Supports mission clearing
  • Remote control intervention allowed
    Simulation result:

Demo3: offboard-position.py

Offboard mode control:

  • Position control in END system (X,Y,Z,heading)
  • Contains commented velocity/attitude controls (dangerous for real drones)
  • Remote control intervention NOT allowed
    Simulation result:

Warning

Contains velocity control in body frame and attitude control. These modes are dangerous and commented out by default. Use position control only except in simulation.

Warning

The remote controller cannot intervene at any time while the aircraft is in Offboard mode.

Communication Setup

Note

Use two telemetry links: QGC and MAVSDK each with separate links for better monitoring.

F410V6C Configuration:

  1. Add miniHomer Sky module to existing setup
  2. Set miniHomer port to 14540 (refer to miniHomer manual)
    https://docs.amovlab.com/minihomer-wiki/#/src/MINIHOMER/%E8%BF%9E%E6%8E%A5%E9%85%8D%E7%BD%AE%E8%AF%B4%E6%98%8E
  3. Connect to flight controller's TELEM3 port
  4. Enable MAV_2_CONFIG parameter (set to telem3)

Default Windows Settings:

  • MAVSDK: UDP 14540
  • QGC: UDP 8080

MAVSDK Connection

mrvsdk_server bridges flight controller and computer:

https://github.com/mavlink/mavsdk/releases
  • Green messages indicate normal operation
  • Red messages indicate errors

Warning

If an emergency occurs, terminate the `mrvsdk_server` connection by pressing `Ctrl+C`.

QGC Connection

Select:
Connection Type → UDP → Port 8080 → Connect

Clone MAVSDK source:

https://github.com/mavlink/MAVSDK

Real Drone Operation

Note

Verify remote control failsafe functions and position hold mode before testing.

Procedure:

  1. Run mrvsdk_server and check MAVLink messages
  2. Confirm Position Hold mode in QGC
  3. Perform manual takeoff/landing test
  4. Verify emergency stop function
  5. Execute MAVSDK demo

Install requirements:

pip3 install mavsdk
git clone https://gitee.com/amovlab1/mavsdk

Install Visual Studio Code from the official download page or the application store:
https://code.visualstudio.com/Download

Demo video:

Safety Note:
Some demos send ARM commands for testing. Maintain safe distance during tests.

Note

Real-drone and simulation operations are the same. For real-drone tests, verify the function of every remote-controller switch, ensure that the aircraft is in Position mode, and confirm that an emergency motor-stop function is available to prevent accidents.

Common API Interfaces