Skip to main content

The official python client interface for ProtoTwin Connect.

Project description

ProtoTwin Connect Client

This package provides a simple client that can be used to interface with ProtoTwin Connect.

Basic Example

# STEP 1: Import the ProtoTwin client
import prototwin
import asyncio
import os
import math

# STEP 2: Define your signal addresses (obtain these from your ProtoTwin model)
simulation_time_address = 0
motor_target_velocity_address = 3

async def main():
    # STEP 3: Start ProtoTwin Connect, load and initialize the model
    path = os.path.join(os.path.dirname(__file__), "example.ptm")
    client = await prototwin.start()
    await client.load(path)
    await client.initialize()

    # STEP 4: Create the simulation loop
    while True:
        t = client.get(simulation_time_address) # Read signal values
        client.set(motor_target_velocity_address, math.sin(t)) # Write signal values
        await client.step() # Step the simulation forward in time

asyncio.run(main()) # Run the simulation loop

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

prototwin-0.2.2.tar.gz (5.1 kB view details)

Uploaded Source

File details

Details for the file prototwin-0.2.2.tar.gz.

File metadata

  • Download URL: prototwin-0.2.2.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for prototwin-0.2.2.tar.gz
Algorithm Hash digest
SHA256 bc09d4a813f6f25c7b72836e44707cf158cfbccd7e78ab207e5839613f7efbee
MD5 00bf861b262a222f3f98adf7249b4948
BLAKE2b-256 641e710e698a88b601281c467169354c0df481a00896b50fd306c1a354908928

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