Skip to main content

Python API for controlling Techman (TM) robots via Listen Node — no TMScript required

Project description

pytmrobot

Python API for Techman (TM) Robots — control your TM robot without writing TMScript.

Python License: MIT

繁體中文說明文件 | Changelog


Features

Category Capabilities
Motion PTP, Line, Circle, relative moves, PVT trajectories
I/O Digital / analog output & input, batch read
State TCP position, joint angles, force, speed, snapshot
Force sensing TouchStop, Compliance, Force control (FTSensor)
Communication Modbus TCP read/write with named Presets
Vision Trigger vision jobs, read output poses
HMI Operator dialogs (choice + popup)
Multi-robot Each TMRobot instance is fully independent — run 12+ in parallel

Requirements

  • Python 3.10+
  • TM Robot running TMflow 1.80+ with a Listen Node in the flow
  • Network access to port 5890 on the robot controller

No external dependencies — only the Python standard library.


Installation

pip install pytmrobot

Or install from source:

git clone https://github.com/harry-techman/pytmrobot.git
cd pytmrobot
pip install -e .

Quick Start

from pytmrobot import TMRobot, CartPoint

with TMRobot("192.168.1.101") as robot:

    home = CartPoint(400, -100, 500, 180, 0, 90)   # X, Y, Z, Rx, Ry, Rz
    pick = CartPoint(400, -100, 280, 180, 0, 90)

    robot.move.ptp(home, speed=30)       # point-to-point move, 30 %
    robot.move.ptp(pick, speed=10)       # slow approach

    robot.io.set_do(2, True)             # close gripper (DO[2] = 1)
    robot.sleep(500)                     # wait 500 ms on robot side

    robot.move.ptp(home, speed=30)
    robot.io.set_do(2, False)            # open gripper

    pos = robot.state.tcp_position       # read current TCP pose
    print(f"Done — X={pos[0]:.1f}  Y={pos[1]:.1f}  Z={pos[2]:.1f} mm")

Sub-controllers

Property Description
robot.move PTP / Line / Circle / relative / PVT
robot.io DO, AO, DI, AI, batch read
robot.state TCP position, joints, force, speed, snapshot
robot.decision ask() choice dialog, popup() confirmation
robot.modbus Modbus TCP connect / preset / read / write
robot.touchstop TouchStop — detect contact and stop
robot.compliance Compliance — compliant motion until resistance
robot.force Force control with external FTSensor
robot.vision Trigger vision jobs, get output pose

More Examples

Read robot state

s = robot.state.snapshot()
print(s.tcp_position)   # (X, Y, Z, Rx, Ry, Rz)
print(s.joint_angles)   # (J1 … J6)
print(s.tcp_force_3d)   # resultant force N

TouchStop — find workpiece surface

result = robot.touchstop.run(
    direction=32,    # Z−  (1=X+, 2=X−, 4=Y+, 8=Y−, 16=Z+, 32=Z−)
    distance=50.0,   # max travel mm
    force=5.0,       # contact threshold N
    speed=10,
)
if result == 5:      # Resisted
    z = robot.touchstop.get_stopped_pos()[2]
    print(f"Surface at Z = {z:.2f} mm")

Multi-robot (12 concurrent)

from concurrent.futures import ThreadPoolExecutor

robots = [TMRobot(f"192.168.1.{100+i}") for i in range(12)]
for r in robots:
    r.connect()

with ThreadPoolExecutor(max_workers=12) as pool:
    futures = [pool.submit(run_task, r) for r in robots]
    for f in futures:
        f.result()

for r in robots:
    r.disconnect()

Modbus TCP

robot.modbus.connect("192.168.1.10")
robot.modbus.preset("light", 1, "DO", 7206, "bool")
robot.modbus.write("light", True)
print(robot.modbus.read_bool("light"))
robot.modbus.disconnect()

Vision-guided pick

if robot.vision.do_job("DetectPart"):
    pose = robot.vision.get_output_pose("DetectPart", "ArmPose_0")
    robot.move.ptp(CartPoint(*pose), speed=20)

Running Tests

pip install -e ".[dev]"
python -m pytest tests/ -v

All 259 tests run without a physical robot (mock-based unit tests).


Documentation

Full API reference and tutorials (繁體中文): docs/wiki.md


License

MIT — see LICENSE.

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

pytmrobot-0.1.0.tar.gz (51.0 kB view details)

Uploaded Source

Built Distribution

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

pytmrobot-0.1.0-py3-none-any.whl (46.0 kB view details)

Uploaded Python 3

File details

Details for the file pytmrobot-0.1.0.tar.gz.

File metadata

  • Download URL: pytmrobot-0.1.0.tar.gz
  • Upload date:
  • Size: 51.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for pytmrobot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cb53999bf1c70e9a5171feee6c880f0e90ef4fdadb68ec14c415d47c8815130a
MD5 89622486542a83fc153a7828f1af3d05
BLAKE2b-256 b6cd1b06083f468c67449cc12cb76d29af4b2b35f768b1038288f8fa21b083c8

See more details on using hashes here.

File details

Details for the file pytmrobot-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pytmrobot-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 46.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for pytmrobot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0129f5b3f789fb0b954faff4546cb383ee8e0a84a9833ef87b20fdd83572b591
MD5 115d6343d73977149a424762f3a46b0c
BLAKE2b-256 ea02bf5aac6ea1c802c9d72d5954bf714b8a8963fb06b0fcf55b3dfc534aa47a

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