DoF - a Robotiq Community
Warning sign
The Dof Community was shut down in June 2023. This is a read-only archive.
If you have questions about Robotiq products please reach our support team.
bcastets

s0972456 said:
Hi, wonder if you have any update on that, still haven't figured out a way to control the epick remotely. Thanks
I did not had time to work on this. Will try to do something next week.

learningrobot

bcastets said:
Here is the Zip file with the python program.
Hi @bcastets
In your sample, what is the driver for the gripper? Was it on Ubuntu or Windows? Is the code still working?
I tried to follow the ROS library at http://wiki.ros.org/robotiq, but failed at Modbus TCP installation, as it said "Rosdep cannot find all required resouces of robotiq_modbus_tcp. How to configure it btw? 

Thanks,

bcastets

I got a question from @rsalehzadeh in a private message about how to open and close the gripper using python and modbus TCP.
From what I understand @rsalehzadeh manage to execute the code provided in this article and succesfully activate his gripper.

To control the gripper you have to write what you want him to do in its memory registers. Those memory registers are described in the griper manual.

Here below is a simple description of the program.

First the Modbus TCP connection with the gripper is established.

# Setup parameters of the Modbus TCP connection
c = ModbusClient(host=MODBUS_SERVER_IP, port=502, auto_open=True)
c.host(MODBUS_SERVER_IP)
c.port(502)
c.unit_id(9)
#Open the connection with the gripper
c.open()
#Wait for the connection to establish
time.sleep(5)

Then some data in written gripper registers to initiate activation.

#Write output register to request and activation
response=c.write_multiple_registers(0,[0b0000000100000000,0,0])

zoom


zoom

With this command, we write the 3 first registers. Each register is composed of 2 bytes.

Registers 1 and 2 are set to 0. There is nothing specific we do with does registers. Just set it at 0.
Register 0 is the important register here. In register 0, there are 2 bytes. Byte 1 is reserved which means that there is nothing we can do with it. Byte 0 is ACTION REQUEST Byte. The Bit 0 of ACTION REQUEST byte is the rACT bit which will trigger the gripper activation if it is set to 1. This is what we are doing here:

response=c.write_multiple_registers(0,[0b0000000100000000,0,0])

Register 0 : 00000001(Byte 0) 00000000(Byte1)
Register 1 : 00000000(Byte 2) 00000000(Byte3)
Register 2 : 00000000(Byte 4) 00000000(Byte5)

Now, let's say that you want to move the gripper. If you read the documentation, you will learn that first the gripper needs to be activated. Then the request gripper position, speed and force needs to be set and the rGTO bit has to be set to 1.

If I want to fully close the gripper at full speed and full force, I will have to write the following information in our registers.

Register 0 : 00001001(Byte 0) 00000000(Byte1) -> rACT=1 AND rGTO=1
Register 1 : 00000000(Byte 2) 11111111(Byte3) -> position_request=0b11111111=255
Register 2 : 11111111(Byte 4) 11111111(Byte5) -> Speed=0b11111111=255 AND Force=0b11111111=255

response=c.write_multiple_registers(0,[0b0000000100000000,0b0000000011111111,0b1111111111111111])

I hope this will help.

rsalehzadeh

bcastets 
Thank you @ bcastets so much for the answer and detailed explanation. It was very helpful and understandable. I tried to close it using your instruction by the following code, but nothing happens after gripper activation (the gripper gets closed and opened once). Could you help me with this? What could be the reason for this?

#Import libraries
##################
from pyModbusTCP.client import ModbusClient
import time

#Initialize variables
##################
executionTime=0
MODBUS_SERVER_IP="10.139.0.101"

#Process initialization
##################
#communication
# TCP auto connect on first modbus request
c = ModbusClient(host=MODBUS_SERVER_IP, port=502, auto_open=True, unit_id=9)

# managing TCP sessions with call to c.open()/c.close()
c.open()

#Wait for the connection to establish
time.sleep(5)

#Write output register to request and activation
response=c.write_multiple_registers(0,[0b0000000100000000,0,0])
print(response)

#Give some time for the gripper to activate
print("Gripper activate")
time.sleep(5)

response=c.write_multiple_registers(0,[0b0000000100000000,0b0000000011111111,0b1111111111111111])

#Give some time for the gripper to reach the desired position
print("Close Gripper")
time.sleep(3)

#close connection
c.close()
exit()