Skip to main content

MAVSDK-Python

GitHub Actions Status

This is the gRPC-based Python wrapper for MAVSDK, published on PyPI as mavsdk-grpc and imported as mavsdk_grpc.

The Python wrapper is based on a gRPC client communicating with the gRPC server written in C++. To use the Python wrapper the gRPC server called "backend" needs to be running on the same system. The wrapper is essentially auto-generated from the message definitions (proto files).

⚠️ Renamed from mavsdk to mavsdk-grpc

This wrapper used to be published as mavsdk. That name on PyPI now refers to the native MAVSDK binding, which has a different API and no gRPC dependency — see the migration guide.

This project carries on under the mavsdk-grpc name, including releases tracking MAVSDK v4. If you were using mavsdk:

  • Install mavsdk-grpc and use import mavsdk_grpc as mavsdk — the code is identical. The separate import name is deliberate, so that the two packages can never overwrite each other's files.
  • Or pin mavsdk<4 to freeze on the last release under the old name, which will not receive further updates.

Important Notes

  • Python 3.7+ is required (because the wrapper is based on asyncio).
  • You may need to run pip3 instead of pip and python3 instead of python, depending of your system defaults.
  • Auterion used to have a Getting started with MAVSDK-Python (web.archive.org) guide if you're a beginner and not sure where to start.

API Reference docs

-> API Reference documentation.

Install using pip from PyPi

Note for Raspberry Pi 1/2 and Zero:

This wrapper requires grpcio. However, there are no binary packets of grpcio for armv6 available via pip (also see files on pypi.org). In this case, install grpcio via the package manager, e.g. sudo apt-get install python3-grpcio.

To install it, simply run:

pip3 install mavsdk-grpc

The package contains mavsdk_server already (previously called "backend"), which is started automatically when connecting (e.g. await drone.connect()). Have a look at the examples to see it used in practice. It will be something like:

from mavsdk_grpc import System

...

drone = System()
await drone.connect(system_address="udpin://0.0.0.0:14540")

Note: System() takes two named parameters: mavsdk_server_address and port. When left empty, they default to None and 50051, respectively, and mavsdk_server -p 50051 is run by await drone.connect(). If mavsdk_server_address is set (e.g. to "localhost"), then await drone.connect() will not start the embedded mavsdk_server and will try to connect to a server running at this address. This is useful for platforms where mavsdk_server does not come embedded, for debugging purposes, and for running mavsdk_server in a place different than where the MAVSDK-Python script is run.

Run the examples

Once the package has been installed, the examples can be run:

examples/takeoff_and_land.py

The examples assume that the embedded mavsdk_server binary can be run. In some cases (e.g. on Raspberry Pi), it may be necessary to run mavsdk_server manually, and therefore to set mavsdk_server_address='localhost' as described above.

Contribute

Note: this is more involved and targeted at contributors.

Most of the code is auto-generated from the proto definitions, using our templates. The generated files can be found in the generated folder. As a result, contributions are generally made in the templates or on the build system. Regularly, there is a need to update MAVSDK-Python to include the latest features defined in the proto definitions. This is described below.

Clone the repo

Clone this repo and recursively update submodules:

git clone https://github.com/mavlink/MAVSDK-Python --recursive
cd MAVSDK-Python

Install prerequisites

First install the protoc plugin (protoc-gen-mavsdk):

cd proto/pb_plugins
pip3 install -r requirements.txt

You can check that the plugin was installed with $ which protoc-gen-mavsdk, as it should now be in the PATH.

Then go back to the root of the repo and install the dependencies of the SDK:

cd ../..
pip3 install -r requirements.txt -r requirements-dev.txt

Generate the code

Run the following helper script. It will generate the Python wrappers for each plugin.

./other/tools/run_protoc.sh

Adding support for new plugins

In case you updated the ./proto submodule to include a new plugin, you will also have to manually edit the file mavsdk/system.py to register the plugin.

Update mavsdk_server version

MAVSDK_SERVER_VERSION contains exactly the tag name of the mavsdk_server release corresponding to the version of MAVSDK-Python. When the proto submodule is updated here, chances are that mavsdk_server should be updated, too. Just edit this file, and the corresponding binary will be downloaded by the setup.py script (see below).

Build and install the package locally

After generating the wrapper and only in ARM architectures with linux, defines a variable MAVSDK_SERVER_ARCH:

export MAVSDK_SERVER_ARCH=<ARM embedded architecture>

Supported architectures: armv6l, armv7l and aarch64. For example for Raspberry Pi it is armv7l, or aarch64 (if a 64 bit distribution is used).

Then you can install a development version of the package, which links the package to the generated code in this local directory. To do so, use:

python3 setup.py build
pip3 install -e .

Note: MAVDSK-Python runs mavsdk/bin/mavsdk_server when await drone.connect() is called. This binary comes from MAVSDK and is downloaded during the setup.py step above.

Generate the API documentation

Make sure the version tag is set correctly before generating new documentation.

pip3 install -r requirements-docs.txt
make -C mavsdk html

Formatting checks before committing

We use the following checks in CI:

pipx run ruff format --check --line-length=100 examples
pipx run ruff check --select=ASYNC,RUF006,E,F --line-length=100 examples
pipx run codespell .

Release steps

  1. Check the proto submodule is up-to-date and the generated code has been updated.
  2. Check all required pull requests are merged to main
  3. Check MAVSDK_SERVER_VERSION is set to the correct version of mavsdk_server.
  4. Create git tag on laster main, e.g.:
    git switch main
    git pull
    git tag X.Y.Z
    git push --tags
    
  5. Go to releases page and create new release. The CI will now:
    • Create and push a wheel for Windows, Linux and macOS to PyPi.
    • Generate the latest docs and push them to s3.

Metadata

Release files for mavsdk-grpc 4.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for mavsdk-grpc 4.0.5
File Actions
mavsdk_grpc-4.0.5-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details for mavsdk_grpc-4.0.5-py3-none-win_arm64.whl
mavsdk_grpc-4.0.5-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for mavsdk_grpc-4.0.5-py3-none-win_amd64.whl
mavsdk_grpc-4.0.5-py3-none-win32.whl Python 3 none Windows x86-32 Details for mavsdk_grpc-4.0.5-py3-none-win32.whl
mavsdk_grpc-4.0.5-py3-none-manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for mavsdk_grpc-4.0.5-py3-none-manylinux2014_aarch64.whl
mavsdk_grpc-4.0.5-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64, Linux glibc 2.5+ x86-64 Details for mavsdk_grpc-4.0.5-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl
mavsdk_grpc-4.0.5-py3-none-macosx_14_0_arm64.whl Python 3 none macOS 14.0+ ARM64 Details for mavsdk_grpc-4.0.5-py3-none-macosx_14_0_arm64.whl
mavsdk_grpc-4.0.5-py3-none-macosx_13_0_x86_64.whl Python 3 none macOS 13.0+ x86-64 Details for mavsdk_grpc-4.0.5-py3-none-macosx_13_0_x86_64.whl
mavsdk_grpc-4.0.5-py3-none-linux_armv7l.whl Python 3 none linux armv7l Details for mavsdk_grpc-4.0.5-py3-none-linux_armv7l.whl
mavsdk_grpc-4.0.5-py3-none-linux_armv6l.whl Python 3 none linux armv6l Details for mavsdk_grpc-4.0.5-py3-none-linux_armv6l.whl

Total release size: 139.4 MB

Release files / mavsdk_grpc-4.0.5-py3-none-win_arm64.whl

Download URL mavsdk_grpc-4.0.5-py3-none-win_arm64.whl
Size 15.7 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
d7ce4488af812db0dab91ca75450b826bc5fc1e474a1e0a7727d66fae18b1071
BLAKE2b-256 checksum
How to use checksums
ef652aee6c49e545eb1c62642f7582cf5fb3fd28b2cca93ed5b2e74af04d257a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / mavsdk_grpc-4.0.5-py3-none-win_amd64.whl

Download URL mavsdk_grpc-4.0.5-py3-none-win_amd64.whl
Size 15.6 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
fdd514f8b881758c6b673fe2c5414659240824868cb4ea8272cf11851319e171
BLAKE2b-256 checksum
How to use checksums
d4f23db065c4bbea2ae0f2153222f36c0e99199c96d9c43f41ccf0bfe83fe9aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / mavsdk_grpc-4.0.5-py3-none-win32.whl

Download URL mavsdk_grpc-4.0.5-py3-none-win32.whl
Size 13.2 MB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
e01121ad3df06c364b4114f6f9cea05b14273a709f4215b3fff8a0ee596eca1a
BLAKE2b-256 checksum
How to use checksums
f457e93429c9b447835f6118b0a4b6b0c9e1cdeeb2af2463a44fc8cb98f4ee09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / mavsdk_grpc-4.0.5-py3-none-manylinux2014_aarch64.whl

Download URL mavsdk_grpc-4.0.5-py3-none-manylinux2014_aarch64.whl
Size 19.0 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
a22e8ed646e1ecc759a215e377d1cab92eb0dbdf361973f0427aea0ebad66d1a
BLAKE2b-256 checksum
How to use checksums
608876d8ed4fbcbcc2167747beebdc7fd51df1d708b268a8afb0afe25dd278e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / mavsdk_grpc-4.0.5-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl

Download URL mavsdk_grpc-4.0.5-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl
Size 15.9 MB
Tags Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 Python 3
SHA-256 checksum
How to use checksums
7031721fbec570c33ee3a82ce623747630cdfce49bdac440ddc4e20158d8de2e
BLAKE2b-256 checksum
How to use checksums
5e12451e69723e31141686adb206ccdc8eb1c4accbd0e1371ee5f1819be28add
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / mavsdk_grpc-4.0.5-py3-none-macosx_14_0_arm64.whl

Download URL mavsdk_grpc-4.0.5-py3-none-macosx_14_0_arm64.whl
Size 12.3 MB
Tags Python 3 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
72ac22e67f2de22a374419a60a76d8048da39f0e30d3db454c2006faa9132222
BLAKE2b-256 checksum
How to use checksums
05dcd9b0763ab54545fc241d55c5d22fa2f089fd2d9ac0ee1b0cac629ec13f3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / mavsdk_grpc-4.0.5-py3-none-macosx_13_0_x86_64.whl

Download URL mavsdk_grpc-4.0.5-py3-none-macosx_13_0_x86_64.whl
Size 12.9 MB
Tags Python 3 macOS 13.0+ x86-64
SHA-256 checksum
How to use checksums
847e213731d7f66dd86f35a7e5241c80b632bab12c372e5954726c4bd7197fee
BLAKE2b-256 checksum
How to use checksums
856b87bf1e0518436cb20dfd4aa7c12e4fefca1e3b563acbad8a3b756a4cb075
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / mavsdk_grpc-4.0.5-py3-none-linux_armv7l.whl

Download URL mavsdk_grpc-4.0.5-py3-none-linux_armv7l.whl
Size 17.3 MB
Tags Python 3 linux armv7l
SHA-256 checksum
How to use checksums
49e3ad2a137f5ffc5dbbabf52eacf99e23403f5e922bd51109d7f4e6ebeb83b3
BLAKE2b-256 checksum
How to use checksums
1ccc1e5be5d84c66336fddd6ba198eb1606d686b4917df7e18fb2dd8ee6afcbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / mavsdk_grpc-4.0.5-py3-none-linux_armv6l.whl

Download URL mavsdk_grpc-4.0.5-py3-none-linux_armv6l.whl
Size 17.3 MB
Tags Python 3 linux armv6l
SHA-256 checksum
How to use checksums
199c71d8c0bed2a3abb4f881a725dbff3c2afdc9bfb2d7d13c6b784469ec9d87
BLAKE2b-256 checksum
How to use checksums
e09048afb90d17a3c0d9ba15885ec9baa94ef302491bfc45a7cf711e51bff316
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for mavsdk-grpc 4.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

4.0.5 This release

9 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page