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.10.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

doplcommunicator-1.0.10-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: doplcommunicator-1.0.10.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for doplcommunicator-1.0.10.tar.gz
Algorithm Hash digest
SHA256 745e711008a6416d72cbb0726d9ae105bec560fc41d51d4783104d96cf2f97b6
MD5 33c86ea8fa461af5a045cdb3299bfaf4
BLAKE2b-256 594f4e18d1b6f4df9792096f6dc28f36851ddaab938d66b41165a0b0faf0e541

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for doplcommunicator-1.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 e30d169a74978bfa7cf8cc4ce375abe0119d77e130add8f2ea2abd008b5bc162
MD5 f7a0f8af306ec6da03ab2c982b1d4682
BLAKE2b-256 0c5550b7941527c4c5378585ff7f9056b4f0f82688905bec41c85e4a257c6206

See more details on using hashes here.

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