Skip to content

Gripper Set Position Range

SUMMARY

Set Position Range configures the gripper's maximum finger separation in millimeters.

Robotiq2F85 automatically sets this to 85 mm after connect. Call set_position_range_mm only if you want to adjust the default stroke.

UNITS

position_range_mm in millimeters.

The Skill

python
gripper.set_position_range_mm(85.0)

The Code

Safety first!

A real robot will faithfully do whatever you ask of it - so please take a moment to clear the workspace, keep an E-Stop within reach, and be ready to disconnect.

Operating real hardware is at your own risk.

python
"""
Demonstrates setting the stroke range of a parallel gripper.

Supports OnRobot and Robotiq grippers, and Isaac Sim.

Usage:
    python set_position_range.py --ip <GRIPPER_IP>
    python set_position_range.py --prim_path <PRIM_PATH>

Note:
    Experimental gripper support for Isaac Sim:  Robotiq 2F85 (USD-based simulation only); Schunk EGP and
    PZN+ are.
"""

import argparse
from loguru import logger

from telekinesis.synapse.tools.parallel_grippers import onrobot


def main(ip: str | None,
         protocol: str,
         prim_path: str | None) -> None:
    """Sets the stroke range of an OnRobot gripper to 85 mm."""

    #===================== Create Gripper ======================================
    gripper = onrobot.OnRobotRG6()

    try:
        #===================== Connect Gripper =================================
        if prim_path:
            gripper.connect(simulation_prim_path=prim_path)
        else:
            gripper.connect(ip=ip, protocol=protocol)

        # ==================== Run Skill ====================================
        gripper.set_position_range_mm(position_range_mm=85.0)
        logger.success("Position range set to 85 mm.")
    except (ConnectionError, OSError) as e:
        logger.error(f"Error occurred: {e}")
    finally:
        gripper.disconnect()


if __name__ == "__main__":
    p = argparse.ArgumentParser(description="OnRobot gripper set position range")
    p.add_argument("--protocol",
                   choices=["MODBUS_TCP"],
                   default="MODBUS_TCP")
    p.add_argument("--ip", default=None, help="IP for OnRobot Gripper")
    p.add_argument("--prim_path", type=str, default=None,
                   help='Isaac Sim gripper prim path, e.g. "/World/onrobot_rg6"')
    args = p.parse_args()

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

Running the Example

bash
python set_position_range.py --ip 192.168.1.100
bash
python set_position_range.py --prim_path /World/onrobot_rg6

For all options:

bash
python set_position_range.py --help

Parameter Configuration

Robotiq 2F-85

ParameterTypeDefaultDescription
position_range_mmfloat85.0Maximum finger separation in mm. Set at initialization. Must be > 0.

OnRobot RG2 / RG6

ParameterTypeDefaultDescription
position_range_mmfloat-Maximum finger separation in mm. Set at initialization. Must be > 0.

Returns

This skill returns nothing (None).

Raises

Robotiq 2F-85

ExceptionCondition
TypeErrorposition_range_mm is not numeric
ValueErrorposition_range_mm is not positive, or the configured connection protocol is not supported
RuntimeErrorThe gripper is not connected

OnRobot RG2 / RG6

ExceptionCondition
TypeErrorposition_range_mm is not numeric
ValueErrorposition_range_mm is non-positive, or exceeds the installed model's physical stroke

How to Tune the Parameters

Each gripper model has a fixed physical stroke that position_range_mm must not exceed:

ModelPhysical stroke (mm)Default in subclass
Robotiq 2F-858585 (set at init)
OnRobot RG2110110 (set at init)
OnRobot RG6160160 (set at init)

Override the default only when the physical installation uses a different or restricted stroke - for example, to keep the fingers clear of nearby tooling or fixtures.

Where to Use the Skill

  • Custom stroke - Override when the physical installation differs from the model's datasheet stroke
  • Obstacle avoidance - Restrict the range to prevent fingers reaching nearby tooling or fixtures

When Not to Use the Skill

Do not call set_position_range_mm when:

  • Using "normalized", "percent", or "device" position units - the mm range only applies when the position unit is "mm"
  • Using the default 2F-85 stroke - Robotiq2F85 sets 85 mm automatically after connect