Skip to content

In Joint Limits ​

SUMMARY

In Joint Limits checks whether a candidate joint configuration lies within the robot's configured per-joint lower and upper bounds, bounds included. Use it as a guard before sending a joint target to the controller or before running motion planning.

UNITS

Input joint configuration q in degrees. Returns a boolean.

The Skill ​

python
ok = robot.in_joint_limits(q=q, verbose=False)

The Code ​

Example: Check Joint Configurations Against Limits ​

Check the robot's current joint configuration and an out-of-range configuration.

python
"""
Checks whether joint configurations lie within the limits derived from the robot's URDF.

Supports Universal Robots (UR), Epson, virtual, and Isaac Sim.

Usage:
    python in_joint_limits.py [--ip <ROBOT_IP>] [--prim_path <PRIM_PATH>]
    python in_joint_limits.py --save-rrd in_joint_limits.rrd
"""

import argparse

import rerun as rr
from loguru import logger

from telekinesis.synapse.robots.manipulators import universal_robots


def init_rerun(app_id: str, save_rrd: str | None) -> "rr.RecordingStream":
    """Start a Rerun recording, live in the viewer or saved to an .rrd file."""
    rr.init(app_id, spawn=save_rrd is None)
    recording = rr.get_global_data_recording()
    if save_rrd:
        recording.save(save_rrd)
    return recording


def main(ip: str | None, prim_path: str | None, save_rrd: str | None) -> None:
    """Check the robot's current joint configuration and an out-of-range one."""

    #===================== Start Rerun ==========================================
    recording = init_rerun("telekinesis_synapse_in_joint_limits", save_rrd)

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

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

        # ==================== Run Skill ============================================
        current_joint_positions = robot.get_joint_positions()
        current_within_limits = robot.in_joint_limits(q=current_joint_positions, verbose=True)
        logger.success(f"Current joint positions within limits: {current_within_limits}")

        out_of_range = robot.joint_limits[:, 1] + 10.0  # 10 deg past every upper limit
        out_of_range_within_limits = robot.in_joint_limits(q=out_of_range, verbose=True)
        logger.info(
            f"Configuration past the upper limits within limits: {out_of_range_within_limits}"
        )

        # ==================== Visualization (Optional) =============================
        # The robot is drawn once at its current configuration, and both results are listed
        # beside it.
        robot.visualize_rerun(recording_stream=recording, live=False)
        labels = [
            f"current configuration within limits: {current_within_limits}",
            f"10 deg past the upper limits within limits: {out_of_range_within_limits}",
        ]
        label_positions = [[0.0, -0.5, 0.8 - 0.1 * i] for i in range(len(labels))]
        rr.log("/in_joint_limits", rr.Points3D(label_positions, labels=labels, radii=0.005))
    except (ConnectionError, OSError) as e:
        logger.error(f"Error occurred: {e}")
    finally:
        robot.disconnect()
        robot.shutdown()


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Check whether joint configurations lie within limits")
    parser.add_argument("--ip", type=str, default=None,
                         help="UR robot IP address for real hardware, e.g. 192.168.1.100")
    parser.add_argument("--prim_path", type=str, default=None,
                         help='Isaac Sim articulation prim path, e.g. "/World/ur10e"')
    parser.add_argument("--save-rrd", type=str, default=None,
                         help="Save the Rerun recording to this .rrd file instead of opening the viewer")
    args = parser.parse_args()

    main(ip=args.ip, prim_path=args.prim_path, save_rrd=args.save_rrd)

Rerun output ​

The viewer shows the UR10e at its current joint configuration, with both results listed beside it: whether the current configuration is within the limits, and whether a configuration 10 degrees past every upper limit is. Pass --save-rrd in_joint_limits.rrd to save the recording instead of opening the viewer, and open it later with rerun in_joint_limits.rrd.

Running the Example ​

bash
python in_joint_limits.py
bash
python in_joint_limits.py --prim_path /World/ur10e
bash
python in_joint_limits.py --ip 192.168.1.100

To save the Rerun recording to a file instead of opening the viewer:

bash
python in_joint_limits.py --save-rrd in_joint_limits.rrd

For all options:

bash
python in_joint_limits.py --help

Parameter Configuration ​

ParameterTypeDefaultDescription
qnp.ndarray-1D joint configuration in degrees. Length must match the number of joints on the robot.
verboseboolFalseIf True, log a warning for each joint value that violates its limit.

Returns ​

TypeDescription
boolTrue if every joint value lies within its configured [lower, upper] bounds, bounds included, False otherwise.

Raises ​

ExceptionCondition
ValueErrorq is not a 1D vector, or its length does not match the number of configured joints

How to Tune the Parameters ​

in_joint_limits returns True when every value in q is within its configured bounds (lower <= q <= upper); a joint exactly at its limit is within limits. The check always uses the physical limits in robot.joint_limits. The inverse kinematics margin set with robot.set_ik_joint_limit_margin (see Inverse Kinematics) does not apply.

Set verbose=True when diagnosing why an IK solution or planned waypoint is being rejected: it logs a warning per offending joint with its name, index, and configured lower/upper bound, rather than just the aggregate bool.

Where to Use the Skill ​

  • Pre-flight validation - Reject joint targets that would violate the configured limits before sending them to the controller
  • IK post-processing - Filter IK solutions to keep only configurations inside the joint envelope
  • Motion planning - Validate sampled or interpolated waypoints during planning
  • Diagnostics - Use verbose=True to surface which joint is the offender when a target is rejected

When Not to Use the Skill ​

Do not use In Joint Limits when: