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 3.17.4

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 3.17.4
File
mavsdk_grpc-3.17.4-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details
mavsdk_grpc-3.17.4-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
mavsdk_grpc-3.17.4-py3-none-win32.whl Python 3 none Windows x86-32 Details
mavsdk_grpc-3.17.4-py3-none-manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
mavsdk_grpc-3.17.4-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
mavsdk_grpc-3.17.4-py3-none-macosx_14_0_arm64.whl Python 3 none macOS 14.0+ ARM64 Details
mavsdk_grpc-3.17.4-py3-none-macosx_13_0_x86_64.whl Python 3 none macOS 13.0+ x86-64 Details
mavsdk_grpc-3.17.4-py3-none-linux_armv7l.whl Python 3 none linux armv7l Details
mavsdk_grpc-3.17.4-py3-none-linux_armv6l.whl Python 3 none linux armv6l Details

Total release size: 131.4 MB

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

Download URL mavsdk_grpc-3.17.4-py3-none-win_arm64.whl
Size 14.3 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
b61660f91352c55370b8fe9699fb5858f98b61e26c01d9eae30fd91ac95c7324
BLAKE2b-256 checksum
How to use checksums
e66263e7780ee28d3ffc2f66c08abc06bd872c06b557137c67033cf98649e572
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-3.17.4-py3-none-win_amd64.whl

Download URL mavsdk_grpc-3.17.4-py3-none-win_amd64.whl
Size 14.3 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
af059f030177aa3622a1c145f1298a21eabef36ebc31b6c268ab04fb6f1b415a
BLAKE2b-256 checksum
How to use checksums
f0ea375aea00d862664dc24f43b70581e3372373c32c90d9f8dfaf71960c4215
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-3.17.4-py3-none-win32.whl

Download URL mavsdk_grpc-3.17.4-py3-none-win32.whl
Size 12.1 MB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
105fbdee95efc7bf377a06dc9f4649ed423e6eade3a7ad0e200197158017527d
BLAKE2b-256 checksum
How to use checksums
c36e07d40f3e31deebd9007b0a7d89f56570ac1c66e3051722989544a05e83c9
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-3.17.4-py3-none-manylinux2014_aarch64.whl

Download URL mavsdk_grpc-3.17.4-py3-none-manylinux2014_aarch64.whl
Size 18.2 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
56e68d41df730f801a7651402450ffb9372dc54cc1567d082b62ce0af13eddd0
BLAKE2b-256 checksum
How to use checksums
216fe1c49d6a38fc24a6ed0872f47990c70befc8120d059dbf7464109d977739
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-3.17.4-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl

Download URL mavsdk_grpc-3.17.4-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl
Size 15.2 MB
Tags Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 Python 3
SHA-256 checksum
How to use checksums
7e6f6ef37ae8999abc5321890269f8aba5f1145dd3492143ad2b9ae2804c478b
BLAKE2b-256 checksum
How to use checksums
c312e23f51a1d01a95aae913c78e79ee03b517bfb264e2ff6a7aef4cb0d16cb4
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-3.17.4-py3-none-macosx_14_0_arm64.whl

Download URL mavsdk_grpc-3.17.4-py3-none-macosx_14_0_arm64.whl
Size 11.7 MB
Tags Python 3 macOS 14.0+ ARM64
SHA-256 checksum
How to use checksums
c36a5f1ca7239d1194c36f460b3fe520138de47e805410238184d4e5759ac14e
BLAKE2b-256 checksum
How to use checksums
bcfd4c5a245e1d714c6461e457b767f3ff20d4b88868793fa4a9984da2324b29
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-3.17.4-py3-none-macosx_13_0_x86_64.whl

Download URL mavsdk_grpc-3.17.4-py3-none-macosx_13_0_x86_64.whl
Size 12.2 MB
Tags Python 3 macOS 13.0+ x86-64
SHA-256 checksum
How to use checksums
f7b3d4a94122506ebc6ded40efe0764e1fab4fb53a6fa0ad8787e15114a151ad
BLAKE2b-256 checksum
How to use checksums
4386060dfb67ef1062080f7abd20d75377710e34be60494fb690104520c14963
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-3.17.4-py3-none-linux_armv7l.whl

Download URL mavsdk_grpc-3.17.4-py3-none-linux_armv7l.whl
Size 16.6 MB
Tags Python 3 linux armv7l
SHA-256 checksum
How to use checksums
35a46494e3f0e67efe4f44210ab16dbe7b42824c074644a2847ae43b76b82b97
BLAKE2b-256 checksum
How to use checksums
44aa903ce1e29d4d5f687ba9aed5a37f1245d44b3d6ebec2433e3464f9e8c9eb
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-3.17.4-py3-none-linux_armv6l.whl

Download URL mavsdk_grpc-3.17.4-py3-none-linux_armv6l.whl
Size 16.6 MB
Tags Python 3 linux armv6l
SHA-256 checksum
How to use checksums
f95cce3e46dc6e5b7a6f9a70fa6dbbf3219f7455c9e845b705cae4000a19f0a1
BLAKE2b-256 checksum
How to use checksums
550067a72d9531d221b689a1b0cca750fe42efc8d74043c2d7a61072e64c148f
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 3.17.4

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

3.17.4 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