# ardupilot/pymavlink architecture

> Architecture diagram of the GitHub repository ardupilot/pymavlink, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ardupilot/pymavlink
- Repository: https://github.com/ardupilot/pymavlink

## Overview

Pymavlink provides a Python MAVLink implementation, generators for other language implementations, and flight-log analysis tools. A typical user either exchanges MAVLink messages through the Python runtime, supplies protocol definitions to the generator, or analyzes a flight log. The source index supports generator dispatch and selected internal references; README statements establish the broader product capabilities. Log-tool internals and several runtime relationships were not sampled, so those links are left out.

Main entry points: [`generator/mavgen.py`](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen.py) (Generator dispatcher), [`generator/mavtemplate.py`](https://github.com/ardupilot/pymavlink/blob/master/generator/mavtemplate.py) (Template engine), [`generator/mavgen_javascript.py`](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_javascript.py) (JavaScript generator), [`generator/mavgen_python.py`](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_python.py) (Python generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Python protocol runtime"]
  node_mavutil["MAVLink utilities<br/>[mavutil.py]"]
  node_mavftp["MAVLink FTP<br/>[mavftp.py]"]
  node_missions["Mission handling<br/>[mavwp.py]"]
  node_parameters["Parameter handling<br/>[mavparm.py]"]
  node_expressions["Telemetry expressions<br/>[mavexpression.py]"]
end

subgraph group_generation["Protocol generation"]
  node_parser["Definition parser<br/>[mavparse.py]"]
  node_templates["Template engine<br/>[mavtemplate.py]"]
  node_dispatcher["Generator dispatcher<br/>[mavgen.py]"]
  node_gen_ada["Ada generator<br/>[mavgen_ada.py]"]
  node_gen_c["C generator<br/>[mavgen_c.py]"]
  node_gen_cpp["C++ generator<br/>[mavgen_cpp11.py]"]
  node_gen_cs["C&#35; generator<br/>[mavgen_cs.py]"]
  node_gen_java["Java generator<br/>[mavgen_java.py]"]
  node_gen_js["JavaScript generator"]
  node_gen_js_stable["Stable JS generator"]
  node_gen_lua["Lua generator<br/>[mavgen_lua.py]"]
  node_gen_objc["Objective-C generator<br/>[mavgen_objc.py]"]
  node_gen_python["Python generator<br/>[mavgen_python.py]"]
  node_gen_rust["Rust generator<br/>[mavgen_rust.py]"]
  node_gen_spin2["Spin2 generator<br/>[mavgen_spin2.py]"]
  node_gen_swift["Swift generator<br/>[mavgen_swift.py]"]
  node_gen_ts["TypeScript generator"]
  node_gen_wlua["Wireshark Lua generator<br/>[mavgen_wlua.py]"]
end

subgraph group_generated["Generated protocol support"]
  node_wire_v1["MAVLink 1 C support<br/>[mavlink_helpers.h]"]
  node_types_v1["MAVLink 1 types<br/>[mavlink_types.h]"]
  node_wire_v2["MAVLink 2 C support<br/>[mavlink_helpers.h]"]
  node_types_v2["MAVLink 2 types<br/>[mavlink_types.h]"]
end

subgraph group_logs["Flight-log analysis"]
  node_log_reader["DataFlash log reader<br/>[DFReader.py]"]
  node_log_dump["Log dump tool<br/>[mavlogdump.py]"]
  node_log_analysis["Log analysis tools"]
end

node_user(("User or application"))

node_user -->|"exchanges messages"| node_mavutil
node_user -->|"requests generation"| node_dispatcher
node_user -->|"analyzes logs"| node_log_analysis
node_dispatcher -->|"parses definitions"| node_parser
node_dispatcher -->|"dispatches to"| node_gen_ada
node_dispatcher -->|"dispatches to"| node_gen_c
node_dispatcher -->|"dispatches to"| node_gen_cpp
node_dispatcher -->|"dispatches to"| node_gen_cs
node_dispatcher -->|"dispatches to"| node_gen_java
node_dispatcher -->|"dispatches to"| node_gen_js
node_dispatcher -->|"dispatches to"| node_gen_js_stable
node_dispatcher -->|"dispatches to"| node_gen_lua
node_dispatcher -->|"dispatches to"| node_gen_objc
node_dispatcher -->|"dispatches to"| node_gen_python
node_dispatcher -->|"dispatches to"| node_gen_rust
node_dispatcher -->|"dispatches to"| node_gen_spin2
node_dispatcher -->|"dispatches to"| node_gen_swift
node_dispatcher -->|"dispatches to"| node_gen_ts
node_dispatcher -->|"dispatches to"| node_gen_wlua
node_gen_python -->|"renders templates"| node_templates
node_gen_js -->|"renders templates"| node_templates
node_gen_wlua -->|"renders templates"| node_templates
node_templates -->|"uses parse errors"| node_parser

click node_mavutil "https://github.com/ardupilot/pymavlink/blob/master/mavutil.py"
click node_mavftp "https://github.com/ardupilot/pymavlink/blob/master/mavftp.py"
click node_missions "https://github.com/ardupilot/pymavlink/blob/master/mavwp.py"
click node_parameters "https://github.com/ardupilot/pymavlink/blob/master/mavparm.py"
click node_expressions "https://github.com/ardupilot/pymavlink/blob/master/mavexpression.py"
click node_parser "https://github.com/ardupilot/pymavlink/blob/master/generator/mavparse.py"
click node_templates "https://github.com/ardupilot/pymavlink/blob/master/generator/mavtemplate.py"
click node_dispatcher "https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen.py"
click node_gen_ada "https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_ada.py"
click node_gen_c "https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_c.py"
click node_gen_cpp "https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_cpp11.py"
click node_gen_cs "https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_cs.py"
click node_gen_java "https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_java.py"
click node_gen_js "https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_javascript.py"
click node_gen_js_stable "https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_javascript_stable.py"
click node_gen_lua "https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_lua.py"
click node_gen_objc "https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_objc.py"
click node_gen_python "https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_python.py"
click node_gen_rust "https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_rust.py"
click node_gen_spin2 "https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_spin2.py"
click node_gen_swift "https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_swift.py"
click node_gen_ts "https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_typescript.py"
click node_gen_wlua "https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_wlua.py"
click node_wire_v1 "https://github.com/ardupilot/pymavlink/blob/master/generator/C/include_v1.0/mavlink_helpers.h"
click node_types_v1 "https://github.com/ardupilot/pymavlink/blob/master/generator/C/include_v1.0/mavlink_types.h"
click node_wire_v2 "https://github.com/ardupilot/pymavlink/blob/master/generator/C/include_v2.0/mavlink_helpers.h"
click node_types_v2 "https://github.com/ardupilot/pymavlink/blob/master/generator/C/include_v2.0/mavlink_types.h"
click node_log_reader "https://github.com/ardupilot/pymavlink/blob/master/DFReader.py"
click node_log_dump "https://github.com/ardupilot/pymavlink/blob/master/tools/mavlogdump.py"
click node_log_analysis "https://github.com/ardupilot/pymavlink/tree/master/tools"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mavutil,node_mavftp,node_missions,node_parameters,node_expressions,node_user toneBlue
class node_parser,node_templates,node_dispatcher,node_gen_ada,node_gen_c,node_gen_cpp,node_gen_cs,node_gen_java,node_gen_js,node_gen_js_stable,node_gen_lua,node_gen_objc,node_gen_python,node_gen_rust,node_gen_spin2,node_gen_swift,node_gen_ts,node_gen_wlua toneAmber
class node_wire_v1,node_types_v1,node_wire_v2,node_types_v2 toneMint
class node_log_reader,node_log_dump,node_log_analysis toneRose
```

## Components

### Python protocol runtime

- [MAVLink utilities](https://github.com/ardupilot/pymavlink/blob/master/mavutil.py): `mavutil.py`
- [MAVLink FTP](https://github.com/ardupilot/pymavlink/blob/master/mavftp.py): `mavftp.py`
- [Mission handling](https://github.com/ardupilot/pymavlink/blob/master/mavwp.py): `mavwp.py`
- [Parameter handling](https://github.com/ardupilot/pymavlink/blob/master/mavparm.py): `mavparm.py`
- [Telemetry expressions](https://github.com/ardupilot/pymavlink/blob/master/mavexpression.py): `mavexpression.py`

### Protocol generation

- [Definition parser](https://github.com/ardupilot/pymavlink/blob/master/generator/mavparse.py): `generator/mavparse.py`
- [Template engine](https://github.com/ardupilot/pymavlink/blob/master/generator/mavtemplate.py): `generator/mavtemplate.py`
- [Generator dispatcher](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen.py): `generator/mavgen.py`
- [Ada generator](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_ada.py): `generator/mavgen_ada.py`
- [C generator](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_c.py): `generator/mavgen_c.py`
- [C++ generator](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_cpp11.py): `generator/mavgen_cpp11.py`
- [C# generator](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_cs.py): `generator/mavgen_cs.py`
- [Java generator](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_java.py): `generator/mavgen_java.py`
- [JavaScript generator](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_javascript.py): `generator/mavgen_javascript.py`
- [Stable JS generator](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_javascript_stable.py): `generator/mavgen_javascript_stable.py`
- [Lua generator](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_lua.py): `generator/mavgen_lua.py`
- [Objective-C generator](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_objc.py): `generator/mavgen_objc.py`
- [Python generator](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_python.py): `generator/mavgen_python.py`
- [Rust generator](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_rust.py): `generator/mavgen_rust.py`
- [Spin2 generator](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_spin2.py): `generator/mavgen_spin2.py`
- [Swift generator](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_swift.py): `generator/mavgen_swift.py`
- [TypeScript generator](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_typescript.py): `generator/mavgen_typescript.py`
- [Wireshark Lua generator](https://github.com/ardupilot/pymavlink/blob/master/generator/mavgen_wlua.py): `generator/mavgen_wlua.py`

### Generated protocol support

- [MAVLink 1 C support](https://github.com/ardupilot/pymavlink/blob/master/generator/C/include_v1.0/mavlink_helpers.h): `generator/C/include_v1.0/mavlink_helpers.h`
- [MAVLink 1 types](https://github.com/ardupilot/pymavlink/blob/master/generator/C/include_v1.0/mavlink_types.h): `generator/C/include_v1.0/mavlink_types.h`
- [MAVLink 2 C support](https://github.com/ardupilot/pymavlink/blob/master/generator/C/include_v2.0/mavlink_helpers.h): `generator/C/include_v2.0/mavlink_helpers.h`
- [MAVLink 2 types](https://github.com/ardupilot/pymavlink/blob/master/generator/C/include_v2.0/mavlink_types.h): `generator/C/include_v2.0/mavlink_types.h`

### Flight-log analysis

- [DataFlash log reader](https://github.com/ardupilot/pymavlink/blob/master/DFReader.py): `DFReader.py`
- [Log dump tool](https://github.com/ardupilot/pymavlink/blob/master/tools/mavlogdump.py): `tools/mavlogdump.py`
- [Log analysis tools](https://github.com/ardupilot/pymavlink/tree/master/tools): `tools`

### Other components

- **User or application**

## Connections

- User or application → MAVLink utilities: exchanges messages
- User or application → Generator dispatcher: requests generation
- User or application → Log analysis tools: analyzes logs
- Generator dispatcher → Definition parser: parses definitions (evidence: `generator/mavgen.py`)
- Generator dispatcher → Ada generator: dispatches to (evidence: `generator/mavgen.py`)
- Generator dispatcher → C generator: dispatches to (evidence: `generator/mavgen.py`)
- Generator dispatcher → C++ generator: dispatches to (evidence: `generator/mavgen.py`)
- Generator dispatcher → C# generator: dispatches to (evidence: `generator/mavgen.py`)
- Generator dispatcher → Java generator: dispatches to (evidence: `generator/mavgen.py`)
- Generator dispatcher → JavaScript generator: dispatches to (evidence: `generator/mavgen.py`)
- Generator dispatcher → Stable JS generator: dispatches to (evidence: `generator/mavgen.py`)
- Generator dispatcher → Lua generator: dispatches to (evidence: `generator/mavgen.py`)
- Generator dispatcher → Objective-C generator: dispatches to (evidence: `generator/mavgen.py`)
- Generator dispatcher → Python generator: dispatches to (evidence: `generator/mavgen.py`)
- Generator dispatcher → Rust generator: dispatches to (evidence: `generator/mavgen.py`)
- Generator dispatcher → Spin2 generator: dispatches to (evidence: `generator/mavgen.py`)
- Generator dispatcher → Swift generator: dispatches to (evidence: `generator/mavgen.py`)
- Generator dispatcher → TypeScript generator: dispatches to (evidence: `generator/mavgen.py`)
- Generator dispatcher → Wireshark Lua generator: dispatches to (evidence: `generator/mavgen.py`)
- Python generator → Template engine: renders templates (evidence: `generator/mavgen_python.py`)
- JavaScript generator → Template engine: renders templates (evidence: `generator/mavgen_javascript.py`)
- Wireshark Lua generator → Template engine: renders templates (evidence: `generator/mavgen_wlua.py`)
- Template engine → Definition parser: uses parse errors (evidence: `generator/mavtemplate.py`)
