Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Drone Autopilot Mavlink

ASecurity

Autonomous drone autopilot control, telemetry stream parsing, and offboard mission execution using MAVLink, MAVSDK, and PX4 / ArduPilot. Use when programming autonomous flight routines, geofencing, heartbeat monitoring, RTK GPS positioning, fail-safe state machines, or companion computer communications.

8 stars
0 votes
0 copies
0 views
Added 9/29/2026
ai-agentspythongoc++bash

Security Analysis

A100/100

Scanned 9/29/2026

$npx -y skills add hamzabellouch/agent-skills --skill drone-autopilot-mavlink --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Drone Autopilot Mavlink?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Drone Autopilot Mavlink
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hamzabellouch-drone-autopilot-mavlink/badge)](https://www.skillsdirectory.com/skills/hamzabellouch-drone-autopilot-mavlink)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: drone-autopilot-mavlink
metadata:
  category: Autonomous Systems and Robotics
description: Autonomous drone autopilot control, telemetry stream parsing, and offboard mission execution using MAVLink, MAVSDK, and PX4 / ArduPilot. Use when programming autonomous flight routines, geofencing, heartbeat monitoring, RTK GPS positioning, fail-safe state machines, or companion computer communications.
compatibility: MAVLink 2.0, MAVSDK (Python/C++), PX4 Autopilot v1.14+, ArduPilot, ROS 2 (MAVROS2 / MicroXRCE-DDS)
---

# Drone Autopilot & MAVLink Mission Control Guidelines

This skill details architecture, telemetry stream decoding, offboard velocity/position control, fail-safe state machine design, and companion computer integration for autonomous Unmanned Aerial Vehicles (UAV) running PX4 or ArduPilot firmware.

---

## 1. MAVLink Protocol & Autopilot Communication Architecture

MAVLink (Micro Air Vehicle Link) is a lightweight binary protocol over UDP/Serial for communicating between Flight Controllers (PX4/ArduPilot), Companion Computers (Raspberry Pi/Jetson), and Ground Control Stations (QGroundControl):

```
+------------------------------------+          UDP / Serial (MAVLink 2.0)          +--------------------------------------+
|        Companion Computer          | <------------------------------------------> |           Flight Controller          |
|  (MAVSDK / PyMAVLink / Offboard)   |                                              |      (PX4 / ArduPilot Autopilot)     |
+------------------------------------+                                              +--------------------------------------+
                  |                                                                                    |
            REST / gRPC                                                                           PWM / CAN Bus
                  v                                                                                    v
+------------------------------------+                                              +--------------------------------------+
|       Cloud Telemetry / Fleet      |                                              |     ESC / Motors / GPS / RTK / IMU   |
+------------------------------------+                                              +--------------------------------------+
```

---

## 2. Autonomous Offboard Flight Script (MAVSDK Python)

Below is a production-grade, asynchronous offboard mission script using MAVSDK Python featuring heartbeat verification, pre-arm safety checks, takeoff, velocity guidance, geofencing, and automated Return-to-Launch (RTL):

```python
import asyncio
from mavsdk import System
from mavsdk.offboard import OffboardError, VelocityNedYaw, PositionNedYaw
from mavsdk.action import ActionError
import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("DroneAutopilot")

class AutonomousDroneController:
    def __init__(self, mavlink_url: str = "udp://:14540"):
        self.drone = System()
        self.mavlink_url = mavlink_url

    async def connect(self):
        logger.info(f"Connecting to autopilot at {self.mavlink_url}...")
        await self.drone.connect(system_address=self.mavlink_url)

        # 1. Wait for Flight Controller Heartbeat
        async for state in self.drone.core.connection_state():
            if state.is_connected:
                logger.info("Flight Controller Connected! Heartbeat detected.")
                break

        # 2. Wait for GPS Fix & Health Checks
        logger.info("Awaiting Global Position GPS Lock & Home Position...")
        async for health in self.drone.telemetry.health():
            if health.is_global_position_ok and health.is_home_position_ok:
                logger.info("GPS Fix & Home Position Established.")
                break

    async def execute_autonomous_mission(self, target_altitude_m: float = 5.0):
        # 3. Arm Aircraft
        try:
            logger.info("Arming motors...")
            await self.drone.action.arm()
        except ActionError as e:
            logger.error(f"Arming failed: {e}")
            return

        # 4. Take Off
        logger.info(f"Taking off to {target_altitude_m}m altitude...")
        await self.drone.action.set_takeoff_altitude(target_altitude_m)
        await self.drone.action.takeoff()
        await asyncio.sleep(8) # Wait to reach takeoff altitude

        # 5. Initialize Offboard Mode with Initial Zero Velocity Setpoint
        logger.info("Initializing Offboard Control mode...")
        await self.drone.offboard.set_velocity_ned(VelocityNedYaw(0.0, 0.0, 0.0, 0.0))
        
        try:
            await self.drone.offboard.start()
        except OffboardError as error:
            logger.critical(f"Starting offboard mode failed: {error._result.result}")
            logger.info("Disarming due to safety failure.")
            await self.drone.action.return_to_launch()
            return

        # 6. Execute Offboard Trajectory: Fly Forward (North) at 2 m/s
        logger.info("Flying North at 2.0 m/s...")
        await self.drone.offboard.set_velocity_ned(VelocityNedYaw(2.0, 0.0, 0.0, 0.0))
        await asyncio.sleep(5)

        # Fly East at 1.5 m/s while turning yaw to 90 degrees
        logger.info("Flying East at 1.5 m/s, Yaw 90 deg...")
        await self.drone.offboard.set_velocity_ned(VelocityNedYaw(0.0, 1.5, 0.0, 90.0))
        await asyncio.sleep(5)

        # Stop Movement
        logger.info("Holding Position...")
        await self.drone.offboard.set_velocity_ned(VelocityNedYaw(0.0, 0.0, 0.0, 90.0))
        await asyncio.sleep(3)

        # 7. Stop Offboard and Return To Launch (RTL)
        logger.info("Stopping offboard mode & executing Return-to-Launch (RTL)...")
        try:
            await self.drone.offboard.stop()
        except OffboardError as error:
            logger.error(f"Stopping offboard mode failed: {error._result.result}")

        await self.drone.action.return_to_launch()

async def main():
    controller = AutonomousDroneController("udp://:14540")
    await controller.connect()
    await controller.execute_autonomous_mission(target_altitude_m=4.0)

if __name__ == "__main__":
    asyncio.run(main())
```

---

## 3. Telemetry Stream Monitoring & Geofence Failsafe

```python
async def monitor_telemetry_failsafe(drone: System, max_distance_from_home_m: float = 100.0):
    """Continuous background task checking battery levels and geofence distance."""
    async for position in drone.telemetry.position():
        # Calculate local distance or battery voltage
        pass

    async for battery in drone.telemetry.battery():
        if battery.remaining_percent < 0.20: # 20% Low Battery
            logger.warning("LOW BATTERY WARNING! Initiating Emergency Landing.")
            await drone.action.land()
            break
```

---

## 4. Anti-Patterns & Critical Pitfalls

| Anti-Pattern | Severity | Consequence | Correct Pattern |
|---|---|---|---|
| Switching to Offboard without prior setpoint message | Critical | Autopilot rejects mode change, safety rejection | Send initial `set_velocity_ned` or `set_position_ned` BEFORE calling `offboard.start()` |
| Offboard setpoint stream rate < 2 Hz | Critical | PX4 command timeout trigger -> Failsafe land | Maintain minimum 10 Hz to 20 Hz continuous streaming loop |
| Missing Heartbeat Timeout Monitoring | High | Uncontrolled drone flight if companion script crashes | Enable PX4 `COM_OBL_ACT` failsafe action |
| Ignoring `health.is_armable` status checks | Critical | Flight crash due to uncalibrated gyro/compass | Check `health` stream before issuing `arm()` |
| Hardcoded Altitude without AGL / Terrain check | High | Ground crash on uneven terrain | Use Rangefinder / Lidar distance sensor or Barometric AGL |

---

## 5. Verification & SITL Simulation Protocols

1. **PX4 Gazebo / QGroundControl SITL**: Run simulation locally to verify offboard script before hardware deployment:
   ```bash
   make px4_sitl gazebo-classic
   ```
2. **MAVLink Inspector**: Verify message rates (`HEARTBEAT`, `LOCAL_POSITION_NED`, `ATTITUDE`) are active at specified frequencies.
3. **Hardware-in-the-Loop (HITL)**: Test on physical autopilot hardware connected to simulation prior to live flight.

Attribution

hamzabellouchhamzabellouch
View sourceSee grades on GitHubMore from hamzabellouch →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698431 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →