Serial/MAVLink drone communication library with gimbal servo control and packet framing.
Project description
🛰️ dronelink
Serial & MAVLink Drone Communication Library
Send gimbal angles, flight commands, and heartbeats over UART/USB-Serial.
✨ Features
- Packet Framing — Header + Command ID + Payload + XOR Checksum
- GimbalController — Normalized PID output → servo angle conversion
- Exponential Smoothing — Prevents jittery servo movement
- Rate Limiting — 50Hz max update rate to prevent serial flooding
- Heartbeat — Keep-alive packets for connection monitoring
📦 Installation
pip install dronelink
🚀 Quick Start
from dronelink import DroneLink, GimbalController
# Connect to flight controller
drone = DroneLink("COM3", baudrate=115200)
# Create gimbal controller
gimbal = GimbalController(drone, pan_range=(-90, 90), tilt_range=(-45, 45))
# In your tracking loop:
# pid_x, pid_y are from servopilot (-1.0 to +1.0)
gimbal.set_angles(pan=pid_x, tilt=pid_y)
# Send heartbeat periodically
drone.send_heartbeat()
# Check status
print(gimbal.get_status())
# Cleanup
drone.close()
Integration with ServoPilot
from servopilot import DualAxisPID
from dronelink import DroneLink, GimbalController
pid = DualAxisPID(kp=0.4, ki=0.008, kd=0.25)
drone = DroneLink("COM3")
gimbal = GimbalController(drone)
# Tracking loop
signal_x, signal_y = pid.update(error_x, error_y, dt=1/30)
gimbal.set_angles(pan=signal_x, tilt=signal_y)
🔧 API Reference
DroneLink(port, baudrate=115200, timeout=1.0)
| Method | Description |
|---|---|
send_command(cmd_id, payload) |
Send framed packet with checksum |
send_raw(data) |
Send raw bytes |
send_heartbeat() |
Send keep-alive packet |
read_response(size) |
Read response bytes |
close() |
Close serial connection |
GimbalController(link, pan_range, tilt_range, smooth_factor)
| Method | Description |
|---|---|
set_angles(pan, tilt) |
Send normalized (-1 to +1) gimbal angles |
center() |
Return to (0°, 0°) |
get_status() |
Get current/target angles |
📜 License
MIT License — use it anywhere.
Built with ❤️ by ByIbos
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dronelink-1.0.0.tar.gz
(6.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dronelink-1.0.0.tar.gz.
File metadata
- Download URL: dronelink-1.0.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ad58e0c8c3a53f108b31a5c44abafb42d0ac3830d0a51b9356413384a75af58
|
|
| MD5 |
a4d4509120eb489b5669dcec69b5c5b7
|
|
| BLAKE2b-256 |
ddefd88e3fef05303836cb8d3f2fbfcbf2edcbf41f1e9865e4f257e0a24c9e0e
|
File details
Details for the file dronelink-1.0.0-py3-none-any.whl.
File metadata
- Download URL: dronelink-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb4bdbaf20ad4083429bc58bf2f4b03471b806de2c8e2eda600042890dd7baed
|
|
| MD5 |
f2f83bcc7facfe6ecaa8b0ebd349137e
|
|
| BLAKE2b-256 |
91491ebe74a28202cfa410f4858e12fb4cd1375f774e61325fc87f33fd9b662d
|