Skip to main content

RI SDK Pythonic Wrapper

Project description

RI SDK wrapper (autogenerated)

Parse RI SDK docs (https://docs.robointellect.ru/) and autogen Python wrapper.

PyPI - Version PyPI - Status PyPI - Python Version Ruff Code style: black mypy codecov

TODO:

  • coverage for ri_sdk_codegen

Install

pip install ri-sdk

Run

Full example at examples/robohand-example.py.

Another example with RoboHand class at examples/robohand-class-example.py.

"""
Смотри полный пример в папке examples
"""
from ri_sdk import RoboIntellectSDK, contrib

lib = contrib.get_lib()
ri_sdk = RoboIntellectSDK(
    lib=lib,
    setup_methods_args=True,
)
ri_sdk.init_sdk(log_level=1)
# pwm_descriptor = init_pwm(ri_sdk)
pwm_descriptor = 0
# i2c_descriptor = init_i2c(ri_sdk, pwm_descriptor)
i2c_descriptor = 0
# led_descriptor = init_led(ri_sdk, pwm_descriptor)
led_descriptor = 0

# Устанавливаем фиолетовый цвет светодиода
ri_sdk.exec_rgb_led_single_pulse(
    descriptor=led_descriptor,
    r=255,
    g=0,
    b=255,
    duration=0,
    run_async=True,
)

# инициализируем сервоприводы
# init_servos(ri_sdk, pwm_descriptor)

# переводим сервоприводы в стартовое положение
# servos_to_start_position(ri_sdk)

servo_rotate_descriptor = 0
# поворачиваем башню на угол 60 со скоростью 30
ri_sdk.exec_servo_drive_turn_with_relative_speed(
    descriptor=servo_rotate_descriptor,
    # угол 60º
    angle=60,
    # скорость в градусах в секунду
    speed=30,
)

# готовимся к завершению, включаем красный свет
ri_sdk.exec_rgb_led_single_pulse(
    descriptor=led_descriptor,
    r=255,
    g=0,
    b=0,
    duration=0,
    run_async=True,
)

# Красиво завершаем работу через destruct
# destruct(
#     ri_sdk=ri_sdk,
#     led_descriptor=led_descriptor,
#     pwm_descriptor=pwm_descriptor,
#     i2c_descriptor=i2c_descriptor,
# )
ri_sdk.destroy_sdk(is_force=True)

Notes

Docs typo? sensor_voltage_sensor_read_reg_bytes read length is output type... but it's not

Codegen

Install dependencies

poetry install

Full RI SDK codegen:

main.py --update-links --parse-docs --remove-unknown-methods-cache --generate-sdk

Each stage can be used separately:

  • --update-links
  • --parse-docs [--remove-unknown-methods-cache]
  • --generate-sdk

Add -v flag for verbose output.

Testing

Run tests

hatch run test:run

Run coverage

hatch run test:cov

Run coverage and export html report

hatch run test:cov-html

Download files

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

Source Distribution

ri_sdk-1.1.0.tar.gz (38.2 kB view hashes)

Uploaded Source

Built Distribution

ri_sdk-1.1.0-py3-none-any.whl (67.1 kB view hashes)

Uploaded Python 3

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