Skip to main content

Communicates data between dopl and devices

Project description

Data Communicator Client

Sends and receives data between clients connected to Dopl

Usage

# Robot
import threading
import time

from doplcommunicator import DoplCommunicator, ControllerData, RobotData

def on_joined_session(session_id: int):
    print('Joined session id', session_id)

def on_controller_data(controller_data: ControllerData):
    print('Controller data received', controller_data.toDict())

def run_loop(communicator):
    while(True):
        # Use sparingly as this causes a read lock
        controller_data = communicator.controller_data

        # Send pressure data to remote clients
        communicator.robot_data = RobotData(True, 0.4)

        # Apply controller data to robot

        time.sleep(0.01)

communicator = DoplCommunicator("http://localhost:3000")
communicator.on_joined_session(on_joined_session)
communicator.on_controller_data(on_controller_data)
communicator.connect()

threading.Thread(target=run_loop, args=(communicator))
# Robot Controller
import time
from doplcommunicator import DoplCommunicator, ControllerData, RobotData

def on_joined_session(session_id: int):
    print('Joined session id', session_id)

def run_loop(communicator):
    while(True):
        # Send controller data to clients
        x = y = z = rx = ry = rz = rw = 0
        communicator.controller_data = ControllerData(x, y, z, rx, ry, rz, rw)

        # Apply pressure data to controller
        pressure = communicator.robot_data.pressure
        # controller.apply_force(pressure)

        time.sleep(0.01)

communicator = DoplCommunicator("http://localhost:3000")
communicator.on_joined_session(on_joined_session)
communicator.connect()

threading.Thread(target=run_loop, args=(communicator))

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

doplcommunicator-1.0.23.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

doplcommunicator-1.0.23-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file doplcommunicator-1.0.23.tar.gz.

File metadata

  • Download URL: doplcommunicator-1.0.23.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for doplcommunicator-1.0.23.tar.gz
Algorithm Hash digest
SHA256 4d9173c8c569cf515b00be27a474fc7f3c47003eabd1292d4dc9f5afa1680a78
MD5 69e8df2dd93096120346d99371420889
BLAKE2b-256 a88366e48b2ab0044bf2d50a02bb606765b79ecec70f4062b736b85f6e10309e

See more details on using hashes here.

File details

Details for the file doplcommunicator-1.0.23-py3-none-any.whl.

File metadata

File hashes

Hashes for doplcommunicator-1.0.23-py3-none-any.whl
Algorithm Hash digest
SHA256 7a07f61581facd3a7106772f527c06efae24ddbf9a334ac35730aa87acb1e52e
MD5 ea22df2259e50a0f84e11dc76ff42964
BLAKE2b-256 4c8aab1b1594a3133517f62297f7545d20e9e7f6fcdab7b742930a6232d7128c

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