Skip to content

Commit 9cb6cda

Browse files
author
nalt
committed
Communication mode with auto update by griiper; Readme; UDP/TCP
1 parent d051e8f commit 9cb6cda

11 files changed

+542
-192
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ srv_gen
33
build
44
bin
55
._*
6+
*.build

README.html

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<h1>wsg50-ros-pkg</h1>
2+
3+
<p>Forked from: <a href="https://code.google.com/p/wsg50-ros-pkg">https://code.google.com/p/wsg50-ros-pkg</a></p>
4+
5+
<p>See also Wiki: <a href="https://code.google.com/p/wsg50-ros-pkg/wiki/wsg_50">https://code.google.com/p/wsg50-ros-pkg/wiki/wsg_50</a></p>
6+
7+
<h2>Node wsg_50_tcp</h2>
8+
9+
<h3>Parameters</h3>
10+
11+
<ul>
12+
<li><em>ip</em>: IP address of gripper</li>
13+
<li><em>port</em>: Port of gripper</li>
14+
<li><em>local_port</em>: Local port for UDP</li>
15+
<li><em>protocol</em>: udp or tcp (default)</li>
16+
<li><em>com_mode</em>: polling (default), script or auto_update. See communication modes below.</li>
17+
<li><em>rate</em>: Polling rate in Hz.</li>
18+
<li><em>grasping_force</em>: Set grasping force limit on startup</li>
19+
</ul>
20+
21+
<h3>Services</h3>
22+
23+
<p>See <a href="https://code.google.com/p/wsg50-ros-pkg/wiki/wsg_50">https://code.google.com/p/wsg50-ros-pkg/wiki/wsg_50</a>. Services currently block the reception of state updates.</p>
24+
25+
<h3>Topics</h3>
26+
27+
<ul>
28+
<li><em>~/goal_position [IN, wsg_50_common/Cmd], Modes: script, auto_update:</em> Position goal; send target position in mm and speed</li>
29+
<li><em>~/goal_speed [IN, std_msgs/Float32], Modes: script:</em> Velocity goal (in mm/s); positive values open the gripper</li>
30+
<li><em>~/moving [OUT, std_msgs/Bool], Modes: script, auto_update:</em> Signals a change in the motion state for position control. Can be used to wait for the end of a gripper movement. Signaling does not work correctly get for velocity control, since the gripper state register does not directly provide this information.</li>
31+
<li><em>~/state [OUT, std_msgs/State]:</em> State information (opening width, speed, forces). Note: Not all fields are available with all communication modes.</li>
32+
<li><em>/joint_states [OUT]:</em> Standard joint state message</li>
33+
</ul>
34+
35+
<h3>Communication modes (closed-loop control)</h3>
36+
37+
<p>Select by <em>com_mode</em> parameters.</p>
38+
39+
<ul>
40+
<li><p><strong>Polling</strong><br />
41+
Gripper state is polled regularly using built-in commands. Services (e.g. move) block the polling as long as the gripper moves; the topic interface is not available. Up to 15 Hz could be reached with the WSG-50 hardware revision 2.</p></li>
42+
<li><p><strong>Script</strong><br />
43+
Allows for closed-loop control with a custom script (see below) that supports up to 2 FMF finger. Gripper state is read synchronously with the specified rate. Up to 30 Hz could be reached with the WSG-50 hardware revision 2. The gripper can be controlled asynchronously by sending position or velocity goals to the topics shown below. Commands will be sent with the next read command in the timer callback timer_cb().<br />
44+
The services can still be used - yet, they are blocking the gripper communication. There are no state updates while the gripper is moved by a service. </p></li>
45+
<li><p><strong>Auto_update</strong><br>
46+
Requests periodic updates of the gripper state (position, speed, force; less than with the script). Up to 140 Hz could be reached with the WSG-50 hardware revision 2. All responses of the gripper must be received by a reading thread which also publishes the ROS messages. Therefore, the commands in functions.cpp cannot be used. Position targets are sent asynchronously to the gripper using the built-in commands. As with the script option, there is a noticeable delay until the movement starts.<br />
47+
The services are disabled.</p></li>
48+
</ul>
49+
50+
<h4>Gripper script</h4>
51+
52+
<p>The script <em>cmd_measure.lua</em> must be running on the gripper for closed-loop control mode. It allows for non-blocking position and velocity control and responds with the current position, speed, motor force and up to to two FMF finger forces. The custom commands 0xB0 (read only), 0xB1 (read, goal position and speed), 0xB2 (read, goal speed) are used. Tested with firmware version 2.6.4. There have been minor API changes compared to 1.x.</p>

