Skip to main content

A Python library for controlling HexDevice robots and devices

Project description

Hex Device Python Library

中文 | English

Overview

This library provides a simple interface for communicating with and controlling Hex devices. It uses Protocol Buffers for message serialization and WebSocket for real-time communication. The supported hardware list is as follows:

Prerequisites

  • Python 3.9 or higher
  • Anaconda Distribution (recommended for beginners) - includes Python, NumPy, and commonly used scientific computing packages

Installation

Install from PyPI (Recommended)

pip install hex_device

Clone the Repository (Development)

git clone --recurse-submodules https://github.com/hexfellow/hex_device_python.git

Quickstart

If you have already installed the library from PyPI using pip, please refer to Usage

Install protoc

  1. Install protoc from package manager (Recommended only for Debian13/Ubuntu24.04)

    sudo apt install protobuf-compiler
    
  2. Install protoc from Github Releases (Recommended Ubuntu22.04 and below)

    Just choose a suitable version and install it. Here below is an example of installing protoc-27.1.

    # For Linux x86_64
    wget https://github.com/protocolbuffers/protobuf/releases/download/v27.1/protoc-27.1-linux-x86_64.zip
    sudo unzip protoc-27.1-linux-x86_64.zip -d /usr/local
    rm protoc-27.1-linux-x86_64.zip
    
    # For Linux arm64
    wget https://github.com/protocolbuffers/protobuf/releases/download/v27.1/protoc-27.1-linux-aarch_64.zip
    sudo unzip protoc-27.1-linux-aarch_64.zip -d /usr/local
    rm protoc-27.1-linux-aarch_64.zip
    
    # Verify installation
    protoc --version # Should be or more than 3.21.12
    

Install hex_device

Compile Protocol Buffer messages:

mkdir ./hex_device/generated
protoc --proto_path=proto-public-api --python_out=hex_device/generated proto-public-api/*.proto && cp ./proto-public-api/version.py ./hex_device/generated/version.py

Option 1: Package Installation

To install the library in your Python environment:

python3 -m pip install .

Option 2: Direct Usage (No Installation)

If you prefer to run the library without installing it in your Python environment:

  1. Install dependencies:

    python3 -m pip install -r requirements.txt
    
  2. Add the library path to your script:

    import sys
    sys.path.insert(1, '<your project path>/hex_device_python')
    sys.path.insert(1, '<your project path>/hex_device_python/hex_device/generated')
    

Usage

  • The complete function interfaces can be found in our wiki. If you are new to the library, we strongly recommend skimming the available control interfaces first.
  • If you are using a robotic arm, you can refer to the docs for the controller port instructions.

Examples

Basic Usage

IPv4 connection:

python3 tests/main.py --url ws://0.0.0.0:8439

IPv6 connection:

python3 tests/main.py --url ws://[fe80::500d:96ff:fee1:d60b%3]:8439

Q&A

How do I connect using IPv6?

You can connect to our devices using IPv6, which enables direct connection without a router (e.g., using a single cable to connect the robot and PC).

Note: We assume you have basic knowledge about IPv6. If you don't, please use IPv4 instead. We will not explain IPv6 in detail.

Key points:

  • Without DHCP6, devices can still have a link-local address
  • To use link-local addresses, you must specify the zone ID of the interface using the % symbol
  • You can find the zone ID of the interface by running ip a

Example:

# Find the interface and zone ID
ip a

# Use the zone ID in the connection URL
ws://[fe80::500d:96ff:fee1:d60b%3]:8439

Why did a previously working software package stop working after a redeployment?

Please check the Change log to see if you are using cross-version software packages. Additionally, we recommend that you use a fixed software version after successful deployment to avoid code failures due to incompatible updates.

If I want to use newer software packages, how do I perform hardware upgrades?

Please contact our after-sales service, and we will provide hardware upgrade instructions based on the equipment you purchased.


Copyright © 2025-present Hexfellow Org

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

hex_device-1.4.4b1.tar.gz (95.0 kB view details)

Uploaded Source

Built Distribution

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

hex_device-1.4.4b1-py3-none-any.whl (90.4 kB view details)

Uploaded Python 3

File details

Details for the file hex_device-1.4.4b1.tar.gz.

File metadata

  • Download URL: hex_device-1.4.4b1.tar.gz
  • Upload date:
  • Size: 95.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for hex_device-1.4.4b1.tar.gz
Algorithm Hash digest
SHA256 035d19e5e05d2a018f836da7db25b836f267740141700a424dbd4a3e220042cf
MD5 fb946eca130b6d32b776ffbc97944950
BLAKE2b-256 de3195391da7c47916c443f44c0b41cd56d17de35a9a670a28d6471ce8551d5c

See more details on using hashes here.

File details

Details for the file hex_device-1.4.4b1-py3-none-any.whl.

File metadata

  • Download URL: hex_device-1.4.4b1-py3-none-any.whl
  • Upload date:
  • Size: 90.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for hex_device-1.4.4b1-py3-none-any.whl
Algorithm Hash digest
SHA256 21d3e718f69a88dfcafd7be75f1d75e77df3cc1683514e225dfe1f947a3c1fb0
MD5 14d0b20ee5d5c5abecf5281fe6bbb084
BLAKE2b-256 ceb42f12213db396cb3ff8ba5b61ad76e41b3619e1c252e07587cae08f0df319

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