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.2.0.tar.gz (64.4 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.2.0-py3-none-any.whl (57.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pytmrobot-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9100c538285caa88c5e543e7a7e4efdeaa69699dab412ee3f53db092a88975e2
MD5 805de70a6b31d6c70360541317d76bbf
BLAKE2b-256 611d9af97e552dc803a0bfdcbf184fef678d2fa4fbe9519d470e36c5e79ff931

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytmrobot-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 57.6 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0b22ab11311b243182abdeffae75054920f385938a746605470b63c1dfecebf
MD5 ca6c2faddc0ae351b9712bf3b4944135
BLAKE2b-256 109126cdc243554b32c9bb2d4ae7390ba5a0011ac9cbf58a6d36c3ea91c94de0

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