Skip to content

Get Runtime State

SUMMARY

Get Runtime State returns the current execution state of the program running on the robot controller as a brand-specific code.

UNITS

Returns a string code (no units), e.g. "PLAYING", "STOPPED", "PAUSED".

The Skill

python
runtime_state = robot.get_runtime_state()

The Code

Example: Read and Log Runtime State

Connect to the robot and read its current runtime state.

python
"""
Logs the controller's program runtime state.

Supports Universal Robots (UR).

Usage:
    python get_runtime_state.py [--ip <ROBOT_IP>]
"""

import argparse

from loguru import logger

from telekinesis.synapse.robots.manipulators import universal_robots


def main(ip: str | None) -> None:
    """Log the current runtime state."""

    #===================== Create Robot ==========================================
    robot = universal_robots.UniversalRobotsUR10E(name='UR10e')

    try:
        #===================== Connect Robot ==========================================
        if ip:
            robot.connect(ip=ip)

        # ==================== Run Skill ============================================
        logger.success(f"Runtime state: {robot.get_runtime_state()}")
    except (ConnectionError, OSError) as e:
        logger.error(f"Error occurred: {e}")
    finally:
        robot.disconnect()
        robot.shutdown()


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Read runtime state Synapse example")
    parser.add_argument("--ip", type=str, default=None,
                         help="UR robot IP address for real hardware, e.g. 192.168.1.100")
    args = parser.parse_args()

    main(ip=args.ip)

Running the Example

bash
python get_runtime_state.py --ip 192.168.1.100

For all options:

bash
python get_runtime_state.py --help

Parameter Configuration

This skill takes no input parameters.

Returns

TypeDescription
strCurrent program runtime state as a brand-specific code. On Universal Robots the underlying integer maps to "STOPPING", "STOPPED", "PLAYING", "PAUSING", "PAUSED", or "RESUMING".

Raises

ExceptionCondition
RuntimeErrorThe robot is not connected. Call connect() before reading the runtime state.
NotImplementedErrorCalled on a manipulator brand other than Universal Robots, where this getter is not yet implemented.

Where to Use the Skill

  • Program flow control - Check whether a controller program is running before issuing Python-side commands
  • State synchronization - Wait for the runtime state to reach STOPPED before reconnecting or restarting
  • Diagnostics - Log the runtime state alongside other telemetry during automated test runs

When Not to Use the Skill

Do not use Get Runtime State when: