• Stars
    star
    380
  • Rank 112,210 (Top 3 %)
  • Language
    Python
  • License
    Other
  • Created about 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

python MAVLink interface and utilities

Build Status

Pymavlink

This is a Python implementation of the MAVLink protocol. It includes a source code generator (generator/mavgen.py) to create MAVLink protocol implementations for other programming languages as well. Also contains tools for analyzing flight logs.

Documentation

Please see http://ardupilot.org/dev/docs/mavlink-commands.html for mavlink command reference.

For realtime discussion please see the pymavlink Gitter channel

Examples can be found in the repository or in the ArduSub book

Installation

Pymavlink supports both Python 2 and Python 3.

The following instructions assume you are using Python 3 and a Debian-based (like Ubuntu) installation.

.. note::

pymavlink assumes the command "python" is in your path. Your distribution may provide a package such as "python-is-python3" to ensure that "python" is in your path.

Dependencies

Pymavlink has several dependencies :

- [future](http://python-future.org/) : for Python 2 and Python 3 interoperability
- [lxml](http://lxml.de/installation.html) : for checking and parsing xml file 

Optional :

- numpy : for FFT
- pytest : for tests

On Linux

lxml has some additional dependencies that can be installed with your package manager (here with apt-get) :

.. note::

If you continue to use Python 2 you may need to change package names here (e.g. python3-numpy => python-numpy)

sudo apt-get install libxml2-dev libxslt-dev

Optional for FFT scripts and tests:

sudo apt-get install python3-numpy python3-pytest

Using pip you can install the required dependencies for pymavlink :

sudo python -m pip install --upgrade future lxml

On Windows

Use pip to install future as for Linux. Lxml can be installed with a Windows installer from here : https://pypi.org/project/lxml

Installation

For users

It is recommended to install pymavlink from PyPI with pip, that way dependencies should be auto installed by pip.

sudo python -m pip install --upgrade pymavlink

Mavnative

Starting from September 2022, mavnative, a C extension for parsing mavlink, was deprecated and removed. Mavnative developpement was stalled for long time, it only supports MAVLink1 and doesn't get any fix on the protocol.

For developers

From the pymavlink directory, you can use :

sudo MDEF=PATH_TO_message_definitions python -m pip install . -v

Since pip installation is executed from /tmp, it is necessary to point to the directory containing message definitions with MDEF. MDEF should not be set to any particular message version directory but the parent folder instead. If you have cloned from mavlink/mavlink then this is /mavlink/message_definitions . Using pip should auto install dependencies and allow you to keep them up-to-date.

Or:

sudo python setup.py install

Ardupilot Custom Modes

By default, pymavlink will map the Ardupilot mode names to mode numbers per the definitions in the ardupilotmega.xml file. However, during development, it can be useful to add to or update the default mode mappings.

To do this:

  • create a folder named .pymavlink in your home directory (i.e. $HOME on Linux, $USERPROFILE on Windows); and
  • add a JSON file called custom_mode_map.json to this new .pymavlink folder.

The JSON file is a dictionary that maps vehicle MAV_TYPE value to a dictionary of mode numbers to mode names. An example that duplicates the existing mapping for MAV_TYPE_FIXED_WING (enum value of 1) vehicles is as follows:

{
    "1": {
        "0":  "MANUAL",
        "1":  "CIRCLE",
        "2":  "STABILIZE",
        "3":  "TRAINING",
        "4":  "ACRO",
        "5":  "FBWA",
        "6":  "FBWB",
        "7":  "CRUISE",
        "8":  "AUTOTUNE",
        "10": "AUTO",
        "11": "RTL",
        "12": "LOITER",
        "13": "TAKEOFF",
        "14": "AVOID_ADSB",
        "15": "GUIDED",
        "16": "INITIALISING",
        "17": "QSTABILIZE",
        "18": "QHOVER",
        "19": "QLOITER",
        "20": "QLAND",
        "21": "QRTL",
        "22": "QAUTOTUNE",
        "23": "QACRO",
        "24": "THERMAL"
    }
}

This custom_mode_map.json file can be used to:

  • change the display name of an existing mode (e.g. change "TAKEOFF" to "LAUNCH");
  • add a new mode (e.g. add "25": "NEW_MODE"); and
  • add a mapping for an unsupported vehicle type (e.g. add a mapping for MAV_TYPE_AIRSHIP (enum value of 7) vehicles).

Notes:

  • Whilst the MAV_TYPE and mode numbers are integers, they need to be defined as strings in the JSON file, as raw integers can't be used as dictionary keys in JSON.
  • This feature updates the default definitions. You can use it to change the name-to-number mapping for a mode, but you completely can't remove an existing mapping.

License


pymavlink is released under the GNU Lesser General Public License v3 or later.

The source code generated by generator/mavgen.py is available under the permissive MIT License.

More Repositories

1

ardupilot

ArduPlane, ArduCopter, ArduRover, ArduSub source
C++
10,757
star
2

MissionPlanner

Mission Planner Ground Control Station for ArduPilot (c# .net)
C#
1,753
star
3

ardupilot_wiki

Repository for ArduPilot wiki issues and wiki-specific website infrastructure.
Python
485
star
4

apm_planner

APM Planner Ground Control Station (Qt)
C++
471
star
5

MAVProxy

MAVLink proxy and command line ground station
Python
393
star
6

SiK

Tools and firmware for the Si1000
C
252
star
7

Schematics

C
131
star
8

UAVLogViewer

An online viewer for UAV log files
JavaScript
131
star
9

OctomapPlanner

ArduPilot Gazebo SITL 3D mapping and planning
C++
123
star
10

companion

Companion computer startup scripts and examples
Shell
95
star
11

ArduRemoteID

RemoteID support using OpenDroneID
C++
90
star
12

ardupilot_gazebo

Plugins and models for vehicle simulation in Gazebo Sim with ArduPilot SITL controllers
C++
74
star
13

node-mavlink

This project is providing native TypeScript bindings and tools for sending and receiving MavLink messages over a verity of medium
TypeScript
56
star
14

alceosd

AlceOSD - Graphical OSD
C#
51
star
15

ChibiOS

Fork of ChibiOS for ArduPilot
C
47
star
16

SITL_Models

Models of aircraft for SITL
HTML
40
star
17

MethodicConfigurator

A clear ArduPilot configuration sequence
Python
31
star
18

ardupilot_gz

Tools for ArduPilot ROS2 integration and testing on ROS 2 humble
Python
31
star
19

ArduConfigurator

JavaScript
30
star
20

APWeb

ArduPilot web server interface
JavaScript
29
star
21

dema-rc

Linux Drone Remote Controller
C
20
star
22

binary

repository for binary files associated with ardupilot
GLSL
17
star
23

OMC

OpenMissionControl
C++
17
star
24

plotjuggler-apbin-plugins

ArduPilot Dataflash plugin for Plotjuggler
C++
15
star
25

CustomBuild

Custom build server source
Python
13
star
26

AP_Cloud

Fleet management solution for ArduPilot Drones
JavaScript
11
star
27

WebTools

JavaScript
11
star
28

ardupilot_dev_docker

Shell
9
star
29

SoloScripts

8
star
30

terraingen

Ardupilot Terrain Generator website
Python
7
star
31

OMC-docs

OpenMissionControl documentation
6
star
32

ChibiOS.svn

Mirror of ChibiOS svn repository
C
5
star
33

ardupilot_wiki_copy

Source for ardupilot.org website
Python
5
star
34

ardupilot-mavsdk

Shell
4
star
35

UDPProxy

UDP Proxy For MAVLink2
C++
4
star
36

ardupilot_vscode_devenv

VS Code extension for Ardupilot development setup
TypeScript
4
star
37

ParameterRepository

All generated parameters in a single place
HTML
4
star
38

useralerts

User Alerts for ArduPilot
HTML
4
star
39

node-mavlink-mappings

TypeScript
2
star
40

plot3d

3D path plotter for aerobatics
JavaScript
2
star
41

sphinxcontrib.vimeo

clone from https://bitbucket.org/jdouglass/sphinxcontrib.vimeo
Python
1
star
42

FWLoad

Factory load tool for Pixhawk2
Python
1
star
43

homebrew-ardupilot

Homebrew recipes for ArduPilot development on MacOS
Ruby
1
star
44

clj-ardupilot-utils

Clojure
1
star
45

gSOAP

Modified gSOAP library for use by Ardupilot
HTML
1
star