Skip to content

Commit aff13bc

Browse files
authored
Merge pull request ros-industrial-attic#143 from christian-rauch/unified_msg_3f
replace control msgs with robotiq_3f_gripper_articulated_msgs
2 parents 056b063 + 3a04950 commit aff13bc

File tree

13 files changed

+271
-311
lines changed

13 files changed

+271
-311
lines changed

robotiq_3f_gripper_articulated_msgs/msg/Robotiq3FGripperRobotOutput.msg

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ uint8 rGTO
2424

2525
uint8 rATR
2626

27+
# rGLV: Glove mode
28+
# 0x0 - Glove mode off
29+
# 0x1 - Glove mode on
30+
31+
uint8 rGLV
32+
2733
# rICF: Individual Control of Fingers mode. Each finger receives its own command
2834
# unless the gripper is in the Scissor Grasping Mode and the Independent Control
2935
# of Scissor (rICS) is not activated.

robotiq_3f_gripper_control/CMakeLists.txt

+2-11
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,18 @@ find_package(catkin REQUIRED COMPONENTS
66
diagnostic_updater
77
dynamic_reconfigure
88
hardware_interface
9-
message_generation
109
robotiq_ethercat
1110
roscpp
1211
rospy
1312
socketcan_interface
1413
std_srvs
14+
robotiq_3f_gripper_articulated_msgs
1515
)
1616

1717
find_package(PkgConfig)
1818

19-
add_message_files(
20-
FILES
21-
Robotiq3FGripper_robot_input.msg
22-
Robotiq3FGripper_robot_output.msg
23-
)
24-
2519
catkin_python_setup()
2620

27-
generate_messages()
28-
2921
generate_dynamic_reconfigure_options(
3022
cfg/Robotiq3FGripper.cfg
3123
)
@@ -37,12 +29,12 @@ catkin_package(
3729
diagnostic_updater
3830
dynamic_reconfigure
3931
hardware_interface
40-
message_runtime
4132
robotiq_ethercat
4233
roscpp
4334
rospy
4435
socketcan_interface
4536
std_srvs
37+
robotiq_3f_gripper_articulated_msgs
4638
)
4739

