Isaac Sim × Modbus TCP: Remote Control of the OnRobot 2FG7 Gripper from TMFlow
Introduction
"Take the program validated in simulation and deploy it directly to the real hardware" — this is the ideal in robot development.
This article introduces how to build a system that controls the OnRobot 2FG7 gripper in ISAAC Sim from TMFlow using the Modbus TCP protocol. Because the system implements the exact same Modbus register map as the physical 2FG7, gripper control programs written in TMFlow can be used as-is from simulation all the way to real hardware deployment.
Note: The code in this article is a simplified proof-of-concept (PoC) version. For production use, please add proper error handling, security measures, and logging.
System Overview
Components
The system consists of three main components:
-
Modbus TCP Server (running inside Isaac Sim)
- Receives gripper commands
- Controls the gripper within the simulation
- Returns status information
-
Isaac Sim Simulation Environment
- Physics simulation of the TM5 robot arm + 2FG7 gripper
- Real-time physics computation
-
Client (TMFlow or a test client)
- Sends Modbus commands
- Controls gripper open/close
Architecture Diagram
┌─────────────────┐ Modbus TCP ┌─────────────────┐
│ │ (Port 5020) │ │
│ TMFlow │◄──────────────────────────────┤ Modbus Server │
│ (Robot PC) │ │ (Isaac Sim) │
│ │───────────────────────────────►│ │
└─────────────────┘ Commands / Status └────────┬────────┘
│
│ Control
▼
┌─────────────────┐
│ 2FG7 Gripper │
│ Simulation │
└─────────────────┘
About the Modbus Protocol
What is Modbus?
Modbus is a widely used standard communication protocol for industrial equipment. Its simplicity and reliability, combined with ease of integration with PLCs and robot controllers, have made it popular in factory automation (FA).
Register Mapping
This system implements the following register map based on the physical OnRobot 2FG7 specifications:
Output Registers (for Commands)
| Address | Name | Description | Range |
|---|---|---|---|
| 0 | rGFR | Grip force | 0-255 (0-100N) |
| 1 | rGWD | Gripper width | 0-1600 (0-160.0mm) |
| 2 | rCTR | Control command | 16=Execute, 0=Stop |
Input Registers (for Status)
| Address | Name | Description |
|---|---|---|
| 258 | gOBJ | Object detection state |
| 259 | gSTA | Status |
| 260 | gGTO | Motion state |
| 261-275 | - | Other status info |
Implementation Details
Python + pymodbus
The server side is implemented in Python using the pymodbus library to build the Modbus TCP server.
Version note: The code below uses pymodbus v2.x syntax. From v3.x onwards, import paths have changed (
pymodbus.server.sync→pymodbus.server). Adjust accordingly for your installed version.
# Modbus server initialization (simplified)
from pymodbus.server.sync import StartTcpServer
from pymodbus.datastore import ModbusSequentialDataBlock
# Create register blocks
output_block = ModbusSequentialDataBlock(1, [0]*3) # for commands
input_block = ModbusSequentialDataBlock(259, [0]*18) # for status
# Start the server
StartTcpServer(context=server_context, address=("0.0.0.0", 5020))
Integration with Isaac Sim
The Isaac Sim Articulation API is used to directly control gripper joints:
# Convert gripper width to joint position
def width_to_joint_position(width_mm):
return (width_mm / 1000.0) / 2.0 # Move each finger half the total width
# Set joint positions
positions = gripper.get_joint_positions()
positions[left_joint_idx] = target_position
positions[right_joint_idx] = target_position
gripper.set_joint_positions(positions)
Multithreaded Processing
Due to PhysX constraints, synchronization between the physics thread and the control thread is critical. This system uses:
- Modbus Server: Background thread
- Control Loop: Polls commands at 50 Hz (20 ms intervals)
- Physics: Automatically managed by Isaac Sim's Timeline
# Run asynchronously as daemon threads
modbus_thread = threading.Thread(target=modbus_server.start, daemon=True)
control_thread = threading.Thread(target=control_loop, daemon=True)
Re-initialization Mechanism
To handle physics view invalidation that occurs when the simulation is stopped and restarted, an automatic re-initialization feature is implemented:
def _check_physics_ready():
if simulation_playing and physics_view_invalid:
gripper.initialize() # Recreate the physics view
return retry_command()
How to Use
1. Starting the Server
Run the server script from Isaac Sim's Script Editor:
Window → Script Editor → Open → fg7_isaac_sim_modbus_control.py → Run
Successful startup message:
✓ Control loop running in background
Server listening on 0.0.0.0:5020
Ready to receive gripper commands!
2. Control from TMFlow
Modbus Device Setup
- Settings → Communication → Modbus
- Add a TCP Client
- Enter the IP address and port 5020
Gripper Commands
Close:
Set Node (Modbus)
Register Type: Holding Register
Address: 0
Values: [100, 0, 16]
Open (160mm):
Set Node (Modbus)
Register Type: Holding Register
Address: 0
Values: [100, 1600, 16]
Custom width (80mm):
Set Node (Modbus)
Register Type: Holding Register
Address: 0
Values: [100, 800, 16]
3. Pick & Place Example
A typical workflow in TMFlow:
[Start]
↓
[PTP] Move to home position
↓
[Modbus Write] Open gripper [100, 1600, 16]
↓
[Delay] 1000ms (wait for gripper motion)
↓
[PTP] Move above pick position
↓
[Line] Descend to pick position
↓
[Modbus Write] Close gripper [100, 0, 16]
↓
[Delay] 1000ms (wait for grasp)
↓
[Modbus Read] Check status (Address: 258)
↓
[If] Object grasped successfully?
↓
[Line] Lift up
↓
[PTP] Move to place position
↓
[Modbus Write] Open gripper [100, 1600, 16]
↓
[Delay] 500ms
↓
[PTP] Return to home position
↓
[End]
Technical Challenges and Solutions
1. PhysX Thread Contention
Problem: Physics API calls from background threads cause race conditions
Solution:
- Update joint positions only upon command receipt
- Avoid continuous updates
- Implement physics readiness checks and retry logic
2. Physics View Invalidation
Problem: The Articulation physics view becomes invalid when the simulation is restarted
Solution:
- Monitor physics state
- Automatic re-initialization mechanism
- Queue pending commands
3. Modbus Addressing
Problem: pymodbus uses 1-based addressing
Solution:
# Modbus address 0 = data block index 1
output_block = ModbusSequentialDataBlock(1, [0]*3)
# Modbus address 258 = data block index 259
input_block = ModbusSequentialDataBlock(259, [0]*18)
Performance
- Latency: ~20–50 ms (including network delay)
- Update rate: 50 Hz (control loop)
- CPU usage: Low (daemon threads)
- Network: TCP/IP over Ethernet
Benefits of This Approach
Compatibility with Real Hardware
Because the system uses the same Modbus protocol as the actual OnRobot 2FG7 gripper, programs tested in simulation can be deployed directly to real hardware. This greatly shortens the development → validation → deployment cycle.
Remote Control
Network-based control allows multiple PCs to access the simulation simultaneously, or operate it from physically remote locations.
TMFlow Integration
Direct control from TMFlow — the standard development environment for TM robots — requires no additional tools or learning.
Industry-Standard Protocol
Modbus is an industrial standard, making it applicable to integration with a wide range of systems including PLCs, SCADA, and HMI.
Use Cases
- Virtual Commissioning: Validate robot programs before real hardware deployment — check cycle times and interference in advance
- Operator Training: Train robot operation in a safe virtual environment
- Algorithm Development: Rapidly validate vision system and path planning algorithms in simulation
- Digital Twin: Run the real hardware and simulation in parallel to compare and verify behavior
System Requirements
- OS: Ubuntu 24.04 (recommended)
- Python: 3.10 or later
- Isaac Sim: 4.x / 5.x
- pymodbus: 2.5.3 or later (change import paths for v3.x)
- Network: TCP/IP, port 5020 (customizable)
Conclusion
The Isaac Sim gripper control system using Modbus TCP effectively bridges the gap between simulation and real hardware. The ability to take programs written in TMFlow and deploy them directly to physical robots is a significant advantage in real-world environments.
If you are considering robot validation or PoC development using Isaac Sim in your work, please also check out the Robotics Simulation Service page.
