Skip to main content

MAVSDK-Python

GitHub Actions Status

This is the Python wrapper for MAVSDK.

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).

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:

MAVSDK-Python 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 mavsdk-python, simply run:

pip3 install mavsdk

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 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mavsdk-3.17.2-py3-none-win_arm64.whl (14.3 MB view details)

Uploaded Python 3Windows ARM64

mavsdk-3.17.2-py3-none-win_amd64.whl (14.3 MB view details)

Uploaded Python 3Windows x86-64

mavsdk-3.17.2-py3-none-win32.whl (14.3 MB view details)

Uploaded Python 3Windows x86

mavsdk-3.17.2-py3-none-manylinux2014_aarch64.whl (18.2 MB view details)

Uploaded Python 3

mavsdk-3.17.2-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl (15.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

mavsdk-3.17.2-py3-none-macosx_14_0_arm64.whl (11.7 MB view details)

Uploaded Python 3macOS 14.0+ ARM64

mavsdk-3.17.2-py3-none-macosx_13_0_x86_64.whl (12.2 MB view details)

Uploaded Python 3macOS 13.0+ x86-64

mavsdk-3.17.2-py3-none-linux_armv7l.whl (16.6 MB view details)

Uploaded Python 3

mavsdk-3.17.2-py3-none-linux_armv6l.whl (16.6 MB view details)

Uploaded Python 3

File details

Details for the file mavsdk-3.17.2-py3-none-win_arm64.whl.

File metadata

  • Download URL: mavsdk-3.17.2-py3-none-win_arm64.whl
  • Upload date:
  • Size: 14.3 MB
  • Tags: Python 3, Windows ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for mavsdk-3.17.2-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 727b2047e326d64e698bfccb8ca77f7eaada0d4b4d562b57d7e7ac55fa579ac1
MD5 39890fb7ac5a98332b255292ae74da57
BLAKE2b-256 6b81209201c6e2420cc27c377b3bc6e38b7880af19ba8e93f15e082cd7554705

See more details on using hashes here.

File details

Details for the file mavsdk-3.17.2-py3-none-win_amd64.whl.

File metadata

  • Download URL: mavsdk-3.17.2-py3-none-win_amd64.whl
  • Upload date:
  • Size: 14.3 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for mavsdk-3.17.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 b613775dbf9324b542e29814f530a5e361cad0234304cb48fe56da4054642fc1
MD5 aa3e2487c28035629fee0d9bc17dec77
BLAKE2b-256 474e6bbd365a6119be77d93d7d61d7f3bb54faa8cc026ddc4471fe204b652e80

See more details on using hashes here.

File details

Details for the file mavsdk-3.17.2-py3-none-win32.whl.

File metadata

  • Download URL: mavsdk-3.17.2-py3-none-win32.whl
  • Upload date:
  • Size: 14.3 MB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for mavsdk-3.17.2-py3-none-win32.whl
Algorithm Hash digest
SHA256 a5bb3618b044820c679f62a4d2b5b1fd4029c2145f53fd3ed80a62bf6768e8e2
MD5 8bff9d663058199d81b7ced163dff0a1
BLAKE2b-256 fb3e843a6bba46b3d442b870c02186003c27c1f7cbe57d9abcf4df35f855f6ba

See more details on using hashes here.

File details

Details for the file mavsdk-3.17.2-py3-none-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mavsdk-3.17.2-py3-none-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 99e58f26705127986fa5e1358e3688aa4e4f8d006e719d2d39179d03368039f8
MD5 29ae227bc3bc1171f636b8295aacccb9
BLAKE2b-256 c0b32b177c2350bbc0785bc3a74f770cfc7cdc134128ad566a4f759631b4e549

See more details on using hashes here.

File details

Details for the file mavsdk-3.17.2-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for mavsdk-3.17.2-py3-none-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 78ac2402306022bb6000e1fa02dfe4af7a634c803d4ca90673b1c7918a23c937
MD5 824e720823d263a5294aac97b4a3663b
BLAKE2b-256 73b672dc4499cb7172665c1e0c3af0b18f5d0ca0160b810c1e05ea6668dd5488

See more details on using hashes here.

File details

Details for the file mavsdk-3.17.2-py3-none-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for mavsdk-3.17.2-py3-none-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 0247c9dcc0d4390b8734358ded178764efa4b83c304cb2f77162758b29cd6f57
MD5 9505e5baeac95af2abc398f343b182f9
BLAKE2b-256 1038da962106d56d68e9290390ec7e1fbfa6d6914580c11673a89d0a8406241d

See more details on using hashes here.

File details

Details for the file mavsdk-3.17.2-py3-none-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for mavsdk-3.17.2-py3-none-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 24c40b9f9fa0ce5cea4c05d300cafbb21dfc1483da7518de77c15356112f2c97
MD5 2db5ce7051bc78a23a77a58549b9cfb5
BLAKE2b-256 9c912005f11804d277a4b599e97bef9c5021c949079ac2c992e5d4f44e304e3f

See more details on using hashes here.

File details

Details for the file mavsdk-3.17.2-py3-none-linux_armv7l.whl.

File metadata

File hashes

Hashes for mavsdk-3.17.2-py3-none-linux_armv7l.whl
Algorithm Hash digest
SHA256 1aa441c7c290c4e1df5cb43376aa776194ea80004ef156826dd60c5d8b13f2c0
MD5 f2a5411d074e93c079c1d7dfb7d50d89
BLAKE2b-256 459e567b2957c1d12e15edf0837fbfcdbd43f139ca32490d848a095bbc55c3f3

See more details on using hashes here.

File details

Details for the file mavsdk-3.17.2-py3-none-linux_armv6l.whl.

File metadata

File hashes

Hashes for mavsdk-3.17.2-py3-none-linux_armv6l.whl
Algorithm Hash digest
SHA256 90ac3826e37dd70f5fdeea4c2d60b3681c22a54e78162d87955313f3deb77083
MD5 27e36ab527f87b62c3ece80d47cdf913
BLAKE2b-256 3842bf38eb788ed238dbfe0b54e2a3c8c6e73ca227bf48abf61171c6cf06162f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

3.17.2 This release

9 files

3.15.3

9 files

3.15.1

5 files

3.15.0

5 files

3.10.2

9 files

3.10.1

9 files

3.10.0

9 files

3.9.0

9 files

3.8.0

9 files

3.6.0

8 files

3.5.0

8 files

3.0.1

8 files

3.0.0

8 files

2.8.4

8 files

2.8.3

8 files

2.8.2

8 files

2.8.1

8 files

2.8.0

8 files

2.7.0

8 files

2.6.2

7 files

2.6.1

7 files

2.6.0

7 files

2.5.1

7 files

2.5.0

7 files

2.4.1

7 files

2.4.0

7 files

2.3.0

7 files

2.2.0

7 files

2.1.0

7 files

2.0.1

7 files

2.0.0

3 files

1.4.9

7 files

1.4.8

7 files

1.4.7

7 files

1.4.6

7 files

1.4.5

7 files

1.4.4

7 files

1.4.3

7 files

1.4.2

7 files

1.4.1

7 files

1.4.0

7 files

1.3.0

7 files

1.2.0

7 files

1.0.0

7 files

0.23.0

7 files

0.22.3

6 files

0.22.2

4 files

0.22.1

7 files

0.22.0

7 files

0.21.0

7 files

0.20.0

7 files

0.19.0

7 files

0.18.0

7 files

0.17.0

8 files

0.16.1

8 files

0.16.0

8 files

0.15.0

8 files

0.14.0

8 files

0.13.4

8 files

0.13.3

5 files

0.13.2

1 file

0.12.0

5 files

0.11.0

5 files

0.10.0

5 files

0.9.1

5 files

0.9.0

5 files

0.8.2

5 files

0.8.1

5 files

0.8.0

5 files

0.7.0

5 files

0.6.1

4 files

0.6.0

2 files

0.5.4

4 files

0.5.3

4 files

0.5.2

3 files

0.5.1

3 files

0.5.0

0.4.0

4 files

0.3.0

2 files

0.2.0

2 files

0.1.0

3 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page