4840
include_directories(
@@ -61,7 +53,6 @@ target_link_libraries(${PROJECT_NAME}
6153
)
6254
add_dependencies(${PROJECT_NAME}
6355
${PROJECT_NAME}_gencfg
64-
${PROJECT_NAME}_generate_messages_cpp
6556
${catkin_EXPORTED_TARGETS}
6657
)
6758

robotiq_3f_gripper_control/include/robotiq_3f_gripper_control/robotiq_3f_gripper_client_base.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@
2626
#define ROBOTIQ_3F_GRIPPER_CLIENT_BASE_H
2727

2828
#include <ros/ros.h>
29-
#include <robotiq_3f_gripper_control/Robotiq3FGripper_robot_output.h>
30-
#include <robotiq_3f_gripper_control/Robotiq3FGripper_robot_input.h>
29+
#include <robotiq_3f_gripper_articulated_msgs/Robotiq3FGripperRobotOutput.h>
30+
#include <robotiq_3f_gripper_articulated_msgs/Robotiq3FGripperRobotInput.h>
3131

3232
namespace robotiq_3f_gripper_control
3333
{
3434

3535
class Robotiq3FGripperClientBase
3636
{
3737
public:
38-
typedef robotiq_3f_gripper_control::Robotiq3FGripper_robot_output GripperOutput;
39-
typedef robotiq_3f_gripper_control::Robotiq3FGripper_robot_input GripperInput;
38+
typedef robotiq_3f_gripper_articulated_msgs::Robotiq3FGripperRobotOutput GripperOutput;
39+
typedef robotiq_3f_gripper_articulated_msgs::Robotiq3FGripperRobotInput GripperInput;
4040

4141
virtual void init(ros::NodeHandle nh) {}
4242

robotiq_3f_gripper_control/include/robotiq_3f_gripper_control/robotiq_3f_gripper_ros.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
#include <ros/ros.h>
2929
#include <std_srvs/Trigger.h>
30-
#include <robotiq_3f_gripper_control/Robotiq3FGripper_robot_input.h>
31-
#include <robotiq_3f_gripper_control/Robotiq3FGripper_robot_output.h>
30+
#include <robotiq_3f_gripper_articulated_msgs/Robotiq3FGripperRobotInput.h>
31+
#include <robotiq_3f_gripper_articulated_msgs/Robotiq3FGripperRobotOutput.h>
3232
#include <robotiq_3f_gripper_control/robotiq_3f_gripper_api.h>
3333
#include <dynamic_reconfigure/server.h>
3434
#include <robotiq_3f_gripper_control/Robotiq3FGripperConfig.h>
@@ -52,7 +52,7 @@ class Robotiq3FGripperROS
5252

5353
void handleReconfigure(robotiq_3f_gripper_control::Robotiq3FGripperConfig &config, uint32_t level=0);
5454

55-
void handleRawCmd(const robotiq_3f_gripper_control::Robotiq3FGripper_robot_output::ConstPtr &msg);
55+
void handleRawCmd(const robotiq_3f_gripper_articulated_msgs::Robotiq3FGripperRobotOutput::ConstPtr &msg);
5656

5757
void updateConfig(const robotiq_3f_gripper_control::Robotiq3FGripperConfig &config);
5858
void getCurrentConfig(robotiq_3f_gripper_control::Robotiq3FGripperConfig &config);
@@ -81,7 +81,7 @@ class Robotiq3FGripperROS
8181
boost::recursive_mutex reconfigure_mutex_;
8282
robotiq_3f_gripper_control::Robotiq3FGripperConfig config_;
8383

84-
robotiq_3f_gripper_control::Robotiq3FGripper_robot_input input_status_msg_;
84+
robotiq_3f_gripper_articulated_msgs::Robotiq3FGripperRobotInput input_status_msg_;
8585

8686
};
8787
} //end namespace robotiq_3f_gripper_control

robotiq_3f_gripper_control/msg/Robotiq3FGripper_robot_input.msg

-22
This file was deleted.

robotiq_3f_gripper_control/msg/Robotiq3FGripper_robot_output.msg

-19
This file was deleted.

robotiq_3f_gripper_control/nodes/Robotiq3FGripperSimpleController.py

+45-43
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,27 @@
4242
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).
4343
"""
4444

45-
import roslib; roslib.load_manifest('robotiq_3f_gripper_control')
45+
from __future__ import print_function
46+
47+
import roslib;
48+
49+
roslib.load_manifest('robotiq_3f_gripper_control')
4650
import rospy
47-
from robotiq_3f_gripper_control.msg import _Robotiq3FGripper_robot_output as outputMsg
48-
from time import sleep
51+
from robotiq_3f_gripper_articulated_msgs.msg import Robotiq3FGripperRobotOutput
4952

5053

5154
def genCommand(char, command):
52-
"""Update the command according to the character entered by the user."""
53-
55+
"""Update the command according to the character entered by the user."""
56+
5457
if char == 'a':
55-
command = outputMsg.Robotiq3FGripper_robot_output();
58+
command = Robotiq3FGripperRobotOutput();
5659
command.rACT = 1
5760
command.rGTO = 1
5861
command.rSPA = 255
5962
command.rFRA = 150
6063

6164
if char == 'r':
62-
command = outputMsg.Robotiq3FGripper_robot_output();
65+
command = Robotiq3FGripperRobotOutput();
6366
command.rACT = 0
6467

6568
if char == 'c':
@@ -70,79 +73,78 @@ def genCommand(char, command):
7073

7174
if char == 'b':
7275
command.rMOD = 0
73-
76+
7477
if char == 'p':
7578
command.rMOD = 1
76-
79+
7780
if char == 'w':
7881
command.rMOD = 2
79-
82+
8083
if char == 's':
8184
command.rMOD = 3
8285

83-
#If the command entered is a int, assign this value to rPRA
84-
try:
86+
# If the command entered is a int, assign this value to rPRA
87+
try:
8588
command.rPRA = int(char)
8689
if command.rPRA > 255:
8790
command.rPRA = 255
8891
if command.rPRA < 0:
8992
command.rPRA = 0
9093
except ValueError:
91-
pass
92-
94+
pass
95+
9396
if char == 'f':
9497
command.rSPA += 25
9598
if command.rSPA > 255:
9699
command.rSPA = 255
97-
100+
98101
if char == 'l':
99102
command.rSPA -= 25
100103
if command.rSPA < 0:
101104
command.rSPA = 0
102105

103-
104106
if char == 'i':
105107
command.rFRA += 25
106108
if command.rFRA > 255:
107109
command.rFRA = 255
108-
110+
109111
if char == 'd':
110112
command.rFRA -= 25
111113
if command.rFRA < 0:
112114
command.rFRA = 0
113115

114116
return command
115-
117+
116118

117119
def askForCommand(command):
118-
"""Ask the user for a command to send to the gripper."""
120+
"""Ask the user for a command to send to the gripper."""
119121

120-
currentCommand = 'Simple 3F gripper Controller\n-----\nCurrent command:'
121-
currentCommand += ' rACT = ' + str(command.rACT)
122+
currentCommand = 'Simple 3F gripper Controller\n-----\nCurrent command:'
123+
currentCommand += ' rACT = ' + str(command.rACT)
122124
currentCommand += ', rMOD = ' + str(command.rMOD)
123125
currentCommand += ', rGTO = ' + str(command.rGTO)
124126
currentCommand += ', rATR = ' + str(command.rATR)
125-
## currentCommand += ', rGLV = ' + str(command.rGLV)
126-
## currentCommand += ', rICF = ' + str(command.rICF)
127-
## currentCommand += ', rICS = ' + str(command.rICS)
127+
## currentCommand += ', rGLV = ' + str(command.rGLV)
128+
## currentCommand += ', rICF = ' + str(command.rICF)
129+
## currentCommand += ', rICS = ' + str(command.rICS)
128130
currentCommand += ', rPRA = ' + str(command.rPRA)
129131
currentCommand += ', rSPA = ' + str(command.rSPA)
130132
currentCommand += ', rFRA = ' + str(command.rFRA)
131133

132-
#We only show the simple control mode
133-
## currentCommand += ', rPRB = ' + str(command.rPRB)
134-
## currentCommand += ', rSPB = ' + str(command.rSPB)
135-
## currentCommand += ', rFRB = ' + str(command.rFRB)
136-
## currentCommand += ', rPRC = ' + str(command.rPRC)
137-
## currentCommand += ', rSPC = ' + str(command.rSPC)
138-
## currentCommand += ', rFRC = ' + str(command.rFRC)
139-
## currentCommand += ', rPRS = ' + str(command.rPRS)
140-
## currentCommand += ', rSPS = ' + str(command.rSPS)
141-
## currentCommand += ', rFRS = ' + str(command.rFRS)
134+
# We only show the simple control mode
135+
## currentCommand += ', rPRB = ' + str(command.rPRB)
136+
## currentCommand += ', rSPB = ' + str(command.rSPB)
137+
## currentCommand += ', rFRB = ' + str(command.rFRB)
138+
## currentCommand += ', rPRC = ' + str(command.rPRC)
139+
## currentCommand += ', rSPC = ' + str(command.rSPC)
140+
## currentCommand += ', rFRC = ' + str(command.rFRC)
141+
## currentCommand += ', rPRS = ' + str(command.rPRS)
142+
## currentCommand += ', rSPS = ' + str(command.rSPS)
143+
## currentCommand += ', rFRS = ' + str(command.rFRS)
142144

143-
print currentCommand
145+
print(currentCommand)
144146

145-
strAskForCommand = '-----\nAvailable commands\n\n'
147+
strAskForCommand = '-----\nAvailable commands\n\n'
146148
strAskForCommand += 'r: Reset\n'
147149
strAskForCommand += 'a: Activate\n'
148150
strAskForCommand += 'c: Close\n'
@@ -156,28 +158,28 @@ def askForCommand(command):
156158
strAskForCommand += 'l: Slower\n'
157159
strAskForCommand += 'i: Increase force\n'
158160
strAskForCommand += 'd: Decrease force\n'
159-
161+
160162
strAskForCommand += '-->'
161163

162164
return raw_input(strAskForCommand)
163165

166+
164167
def publisher():
165168
"""Main loop which requests new commands and publish them on the Robotiq3FGripperRobotOutput topic."""
166169

167170
rospy.init_node('Robotiq3FGripperSimpleController')
168-
169-
pub = rospy.Publisher('Robotiq3FGripperRobotOutput', outputMsg.Robotiq3FGripper_robot_output)
170171

171-
command = outputMsg.Robotiq3FGripper_robot_output();
172+
pub = rospy.Publisher('Robotiq3FGripperRobotOutput', Robotiq3FGripperRobotOutput)
173+
174+
command = Robotiq3FGripperRobotOutput();
172175

173176
while not rospy.is_shutdown():
177+
command = genCommand(askForCommand(command), command)
174178

175-
command = genCommand(askForCommand(command), command)
176-
177179
pub.publish(command)
178180

179181
rospy.sleep(0.1)
180-
182+
181183

182184
if __name__ == '__main__':
183185
publisher()

0 commit comments

Comments
 (0)