Skip to main content

Python library for applications to interact with ROV (Remotely Operated Vehicle) systems over WebSocket

Project description

HydroWire

A Python library for applications to interact with HydroWire devices (ROV / robot peripherals) over WebSocket.

Installation

From PyPI (Recommended)

pip install hydrowire

From Source (Development)

git clone https://github.com/yourusername/hydrowire.git
cd hydrowire
pip install -e .

Features

  • 🔌 WebSocket Communication: Send JSON commands to ROV devices
  • 🎯 Device Targeting: Route commands to specific devices using device IDs
  • ⚙️ Async-First Design: Built on asyncio for efficient concurrent operations
  • 🎨 GUI Ready: Framework for integrating graphical interfaces
  • 📦 Library-First: Designed to be embedded in main applications

Installation

pip install -r requirements.txt

For development:

pip install -r dev-requirements.txt

Quick Start

Basic Usage

import asyncio
from hydrowire import HydroWireManager as ROVManager

async def main():
    # Initialize manager
    manager = ROVManager("ws://localhost:8000")
    
    # Start communication
    await manager.start()
    
    try:
        # Send a command to a device
        response = await manager.send_command(
            device_id="arm_1",
            command={"action": "move", "position": 45},
            expect_response=True
        )
        print(response)
    finally:
        await manager.close()

asyncio.run(main())

Using the Global Start Function

import asyncio
from hydrowire import start

async def main():
    # Quick start with convenience function
    manager = await start("ws://localhost:8000")
    
    try:
        await manager.send_command(
            device_id="camera_main",
            command={"action": "capture"}
        )
    finally:
        await manager.close()

asyncio.run(main())

API Reference

ROVManager

The main class for interacting with ROV systems.

Initialization

manager = ROVManager(rov_uri, timeout=10.0)
  • rov_uri (str): WebSocket URI for ROV (e.g., ws://localhost:8000)
  • timeout (float): Command timeout in seconds (default: 10.0)

Methods

async initialize(): Initialize connection to ROV

async start(gui_enabled=False, **gui_config): Start the ROV manager and optionally launch GUI

async send_command(device_id, command, expect_response=False): Send a command to a device

  • device_id (str): Target device identifier (e.g., "arm_1", "camera_main")
  • command (dict): Command object with action and parameters
  • expect_response (bool): Wait for response if True
  • Returns: Response dict if expect_response=True, otherwise None

async close(): Close ROV connection

async run(gui_enabled=False, **gui_config): Run manager in blocking mode

attach_gui(gui_app): Attach GUI application instance

register_command_handler(command_type, handler): Register custom command handler

Global Functions

async start(rov_uri, gui_enabled=False, **gui_config): Convenience function to create and start a manager

async get_manager(): Get the global manager instance

Command Structure

Commands are sent with a structured format where parameters are grouped under a params key:

Your code:

await manager.send_command(
    device_id="led",
    command={"action": "pwm", "duty_cycle": 0.5, "enable": true}
)

What gets sent over WebSocket:

{
  "device": "led",
  "cmd": "pwm",
  "params": {
    "duty_cycle": 0.5,
    "enable": true
  }
}

This structured format makes it easy for the ROV backend to:

  • Route commands to the correct device
  • Access the command type directly
  • Parse all parameters from a single params object

Running Tests

pytest tests/ -v

Examples

See the examples/ directory for more detailed usage patterns.

Architecture

  • rov_lib/client.py: Low-level WebSocket client
  • rov_lib/manager.py: High-level manager with device routing
  • rov_lib/__init__.py: Package exports

Future Enhancements

  • GUI framework integration
  • Device discovery and management
  • Command queuing and priority
  • Connection recovery and reconnection
  • Telemetry and logging

License

(To be determined)

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

hydrowire-0.0.7.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

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

hydrowire-0.0.7-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file hydrowire-0.0.7.tar.gz.

File metadata

  • Download URL: hydrowire-0.0.7.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for hydrowire-0.0.7.tar.gz
Algorithm Hash digest
SHA256 e2468937669ae36b0064dad73e6dfb82f353a3cdeff53d52e3d56ea4c7e56ab7
MD5 ccb0772422a0f6e4add65bfc6687936c
BLAKE2b-256 19f3b664a320256a1a2fd22d872ed8e09132b4130a9213079f8ff4feeb727a4c

See more details on using hashes here.

File details

Details for the file hydrowire-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: hydrowire-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for hydrowire-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 6abf8991c5769c887a87c3a22ccb91149b2100c5dc51560971ceb60ac133cf55
MD5 9fe975a8e20281dd645b3b596e039adc
BLAKE2b-256 49a75b04c56889b8f26ea948f833ba4d6ae5aa69befca4080b1e2c88e9530835

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