Skip to content

Get Joint Positions

SUMMARY

Get Joint Positions returns the current joint angles in degrees, one per joint, ordered base to wrist. Reads from the manipulator state - live values when connected, the last commanded joint configuration offline.

SUPPORTED ROBOTS

Available on all supported manipulators in offline mode. Live hardware readings are currently supported only on Universal Robots.

UNITS

Returns joint positions in degrees, ordered base to wrist.

The Skill

python
joint_positions = robot.get_joint_positions()

The Code

python
"""
Read joint positions example for the Synapse SDK.

Returns the manipulator's joint positions [deg]. With ``--ip``, reads live
hardware state. Without ``--ip``, reads from the internal commanded cache
(no connection made) and logs a warning.

Illustrated using Universal Robots (UR10e), supported on all robots.

Usage:
    python get_joint_positions.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 joint positions [deg]."""

    # Create the robot instance
    robot = universal_robots.UniversalRobotsUR10E()

    # Connect if --ip was provided, otherwise read from the commanded cache
    if ip is not None:
        robot.connect(ip=ip)
    else:
        logger.warning(
            "No --ip provided; reading offline commanded-cache state, "
            "not live hardware readings."
        )

    try:
        logger.success(f"joint_positions [deg]: {robot.get_joint_positions()}")
    finally:
        if ip is not None:
            robot.disconnect()


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Read joint positions Synapse example")
    parser.add_argument("--ip", type=str, default=None, help="UR robot IP address (optional)")
    args = parser.parse_args()

    main(ip=args.ip)

The Explanation of the Code

python
from telekinesis.synapse.robots.manipulators import universal_robots

robot = universal_robots.UniversalRobotsUR10E()

Create the robot. UR10e is used here for illustration; the same pattern works for every supported brand.

python
if ip is not None:
    robot.connect(ip=ip)

Connect to the robot at the given IP. When no --ip is passed, no connection is made and the getter returns from the offline commanded-cache instead of live hardware.

python
logger.success(f"joint_positions [deg]: {robot.get_joint_positions()}")

Read the joint angles in degrees, ordered base to wrist. When connected, this is the live measurement; offline it returns the last commanded configuration (whatever set_joint_positions, the IK of set_cartesian_pose, or the default joint configuration last cached).

python
finally:
    if ip is not None:
        robot.disconnect()

Always release the controller link in a finally block so a failure mid-read still cleans up the connection.

Return Value

TypeDescription
list[float]Joint angles in degrees, one value per joint, ordered base to wrist.

Where to Use the Skill

  • Feedback control - Sample joint state at each control step to close a position loop.
  • Relative motion - Read current positions and apply an offset before calling set_joint_positions.
  • State logging - Record the joint configuration at key points in a task sequence.

When Not to Use the Skill