37 Module baseRobotiq2FGripper: defines a base class for handling command and status of the Robotiq 2F gripper. 39 After being instanciated, a 'client' member must be added to the object. This client depends on the communication protocol used by the Gripper. As an example, the ROS node 'Robotiq2FGripperTcpNode.py' instanciate a robotiqbaseRobotiq2FGripper and adds a client defined in the module comModbusTcp. 42 from robotiq_2f_gripper_control.msg
import _Robotiq2FGripper_robot_input
as inputMsg
43 from robotiq_2f_gripper_control.msg
import _Robotiq2FGripper_robot_output
as outputMsg
46 """Base class (communication protocol agnostic) for sending commands and receiving the status of the Robotic 2F gripper""" 56 """Function to verify that the value of each variable satisfy its limits.""" 59 command.rACT = max(0, command.rACT)
60 command.rACT = min(1, command.rACT)
62 command.rGTO = max(0, command.rGTO)
63 command.rGTO = min(1, command.rGTO)
65 command.rATR = max(0, command.rATR)
66 command.rATR = min(1, command.rATR)
68 command.rPR = max(0, command.rPR)
69 command.rPR = min(255, command.rPR)
71 command.rSP = max(0, command.rSP)
72 command.rSP = min(255, command.rSP)
74 command.rFR = max(0, command.rFR)
75 command.rFR = min(255, command.rFR)
81 """Function to update the command which will be sent during the next sendCommand() call.""" 84 command = self.verifyCommand(command)
91 self.message.append(command.rACT + (command.rGTO << 3) + (command.rATR << 4))
92 self.message.append(0)
93 self.message.append(0)
94 self.message.append(command.rPR)
95 self.message.append(command.rSP)
96 self.message.append(command.rFR)
99 """Send the command to the Gripper.""" 101 self.client.sendCommand(self.
message)
104 """Request the status from the gripper and return it in the Robotiq2FGripper_robot_input msg type.""" 107 status = self.client.getStatus(6);
110 message = inputMsg.Robotiq2FGripper_robot_input()
113 message.gACT = (status[0] >> 0) & 0x01;
114 message.gGTO = (status[0] >> 3) & 0x01;
115 message.gSTA = (status[0] >> 4) & 0x03;
116 message.gOBJ = (status[0] >> 6) & 0x03;
117 message.gFLT = status[2]
118 message.gPR = status[3]
119 message.gPO = status[4]
120 message.gCU = status[5]
def refreshCommand(self, command)
def verifyCommand(self, command)