Skip to main content

A library for the MAVLink protocol

Project description

Libmav Python

Native python bindings for the libmav library.

Installation

pip install libmav

Example usage

import libmav

# Create a message set from a mavlink xml file
message_set = libmav.MessageSet('<PATH TO common.xml>')
# You can also add additional messages here with inline xml
message_set.add_from_xml_string('''
<mavlink>
    <messages>
        <message>
            ...
        </message>
    </messages>
</mavlink>''')

# Create a message from the message set
message = self.message_set.create('MY_PROTOCOL_MESSAGE')

# Set fields of the message individually
message['my_numeric_field'] = 1
message['my_char_array_field'] = 'Hello world'
message['my_float_array_field'] = [1.0, 2.0, 3.0]
message['my_int_array_field'] = [4, 5, 6]

# Get fields individually
my_num = message['my_numeric_field']
my_string = message['my_char_array_field']
my_float_array_field = message['my_float_array_field']

# You can also use pythonic things like list comprehensions
    # This creates a list of all the values in my_float_array_field multiplied by 2
my_float_array_field = [x * 2 for x in message['my_float_array_field']]

# Set fields from a dict
message.set_from_dict({
            'my_numeric_field': 1,
            'my_char_array_field': 'Hello world',
            'my_float_array_field': [1.0, 2.0, 3.0],
            'my_int_array_field': [4, 5, 6]
        })


# Get fields as python dict
message_dict = message.to_dict()


# Connect to a TCP server
conn_physical = libmav.TCPClient('192.168.1.12', 14550)
conn_runtime = libmav.NetworkRuntime(self.message_set, heartbeat, client_physical)

connection = conn_runtime.await_connection(2000)

# Check if connection is still alive
if not connection.alive():
    print('Connection lost, waiting for reconnect...')
    connection = conn_runtime.await_connection(2000)

# Send a message
connection.send(message)

# Receive a message, timeout 1s
received_message = connection.receive("HEARTBEAT", 1000)

# Receive a message, no timeout
received_message = connection.receive("HEARTBEAT")

# Receive a message as the result of a message we send
# This avoids the race condition between us sending and then waiting for reception
expectation = connection.receive("PARAM_VALUE")
connection.send(our_param_request_message)
received_message = connection.receive(expectation, 1000)


# Connect to a Serial port
conn_physical = libmav.TCPClient('/dev/ttyUSB0', 14550)
conn_runtime = libmav.NetworkRuntime(self.message_set, heartbeat, client_physical)

Install from source

Prerequisites

  • A compiler with C++11 support
  • Pip 10+ or CMake >= 3.4 (or 3.14+ on Windows, which was the first version to support VS 2019)
  • Ninja or Pip 10+

Just clone this repository and pip install. Note the --recursive option which is needed for the pybind11 submodule:

git clone --recursive https://github.com/Auterion/libmav-python.git
pip install ./libmav-python

With the setup.py file included in this project, the pip install command will invoke CMake and build the pybind11 module as specified in CMakeLists.txt.

Project details


Download files

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

Source Distribution

libmav-0.0.1.tar.gz (322.6 kB view hashes)

Uploaded Source

Built Distributions

libmav-0.0.1-cp311-cp311-musllinux_1_1_x86_64.whl (763.2 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

libmav-0.0.1-cp311-cp311-musllinux_1_1_i686.whl (833.3 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

libmav-0.0.1-cp311-cp311-musllinux_1_1_aarch64.whl (735.2 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ ARM64

libmav-0.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (277.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

libmav-0.0.1-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (298.0 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686

libmav-0.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (257.9 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

libmav-0.0.1-cp311-cp311-macosx_10_15_x86_64.whl (198.2 kB view hashes)

Uploaded CPython 3.11 macOS 10.15+ x86-64

libmav-0.0.1-cp311-cp311-macosx_10_15_universal2.whl (375.7 kB view hashes)

Uploaded CPython 3.11 macOS 10.15+ universal2 (ARM64, x86-64)

libmav-0.0.1-cp310-cp310-musllinux_1_1_x86_64.whl (763.2 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

libmav-0.0.1-cp310-cp310-musllinux_1_1_i686.whl (833.3 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

libmav-0.0.1-cp310-cp310-musllinux_1_1_aarch64.whl (735.2 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ ARM64

libmav-0.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (277.4 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

libmav-0.0.1-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (298.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686

libmav-0.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (258.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

libmav-0.0.1-cp310-cp310-macosx_10_15_x86_64.whl (198.2 kB view hashes)

Uploaded CPython 3.10 macOS 10.15+ x86-64

libmav-0.0.1-cp310-cp310-macosx_10_15_universal2.whl (375.7 kB view hashes)

Uploaded CPython 3.10 macOS 10.15+ universal2 (ARM64, x86-64)

libmav-0.0.1-cp39-cp39-musllinux_1_1_x86_64.whl (763.1 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

libmav-0.0.1-cp39-cp39-musllinux_1_1_i686.whl (833.4 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

libmav-0.0.1-cp39-cp39-musllinux_1_1_aarch64.whl (735.1 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ ARM64

libmav-0.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (277.6 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

libmav-0.0.1-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (297.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686

libmav-0.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (258.3 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

libmav-0.0.1-cp39-cp39-macosx_10_15_x86_64.whl (198.2 kB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

libmav-0.0.1-cp39-cp39-macosx_10_15_universal2.whl (375.9 kB view hashes)

Uploaded CPython 3.9 macOS 10.15+ universal2 (ARM64, x86-64)

libmav-0.0.1-cp38-cp38-musllinux_1_1_x86_64.whl (763.6 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

libmav-0.0.1-cp38-cp38-musllinux_1_1_i686.whl (833.0 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

libmav-0.0.1-cp38-cp38-musllinux_1_1_aarch64.whl (734.6 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ ARM64

libmav-0.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (277.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

libmav-0.0.1-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl (297.3 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686

libmav-0.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (257.4 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

libmav-0.0.1-cp38-cp38-macosx_10_15_x86_64.whl (198.2 kB view hashes)

Uploaded CPython 3.8 macOS 10.15+ x86-64

libmav-0.0.1-cp38-cp38-macosx_10_15_universal2.whl (375.8 kB view hashes)

Uploaded CPython 3.8 macOS 10.15+ universal2 (ARM64, x86-64)

libmav-0.0.1-cp37-cp37m-musllinux_1_1_x86_64.whl (769.1 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

libmav-0.0.1-cp37-cp37m-musllinux_1_1_i686.whl (840.9 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ i686

libmav-0.0.1-cp37-cp37m-musllinux_1_1_aarch64.whl (741.6 kB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ ARM64

libmav-0.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (283.0 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

libmav-0.0.1-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl (307.4 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686

libmav-0.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (266.0 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

libmav-0.0.1-cp37-cp37m-macosx_10_15_x86_64.whl (194.6 kB view hashes)

Uploaded CPython 3.7m macOS 10.15+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page