Skip to main content

gs2d: The Library for Generic Serial-bus Servo Driver kr-sac001 for Python

Project description

gs2d: Generic Serial-bus Servo Driver library for Python

karakuri products社製シリアルサーボドライバ kr-sac001 用の Python ライブラリ


機能

  • karakuri products社製シリアルサーボドライバ kr-sac001 に接続されたサーボモータを Python で簡単にコントロールできるライブラリです。
  • 様々なブランドのサーボモータをほぼ同じ関数で制御が可能です。
  • Read系コマンドはBlockingスタイル、callbackスタイル、asyncスタイルで利用可能です。

サポートしているサーボモータ

  • 現在対応しているサーボモータ

    • FUTABA RS40x
    • Robotis Dynamixel (Protocol2.0)
  • 対応したいな、と思っているサーボモータ

    • KONDO KRS300x
    • KONDO KRS400x
    • JR programmable
    • Vstone Vs-xxx

インストール方法

pip install gs2d

利用例

フタバのサーボモータID:1をちょっとずつ動かす

from gs2d import SerialInterface, Futaba

# Initialize
si = SerialInterface()
futaba = Futaba(si)

# Enable torque
futaba.set_torque_enable(True, sid=1)

for i in range(11):
  angle = i * 20 - 100
  print('Angle:', angle, 'deg')
  futaba.set_target_position(angle, sid=1)
  time.sleep(0.5)

# Disable torque
futaba.set_torque_enable(False, sid=1)

# Close
futaba.close()
si.close()

フタバのサーボモータID:1の電圧を取得する (Blocking版)

from gs2d import SerialInterface, Futaba

# 初期化
si = SerialInterface()
futaba = Futaba(si)

# 電圧取得
v = futaba.get_voltage(sid=1)
print('Voltage: %.2f(V)' % v)

# クローズ
futaba.close()
si.close()

フタバのサーボモータID:1の電圧を取得する (コールバック版)

from gs2d import SerialInterface, Futaba

def voltage_callback(voltage):
    """電圧取得できたときに呼ばれる"""
    print('Voltage: %.2f(V)' % voltage)

    # クローズ
    futaba.close()
    si.close()

# 初期化
si = SerialInterface()
futaba = Futaba(si)

# コールバックつきで電圧取得
futaba.get_voltage(sid=1, callback=voltage_callback)

フタバのサーボモータID:1の電圧を取得する (Async版)

import asyncio
from gs2d import SerialInterface, Futaba

async def main(loop):
    # Initialize SerialInterface & servo object
    si = SerialInterface()
    futaba = Futaba(si)

    # Get voltage
    voltage = await futaba.get_voltage_async(sid=1)
    print('Voltage: %.2f(V)' % voltage)

    # Close SerialInterface & servo object
    futaba.close()
    si.close()


# Initialize event loop
lp = asyncio.get_event_loop()
lp.run_until_complete(main(lp))
lp.close()

API

Torque Enable (get/set)

get_torque_enable

get_torque_enable(sid, callback=None)
  • Parameters
    • sid: Servo ID
    • callback: TBD
  • Response
    • None
get_torque_enable_async(sid, loop=None)
  • Parameters
    • sid: Servo ID
    • loop: TBD
  • Response
    • True (Torque ON)/False (Torque OFF)

set_torque_enable

TBE...

License

Generic Serial-bus Servo Driver library uses Apache License 2.0.

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

gs2d-0.0.4.tar.gz (25.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gs2d-0.0.4-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

Details for the file gs2d-0.0.4.tar.gz.

File metadata

  • Download URL: gs2d-0.0.4.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.10

File hashes

Hashes for gs2d-0.0.4.tar.gz
Algorithm Hash digest
SHA256 a88c56e1ddaeab0329b4ef5a66a13d30a7ac7b2d9885e90861a3c5be6bd9a575
MD5 2b1c094c48537dc26fd0f6fb02aa4ebb
BLAKE2b-256 266baad630855d3f25a2aa606e6d87b4dd654c1ece30831b08fd25e228f38583

See more details on using hashes here.

File details

Details for the file gs2d-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: gs2d-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 27.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.10

File hashes

Hashes for gs2d-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1ee73b83a7e0162ae7a462c4ba69da72c768e2707a5ab8ccdb9e8d715cf7cd51
MD5 76ad779ae3121fbf0ee64cb89a906f62
BLAKE2b-256 acdcdbbde417b882a475be0f701a0490e720373eea4fd49fb9040ada0e2b1efb

See more details on using hashes here.

Supported by

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