40 Command-line interface for sending simple commands to a ROS node controlling a 3F gripper gripper. 42 This serves as an example for publishing messages on the 'Robotiq3FGripperRobotOutput' topic using the 'Robotiq3FGripper_robot_output' msg type for sending commands to a 3F gripper gripper. In this example, only the simple control mode is implemented. For using the advanced control mode, please refer to the Robotiq support website (support.robotiq.com). 45 from __future__
import print_function
49 roslib.load_manifest(
'robotiq_3f_gripper_control')
51 from robotiq_3f_gripper_articulated_msgs.msg
import Robotiq3FGripperRobotOutput
55 """Update the command according to the character entered by the user.""" 58 command = Robotiq3FGripperRobotOutput();
65 command = Robotiq3FGripperRobotOutput(); 88 command.rPRA = int(char)
89 if command.rPRA > 255:
98 if command.rSPA > 255:
108 if command.rFRA > 255:
120 """Ask the user for a command to send to the gripper.""" 122 currentCommand =
'Simple 3F gripper Controller\n-----\nCurrent command:' 123 currentCommand +=
' rACT = ' + str(command.rACT)
124 currentCommand +=
', rMOD = ' + str(command.rMOD)
125 currentCommand +=
', rGTO = ' + str(command.rGTO)
126 currentCommand +=
', rATR = ' + str(command.rATR)
130 currentCommand +=
', rPRA = ' + str(command.rPRA)
131 currentCommand +=
', rSPA = ' + str(command.rSPA)
132 currentCommand +=
', rFRA = ' + str(command.rFRA)
145 print(currentCommand)
147 strAskForCommand =
'-----\nAvailable commands\n\n' 148 strAskForCommand +=
'r: Reset\n' 149 strAskForCommand +=
'a: Activate\n' 150 strAskForCommand +=
'c: Close\n' 151 strAskForCommand +=
'o: Open\n' 152 strAskForCommand +=
'b: Basic mode\n' 153 strAskForCommand +=
'p: Pinch mode\n' 154 strAskForCommand +=
'w: Wide mode\n' 155 strAskForCommand +=
's: Scissor mode\n' 156 strAskForCommand +=
'(0-255): Go to that position\n' 157 strAskForCommand +=
'f: Faster\n' 158 strAskForCommand +=
'l: Slower\n' 159 strAskForCommand +=
'i: Increase force\n' 160 strAskForCommand +=
'd: Decrease force\n' 162 strAskForCommand +=
'-->' 164 return raw_input(strAskForCommand)
168 """Main loop which requests new commands and publish them on the Robotiq3FGripperRobotOutput topic.""" 170 rospy.init_node(
'Robotiq3FGripperSimpleController')
172 pub = rospy.Publisher(
'Robotiq3FGripperRobotOutput', Robotiq3FGripperRobotOutput)
174 command = Robotiq3FGripperRobotOutput();
176 while not rospy.is_shutdown():
184 if __name__ ==
'__main__':
def genCommand(char, command)
def askForCommand(command)