README.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# wsg50-ros-pkg
2+
Forked from: [https://code.google.com/p/wsg50-ros-pkg](https://code.google.com/p/wsg50-ros-pkg)
3+
4+
See also Wiki: [https://code.google.com/p/wsg50-ros-pkg/wiki/wsg_50](https://code.google.com/p/wsg50-ros-pkg/wiki/wsg_50)
5+
6+
## Node wsg\_50_tcp
7+
8+
### Parameters
9+
* *ip*: IP address of gripper
10+
* *port*: Port of gripper
11+
* *local_port*: Local port for UDP
12+
* *protocol*: udp or tcp (default)
13+
* *com_mode*: polling (default), script or auto_update. See communication modes below.
14+
* *rate*: Polling rate in Hz.
15+
* *grasping_force*: Set grasping force limit on startup
16+
17+
18+
### Services
19+
See [https://code.google.com/p/wsg50-ros-pkg/wiki/wsg_50](https://code.google.com/p/wsg50-ros-pkg/wiki/wsg_50). Services currently block the reception of state updates.
20+
21+
### Topics
22+
* *~/goal\_position [IN, wsg_50_common/Cmd], Modes: script, auto_update:* Position goal; send target position in mm and speed
23+
* *~/goal\_speed [IN, std_msgs/Float32], Modes: script:* Velocity goal (in mm/s); positive values open the gripper
24+
* *~/moving [OUT, std_msgs/Bool], Modes: script, auto_update:* Signals a change in the motion state for position control. Can be used to wait for the end of a gripper movement. Signaling does not work correctly get for velocity control, since the gripper state register does not directly provide this information.
25+
* *~/state [OUT, std_msgs/State]:* State information (opening width, speed, forces). Note: Not all fields are available with all communication modes.
26+
* */joint_states [OUT]:* Standard joint state message
27+
28+
29+
### Communication modes (closed-loop control)
30+
Select by *com_mode* parameters.
31+
32+
* **Polling**<br />
33+
Gripper state is polled regularly using built-in commands. Services (e.g. move) block the polling as long as the gripper moves; the topic interface is not available. Up to 15 Hz could be reached with the WSG-50 hardware revision 2.
34+
35+
* **Script**<br />
36+
Allows for closed-loop control with a custom script (see below) that supports up to 2 FMF finger. Gripper state is read synchronously with the specified rate. Up to 30 Hz could be reached with the WSG-50 hardware revision 2. The gripper can be controlled asynchronously by sending position or velocity goals to the topics shown below. Commands will be sent with the next read command in the timer callback timer_cb().<br />
37+
The services can still be used - yet, they are blocking the gripper communication. There are no state updates while the gripper is moved by a service.
38+
39+
* **Auto_update**<br>
40+
Requests periodic updates of the gripper state (position, speed, force; less than with the script). Up to 140 Hz could be reached with the WSG-50 hardware revision 2. All responses of the gripper must be received by a reading thread which also publishes the ROS messages. Therefore, the commands in functions.cpp cannot be used. Position targets are sent asynchronously to the gripper using the built-in commands. As with the script option, there is a noticeable delay until the movement starts.<br />
41+
The services are disabled.
42+
43+
#### Gripper script
44+
The script *cmd_measure.lua* must be running on the gripper for the script mode. It allows for non-blocking position and velocity control and responds with the current position, speed, motor force and up to two FMF finger forces. The custom commands 0xB0 (read only), 0xB1 (read, goal position and speed), 0xB2 (read, goal speed) are used. Tested with firmware version 2.6.4. There have been minor API changes compared to 1.x.

wsg_50/CMakeLists.txt

+13-14
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ rosbuild_gensrv()
3333
# WSG_50_TCP version
3434

3535
set(DRIVER_SOURCES
36-
src/checksum.cpp
37-
src/cmd.c
38-
src/common.cpp
39-
src/functions.cpp
40-
src/interface.cpp
36+
src/checksum.cpp include/wsg_50/checksum.h
37+
src/cmd.c include/wsg_50/cmd.h
38+
src/common.cpp include/wsg_50/common.h
39+
src/functions.cpp include/wsg_50/functions.h
40+
src/interface.cpp include/wsg_50/interface.h
4141
src/main.cpp
42-
src/msg.c
43-
src/serial.c
44-
src/tcp.c
45-
src/udp.c)
42+
src/msg.c include/wsg_50/msg.h
43+
src/serial.c include/wsg_50/serial.h
44+
src/tcp.c include/wsg_50/tcp.h
45+
src/udp.c include/wsg_50/udp.h)
4646

4747

4848
rosbuild_add_executable(wsg_50_tcp src/main.cpp ${DRIVER_SOURCES})
@@ -59,13 +59,12 @@ set(DRIVER_SOURCES_CAN
5959
#rosbuild_add_executable(wsg_50_can src/main_can.cpp ${DRIVER_SOURCES_CAN})
6060

6161
add_definitions(-DOSNAME_LINUX)
62-
add_definitions(-std=c++0x)
63-
64-
include_directories(/home/marc/peak-linux-driver-7.5/driver/src/)
65-
link_directories(/home/marc/peak-linux-driver-7.5/lib/)
62+
add_definitions(-g)
63+
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++0x") # Need C++11
6664

65+
#include_directories(/home/marc/peak-linux-driver-7.5/driver/src/)
66+
#link_directories(/home/marc/peak-linux-driver-7.5/lib/)
6767
#rosbuild_add_compile_flags(wsg_50_can -g -Wall)
68-
6968
#target_link_libraries(wsg_50_can pcan)
7069

7170

wsg_50/include/wsg_50/functions.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ typedef struct {
6565
// Function declaration
6666
//------------------------------------------------------------------------
6767

68+
float convert(unsigned char *b);
6869
int homing( void );
69-
int move( float width, float speed, bool stop_on_block );
70-
int stop( void );
70+
int move(float width, float speed, bool stop_on_block, bool ignore_response = false);
71+
int stop( bool ignore_response = false );
7172
int grasp( float objWidth, float speed );
7273
int release( float width, float speed );
7374
int ack_fault( void );
@@ -77,12 +78,13 @@ int setGraspingForceLimit( float force );
7778

7879
const char * systemState( void );
7980
int graspingState( void );
80-
float getOpening( void );
81-
float getForce( void );
81+
float getOpening(int auto_update = 0);
82+
float getForce(int auto_update = 0);
83+
float getSpeed(int auto_update = 0);
8284
int getAcceleration( void );
8385
int getGraspingForceLimit( void );
8486

85-
int measure_move (unsigned char cmd_type, float cmd_width, float cmd_speed, gripper_response & info);
87+
int script_measure_move (unsigned char cmd_type, float cmd_width, float cmd_speed, gripper_response & info);
8688

8789
//void getStateValues(); //(unsigned char *);
8890

wsg_50/launch/wsg_50_tcp_script.launch

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<launch>
2+
<arg name="com_mode" default="script" /><!-- or auto_update, polling -->
23

34
<node name="wsg_50" pkg="wsg_50" type="wsg_50_tcp" output="screen">
45
<param name="ip" type="string" value="192.168.20.2"/>
56
<param name="port" type="int" value="1000"/>
6-
<param name="use_script" type="bool" value="true"/>
7-
<param name="rate" type="double" value="50"/> <!-- WSG50 HW revision 2: up to 30 Hz -->
7+
<param name="protocol" type="string" value="tcp"/>
8+
<param name="com_mode" type="string" value="$(arg com_mode)"/>
9+
<param name="rate" type="double" value="500"/> <!-- WSG50 HW revision 2: up to 30 Hz with script; 130Hz with auto_update -->
810
<param name="grasping_force" type="double" value="80"/>
911
</node>
1012

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<launch>
2+
<arg name="com_mode" default="script" />
3+
4+
<node name="wsg_50" pkg="wsg_50" type="wsg_50_tcp" output="screen">
5+
<param name="ip" type="string" value="192.168.20.2"/>
6+
<param name="port" type="int" value="1500"/>
7+
<param name="local_port" type="int" value="5501"/>
8+
<param name="protocol" type="string" value="udp"/>
9+
<param name="com_mode" type="string" value="$(arg com_mode)"/>
10+
<param name="rate" type="double" value="500"/>
11+
<param name="grasping_force" type="double" value="80"/>
12+
</node>
13+
14+
</launch>
15+

wsg_50/src/common.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,6 @@ const char * getStateValues( unsigned char *b ){
290290

291291
//dbgPrint("%s\n", resp);
292292
return resp;
293-
294-
295-
296293
}
297294

298295

0 commit comments

Comments
 (0)