Skip to content

Set Unit

SUMMARY

Set Unit configures the measurement unit used for position, speed, and force parameters in subsequent gripper commands.

Robotiq automatically sets default units after connect ("mm" for position, "percent" for speed and force). Call set_unit only when a different unit is needed.

SUPPORTED GRIPPERS

Available on Robotiq (full unit selection: device, normalized, percent, mm) and OnRobot grippers (only position=mm and force=N accepted).

The Skill

python
gripper.set_unit("position", "mm")
gripper.set_unit("speed", "percent")
gripper.set_unit("force", "percent")

The Code

Example: Confirm Default Units After Connecting

Robotiq sets these units automatically on connect. Calling them explicitly improves readability.

python
"""
Robotiq 2F-85 set position unit example for the Synapse SDK.

Switches the gripper position unit between normalized (0..1) and mm.

Usage:
    python set_unit.py --ip <ROBOT_IP>
"""

import argparse
from loguru import logger

from telekinesis.synapse.tools.parallel_grippers import robotiq


def main(ip: str):
    """Switch the gripper position unit to normalized (0..1)."""

    # Create and connect to the gripper
    gripper = robotiq.Robotiq2F85()
    gripper.connect(ip=ip)

    try:
        gripper.set_unit(parameter='position', unit='normalized')
        logger.success("Position unit set to 'normalized'.")
    finally:
        gripper.disconnect()


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Robotiq gripper set_unit example")
    parser.add_argument("--ip", type=str, required=True, help="UR robot IP address")
    args = parser.parse_args()

    main(ip=args.ip)

The Explanation of the Code

set_unit declares the unit for a given parameter. The setting persists for the entire session and applies to all subsequent calls to move, open, close, get_current_position, set_speed, and set_force.

Supported units per parameter:

ParameterSupported units
"position""mm", "device" (0-255), "normalized" (0.0-1.0), "percent" (0-100)
"speed""device", "normalized", "percent"
"force""device", "normalized", "percent"

How to Tune the Parameters

Robotiq 2F-85

ParameterTypeDescription
parameterstrThe parameter to configure: "position", "speed", or "force".
unitstrPosition: "mm", "device" (0-255), "normalized" (0.0-1.0), "percent" (0-100). Speed / force: "device", "normalized", "percent".

OnRobot RG2 / RG6

ParameterTypeDescription
parameterstr"position" or "force" only. "speed" is not accepted.
unitstrPosition: "mm" only. Force: "N" only.

TIP

Prefer "mm" for position in production scripts - physical units are self-documenting and easy to validate against the gripper's datasheet.

WARNING

A ValueError is raised if an unsupported parameter or unit value is passed. set_unit requires an active connection - call it after connect.

Where to Use the Skill

  • Session initialization - Call once after connect when a non-default unit is needed
  • Unit switching - Re-call mid-session to switch between units for a specific subroutine

When Not to Use the Skill

Do not call set_unit when:

  • The default units are sufficient - after connect, position is already "mm" and speed/force are already "percent"