Gripper Get Current Position
SUMMARY
Get Current Position reads the current finger separation of the gripper in the configured position unit (default: millimeters).
UNITS
Returns finger separation in the configured position unit (default mm after connect).
The Skill
python
position = gripper.get_current_position()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 reading the current position of a parallel gripper.
Supports OnRobot and Robotiq grippers, and Isaac Sim.
Usage:
python get_current_position.py --ip <GRIPPER_IP>
python get_current_position.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:
"""Reads the current position of an OnRobot gripper in the configured unit."""
#===================== 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 ====================================
logger.success(f"Current position: {gripper.get_current_position()}")
except (ConnectionError, OSError) as e:
logger.error(f"Error occurred: {e}")
finally:
gripper.disconnect()
if __name__ == "__main__":
p = argparse.ArgumentParser(description="OnRobot gripper get current position")
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 get_current_position.py --ip 192.168.1.100bash
python get_current_position.py --prim_path /World/onrobot_rg6For all options:
bash
python get_current_position.py --helpParameter Configuration
This skill takes no input parameters.
Returns
| Type | Description |
|---|---|
float | Current finger separation in the configured position unit. |
Raises
| Exception | Condition |
|---|---|
RuntimeError | The gripper is not connected |
How to Tune the Parameters
Compare the returned position against a threshold rather than an exact value - hardware-level variation means the reading will vary slightly between calls.
Where to Use the Skill
- Grasp verification - Confirm an object is held before transporting
- State inspection - Read gripper position at any point in a workflow for logging or branching logic
- Closed-loop control - Combine with
moveto implement position-feedback loops
When Not to Use the Skill
Do not use Get Current Position when:
- The gripper is not connected - always call
connectbefore issuing gripper commands - High-frequency polling is required - repeated queries add latency; use asynchronous motion and a single readback instead