Skip to content

ByIbos/dronelink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

🛰️ dronelink

Serial & MAVLink Drone Communication Library

Send gimbal angles, flight commands, and heartbeats over UART/USB-Serial.

Python PySerial License


✨ 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

About

Comprehensive Serial/MAVLink integration for precise gimbal control and robust packet framing.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages