Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
name: Check and PyPi Upload

# Tagged builds publish this project under two names: "mavsdk-grpc" (the
# going-forward name) and "mavsdk" (the legacy name, one last time, carrying a
# rename warning). See setup.py for how the two builds differ.
#
# NOTE: the token in TWINE_PASSWORD must be account-scoped for the release that
# first creates "mavsdk-grpc" on PyPI -- a project-scoped token cannot create a
# new project. It can be swapped back to project-scoped tokens afterwards.

on:
push:
branches:
Expand Down Expand Up @@ -35,9 +43,13 @@ jobs:
python3 -m pip install -r requirements.txt -r requirements-dev.txt -r requirements-docs.txt
python3 -m pip install "setuptools<77" auditwheel twine

# Built twice: once as "mavsdk-grpc" (the going-forward name) and once as
# "mavsdk" (the legacy name, carrying a rename warning). See setup.py.
- name: Create wheel
run: |
python3 setup.py bdist_wheel
MAVSDK_DIST_NAME=mavsdk-grpc python3 setup.py bdist_wheel
rm -rf build mavsdk.egg-info
MAVSDK_DIST_NAME=mavsdk python3 setup.py bdist_wheel
mkdir wheelhouse
export PATH=$PATH:$HOME/.local/bin
auditwheel repair --plat manylinux2014_x86_64 dist/*.whl
Expand All @@ -64,7 +76,7 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
run: |
export PATH=$PATH:$HOME/.local/bin
twine upload wheelhouse/*.whl
twine upload --skip-existing wheelhouse/*.whl

- name: Upload docs
env:
Expand Down Expand Up @@ -108,7 +120,9 @@ jobs:
- name: Create wheel
run: |
export MAVSDK_SERVER_ARCH=${{ matrix.arch }}
python3 setup.py bdist_wheel
MAVSDK_DIST_NAME=mavsdk-grpc python3 setup.py bdist_wheel
rm -rf build mavsdk.egg-info
MAVSDK_DIST_NAME=mavsdk python3 setup.py bdist_wheel
ls dist/*any.whl | sed -e 'p;s/any/${{ matrix.pypi_arch }}/' | xargs -n2 mv

- name: Check the artifacts
Expand All @@ -128,7 +142,7 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
run: |
export PATH=$PATH:$HOME/.local/bin
twine upload dist/*.whl
twine upload --skip-existing dist/*.whl

macOS:
name: macOS ${{ matrix.arch }}
Expand Down Expand Up @@ -161,7 +175,9 @@ jobs:

- name: Create wheel
run: |
python setup.py bdist_wheel
MAVSDK_DIST_NAME=mavsdk-grpc python setup.py bdist_wheel
rm -rf build mavsdk.egg-info
MAVSDK_DIST_NAME=mavsdk python setup.py bdist_wheel
export PATH="$(python -m site --user-base)/bin:$PATH"
delocate-wheel -w wheelhouse -v dist/*.whl
ls wheelhouse/*any.whl | sed -e 'p;s/any/macosx_${{ matrix.wheel_arch }}/' | xargs -n2 mv
Expand All @@ -183,7 +199,7 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
run: |
export PATH=$PATH:$HOME/.local/bin
twine upload wheelhouse/*.whl
twine upload --skip-existing wheelhouse/*.whl

Windows:
name: Windows (${{ matrix.arch }})
Expand Down Expand Up @@ -222,6 +238,10 @@ jobs:
- name: Create wheel
run: |
$env:MAVSDK_SERVER_ARCH = "${{ matrix.arch }}"
$env:MAVSDK_DIST_NAME = "mavsdk-grpc"
python3 setup.py bdist_wheel
Remove-Item -Recurse -Force build, mavsdk.egg-info -ErrorAction SilentlyContinue
$env:MAVSDK_DIST_NAME = "mavsdk"
python3 setup.py bdist_wheel
Dir "dist/" | rename-item -NewName {$_.name -replace '-any.whl','-${{ matrix.wheel_arch }}.whl'}

Expand All @@ -240,4 +260,4 @@ jobs:
TWINE_NON_INTERACTIVE: 1
if: startsWith(github.ref, 'refs/tags/')
run: |
twine upload dist/*.whl
twine upload --skip-existing dist/*.whl
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ build/
.tox/
mavsdk/bin/mavsdk_server
mavsdk/bin/mavsdk_server.exe
mavsdk/_dist.py
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,26 @@

[![GitHub Actions Status](https://github.com/mavlink/MAVSDK-Python/workflows/Check%20and%20PyPi%20Upload/badge.svg?branch=main)](https://github.com/mavlink/MAVSDK-Python/actions/workflows/main.yml?query=branch%3Amain)

This is the Python wrapper for MAVSDK.
This is the gRPC-based Python wrapper for MAVSDK, published on PyPI as
[`mavsdk-grpc`](https://pypi.org/project/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](https://github.com/mavlink/MAVSDK-Proto)).

> ### ⚠️ 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](https://mavsdk.mavlink.io/main/en/python/migration.html).
>
> 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

Expand All @@ -21,20 +37,20 @@ The Python wrapper is based on a gRPC client communicating with the gRPC server

**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](https://pypi.org/project/grpcio/#files)).
> This wrapper requires grpcio. However, there are no binary packets of grpcio for armv6 available via pip (also see [files on pypi.org](https://pypi.org/project/grpcio/#files)).
> In this case, install grpcio via the package manager, e.g. `sudo apt-get install python3-grpcio`.


To install mavsdk-python, simply run:
To install it, simply run:

```sh
pip3 install mavsdk
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:

```python
from mavsdk import System
from mavsdk_grpc import System

...

Expand Down
2 changes: 1 addition & 1 deletion examples/all_params.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

import asyncio
from mavsdk import System
from mavsdk_grpc import System


async def run():
Expand Down
2 changes: 1 addition & 1 deletion examples/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import asyncio
import logging
from mavsdk import System
from mavsdk_grpc import System

# Enable INFO level logging by default so that INFO messages are shown
logging.basicConfig(level=logging.INFO)
Expand Down
4 changes: 2 additions & 2 deletions examples/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import asyncio
import logging

from mavsdk.camera import CameraError, Mode
from mavsdk import System
from mavsdk_grpc.camera import CameraError, Mode
from mavsdk_grpc import System

# Enable INFO level logging by default so that INFO messages are shown
logging.basicConfig(level=logging.INFO)
Expand Down
4 changes: 2 additions & 2 deletions examples/camera_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import asyncio

from aioconsole import ainput
from mavsdk import System
from mavsdk.camera import CameraError, Mode, Option, Setting
from mavsdk_grpc import System
from mavsdk_grpc.camera import CameraError, Mode, Option, Setting


usage_str = """
Expand Down
4 changes: 2 additions & 2 deletions examples/do_orbit.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python3

import asyncio
from mavsdk import System
from mavsdk.action import OrbitYawBehavior
from mavsdk_grpc import System
from mavsdk_grpc.action import OrbitYawBehavior


async def run():
Expand Down
4 changes: 2 additions & 2 deletions examples/failure_injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import asyncio

from mavsdk import System
from mavsdk.failure import FailureType, FailureUnit
from mavsdk_grpc import System
from mavsdk_grpc.failure import FailureType, FailureUnit


async def run():
Expand Down
2 changes: 1 addition & 1 deletion examples/firmware_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import asyncio
import logging
from mavsdk import System
from mavsdk_grpc import System

# Enable INFO level logging by default so that INFO messages are shown
logging.basicConfig(level=logging.INFO)
Expand Down
4 changes: 2 additions & 2 deletions examples/follow_me_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# This example shows how to use the follow me plugin

import asyncio
from mavsdk import System
from mavsdk.follow_me import Config, TargetLocation
from mavsdk_grpc import System
from mavsdk_grpc.follow_me import Config, TargetLocation


follow_height = 8.0 # in meters
Expand Down
2 changes: 1 addition & 1 deletion examples/ftp_download_file.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

import asyncio
from mavsdk import System
from mavsdk_grpc import System


async def run():
Expand Down
2 changes: 1 addition & 1 deletion examples/ftp_list_dir.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

import asyncio
from mavsdk import System
from mavsdk_grpc import System


async def run():
Expand Down
4 changes: 2 additions & 2 deletions examples/geofence.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python3

import asyncio
from mavsdk import System
from mavsdk.geofence import Point, Polygon, FenceType, GeofenceData, Circle
from mavsdk_grpc import System
from mavsdk_grpc.geofence import Point, Polygon, FenceType, GeofenceData, Circle

"""
This example shows how to use the geofence plugin.
Expand Down
4 changes: 2 additions & 2 deletions examples/gimbal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import asyncio
import logging
from mavsdk import System
from mavsdk.gimbal import GimbalMode, ControlMode, SendMode
from mavsdk_grpc import System
from mavsdk_grpc.gimbal import GimbalMode, ControlMode, SendMode

# Enable INFO level logging by default so that INFO messages are shown
logging.basicConfig(level=logging.INFO)
Expand Down
2 changes: 1 addition & 1 deletion examples/goto.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import asyncio
import logging
from mavsdk import System
from mavsdk_grpc import System

# Enable INFO level logging by default so that INFO messages are shown
logging.basicConfig(level=logging.INFO)
Expand Down
2 changes: 1 addition & 1 deletion examples/gripper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

import asyncio
from mavsdk import System
from mavsdk_grpc import System


async def run():
Expand Down
2 changes: 1 addition & 1 deletion examples/highres_imu.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

import asyncio
from mavsdk import System
from mavsdk_grpc import System


async def get_imu_data():
Expand Down
2 changes: 1 addition & 1 deletion examples/logfile_download.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

import asyncio
from mavsdk import System
from mavsdk_grpc import System
import sys


Expand Down
2 changes: 1 addition & 1 deletion examples/manual_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import asyncio
import random
from mavsdk import System
from mavsdk_grpc import System

# Test set of manual inputs. Format: [roll, pitch, throttle, yaw]
manual_inputs = [
Expand Down
2 changes: 1 addition & 1 deletion examples/mavlink_direct_receive.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

import asyncio
from mavsdk import System
from mavsdk_grpc import System
import json


Expand Down
2 changes: 1 addition & 1 deletion examples/mavlink_direct_send.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

import asyncio
from mavsdk import System, mavlink_direct
from mavsdk_grpc import System, mavlink_direct
import json
import random

Expand Down
4 changes: 2 additions & 2 deletions examples/mission.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import asyncio
import logging

from mavsdk import System
from mavsdk.mission import MissionItem, MissionPlan
from mavsdk_grpc import System
from mavsdk_grpc.mission import MissionItem, MissionPlan

# Enable INFO level logging by default so that INFO messages are shown
logging.basicConfig(level=logging.INFO)
Expand Down
2 changes: 1 addition & 1 deletion examples/mission_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import asyncio

from mavsdk import System
from mavsdk_grpc import System


async def run():
Expand Down
4 changes: 2 additions & 2 deletions examples/mission_raw.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python3

import asyncio
from mavsdk import System
from mavsdk import mission_raw
from mavsdk_grpc import System
from mavsdk_grpc import mission_raw


async def px4_connect_drone():
Expand Down
4 changes: 2 additions & 2 deletions examples/offboard_attitude.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import asyncio

from mavsdk import System
from mavsdk.offboard import Attitude, OffboardError
from mavsdk_grpc import System
from mavsdk_grpc.offboard import Attitude, OffboardError


async def run():
Expand Down
8 changes: 4 additions & 4 deletions examples/offboard_from_csv/offboard_from_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@
import csv
import io
import anyio
from mavsdk import System
from mavsdk.offboard import PositionNedYaw, VelocityNedYaw
from mavsdk.offboard import OffboardError
from mavsdk.telemetry import LandedState
from mavsdk_grpc import System
from mavsdk_grpc.offboard import PositionNedYaw, VelocityNedYaw
from mavsdk_grpc.offboard import OffboardError
from mavsdk_grpc.telemetry import LandedState


# Find the current waypoint based on time
Expand Down
Loading