Package: mavsdk
MAVSDK-PythonThis 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 NotesPython 3.7+ is required (because the wrapper is based onasyncio).You may need to runpip3instead ofpipandpython3instead ofpython, depending of your system defaults.Auterion has aGetting started with MAVSDK-Pythonguide if you're a beginner and not sure where to start.API Reference docs->API Reference documentation.Install using pip from PyPiTo install mavsdk-python, simply run:pip3installmavsdkThe package containsmavsdk_serveralready (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:frommavsdkimportSystem...drone=System()awaitdrone.connect(system_address="udp://:14540")Note:System()takes two named parameters:mavsdk_server_addressandport. When left empty, they default toNoneand50051, respectively, andmavsdk_server -p 50051is run byawait drone.connect(). Ifmavsdk_server_addressis set (e.g. to "localhost"), thenawait drone.connect()will not start the embeddedmavsdk_serverand will try to connect to a server running at this address. This is useful for platforms wheremavsdk_serverdoes not come embedded, for debugging purposes, and for runningmavsdk_serverin a place different than where the MAVSDK-Python script is run.Run the examplesOnce the package has been installed, the examples can be run:examples/takeoff_and_land.pyThe examples assume that the embeddedmavsdk_serverbinary can be run. In some cases (e.g. on Raspberry Pi), it may be necessary to runmavsdk_servermanually, and therefore to setmavsdk_server_address='localhost'as described above.ContributeNote: this is more involved and targeted at contributors.Most of the code is auto-generated from theproto definitions, using ourtemplates. The generated files can be found in thegeneratedfolder. 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 describedbelow.Clone the repoClone this repo and recursively update submodules:git clone https://github.com/mavlink/MAVSDK-Python --recursive
cd MAVSDK-PythonInstall prerequisitesFirst install the protoc plugin (protoc-gen-mavsdk):cd proto/pb_plugins
pip3 install -r requirements.txtYou 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.txtGenerate the codeRun the following helper script. It will generate the Python wrappers for each plugin../other/tools/run_protoc.shUpdatemavsdk_serverversionMAVSDK_SERVER_VERSIONcontains exactly the tag name of themavsdk_serverrelease corresponding to the version of MAVSDK-Python. When theprotosubmodule is updated here, chances are thatmavsdk_servershould be updated, too. Just edit this file, and the corresponding binary will be downloaded by thesetup.pyscript (see below).Build and install the package locallyAfter generating the wrapper and only in ARM architectures with linux, defines a variableMAVSDK_SERVER_ARCH:export MAVSDK_SERVER_ARCH=<ARM embedded architecture>Supported architectures:armv6l,armv7landaarch64. For example for Raspberry Pi it isarmv7l, oraarch64(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 runsmavsdk/bin/mavsdk_serverwhenawait drone.connect()is called. This binary comes fromMAVSDKand is downloaded during thesetup.pystep above.Generate the API documentationMake sure the version tag is set correctly before generating new documentation.pip3 install -r requirements-docs.txt
make -C mavsdk htmlRelease stepsCheck the proto submodule is up-to-date and the generated code has been updated.Check all required pull requests are merged to mainCheckMAVSDK_SERVER_VERSIONis set to the correct version of mavsdk_server.Create git tag on laster main, e.g.:git switch main
git pull
git tag X.Y.Z
git push --tagsGo toreleases pageand 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.