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.2.tar.gz (73.3 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.2-py3-none-any.whl (63.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytmrobot-0.2.2.tar.gz
  • Upload date:
  • Size: 73.3 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.2.tar.gz
Algorithm Hash digest
SHA256 449e685cb5f7a9f2e842501e7106bc76e2a4f05a377ac0fdefb1c417a04172fd
MD5 e90c1f2dd695687a5484dd6fa632ccc9
BLAKE2b-256 a6a9654ed5f56393a5fda9b34ab02059136fa8cccf4604a7b16a781640a0d7c0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytmrobot-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 63.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 32bc5ff78674f59a905dfc4bbe80bac01f77209d31fa977b27864790e18a49d3
MD5 d5f7dac8cc991d570421047d7864e571
BLAKE2b-256 cd7a3a6350a4aeeef722322dbd4df93901e9f3c2e47ef2ffa5673b1f45a78114

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