Skip to main content

Python sample control gimbal via Mavlink.

Project description

pygimbal

Pygimbal is an open source software developed in Python, designed for controlling gimbals using the Mavlink protocol. It allows users to control the gimbal's tilt, pan, and roll angles, as well as retrieve real-time angle values.

Install

pip install pygimbal

Getting Started

How to control gimbal via Mavlink with Python:

Note: you need to give permission to gimbal uart port first.

sudo chmod a+wrx /dev/ttyUSB0

Sample code:

import time
from pygimbal import control
from threading import Thread

master_gimbal = control.init_mav_connector('/dev/ttyUSB0', 1, 154, 115200)
system = master_gimbal.source_system
component = master_gimbal.source_component

maintain_connection_threading = Thread(target=control.maintain_connection, args=[master_gimbal], daemon=True)
maintain_connection_threading.start()

orientation_theading = Thread(target=control.get_orientation, args=[master_gimbal], daemon=True)
orientation_theading.start()

while True:
    try:
        control.control_gimbal(master_gimbal, system, component, tilt=45, roll=0, pan=45)
        time.sleep(2)
        control.control_gimbal(master_gimbal, system, component, tilt=0, roll=0, pan=0)
        time.sleep(2)
        control.control_gimbal(master_gimbal, system, component, tilt=45, roll=0, pan=-45)
        time.sleep(2)
        control.control_gimbal(master_gimbal, system, component, tilt=0, roll=0, pan=0)
        time.sleep(2)
    except KeyboardInterrupt:
        break

Output:

[ACTION]: Mavlink is connecting to /dev/ttyUSB0
[MESSAGE]: Successful Connection to /dev/ttyUSB0 1 154
[Control] Gimbal Pitch - Yaw 45 45
[ORIENTATION] Til, Pan, Roll:  0.1949998289346695 0.02197265625 0.023102451115846634
[ORIENTATION] Til, Pan, Roll:  0.19493775069713593 0.02197265625 0.02414652332663536
[ORIENTATION] Til, Pan, Roll:  0.19543787837028503 0.02197265625 0.02471373975276947
[ORIENTATION] Til, Pan, Roll:  0.19867371022701263 0.02197265625 0.0238236952573061

Result:

Author

github: winter2897
mail: haiquantran2897@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygimbal-1.0.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

pygimbal-1.0.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file pygimbal-1.0.0.tar.gz.

File metadata

  • Download URL: pygimbal-1.0.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for pygimbal-1.0.0.tar.gz
Algorithm Hash digest
SHA256 93c2ab6ab1c1dbb522cc56d9a00d2ec4855ab59977d51dccdd4c93180a73a272
MD5 95c15f3bef00d99c07780a61d9625259
BLAKE2b-256 1ce988af3f553e2ffab8e717a735aec38344a68b7df2ce518872c6b04121fdcc

See more details on using hashes here.

File details

Details for the file pygimbal-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pygimbal-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for pygimbal-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ab35276c4e66c4ac7e678db653dd51787a26add40e62b394ff1ac5389b2d615
MD5 f96ae886b72aa10480451a79aab42276
BLAKE2b-256 9b091c0f629eaf118a5d2455ae79976ae0e9fd9af64f8a1381d4b83dd281b11c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page