Skip to content

Commit ba47f5a

Browse files
committed
Merge branch 'humble-devel' into feature/jazzy-port
2 parents 187632a + 1ebafe3 commit ba47f5a

File tree

6 files changed

+176
-37
lines changed

6 files changed

+176
-37
lines changed

README.md

Lines changed: 105 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,14 @@ Package for controlling the [Robotiq Hand-E gripper](https://robotiq.com/product
1313

1414
## Quick Start
1515

16-
### Connection Setup
16+
### Workspace setup
1717

18-
#### Without Physical Hardware
19-
* You are ready to go - just remember to pass the `use_fake_hardware:=true` argument.
20-
21-
#### Modbus RTU
22-
* Connect the serial port to your system and locate the TTY device (typically `/dev/ttyX`).
23-
* You will need to configure the serial connection in your `.xacro.urdf` file ([example](https://github.com/AGH-CEAI/robotiq_hande_description/blob/humble/urdf/robotiq_hande_gripper.urdf.xacro) in `robotiq_hande_description`).
24-
25-
#### Modbus TCP
26-
* You can create a local `TCP` <-> `Virtual Serial Port` server with the `socat` command.
27-
* An example usage (in the form of a Python ROS 2 wrapper) can be found in `ur_robot_driver`'s [scripts/tool_communication.py](https://github.com/UniversalRobots/Universal_Robots_ROS2_Driver/blob/204e215c8a7371f6357e6a09f7e106364e566931/ur_robot_driver/scripts/tool_communication.py#L64).
28-
* Example: `socat pty,link=/tmp/ttyUR,raw,ignoreeof,waitslave tcp:192.168.1.2:54321`
29-
* For the UR's `ur_robot_driver`, the default path to the virtual serial port is `/tmp/ttyUR`.
30-
31-
32-
### Package setup
3318
```bash
34-
cd ~/ceai_ws/src
35-
git clone git@github.com:AGH-CEAI/robotiq_hande_driver.git ./src
36-
vcs import src < src/robotiq_hande_driver/robotiq_hande_driver.repos &&
37-
colcon build --symlink-install --packages-select robotiq_hande_driver
19+
mkdir -p ~/ceai_ws
20+
cd ~/ceai_ws
21+
git clone git@github.com:AGH-CEAI/robotiq_hande_driver.git src/robotiq_hande_driver
22+
vcs import src < src/robotiq_hande_driver/robotiq_hande_driver/robotiq_hande_driver.repos
23+
colcon build --symlink-install
3824
source ./install/local_setup.sh
3925
```
4026
> [!NOTE]
@@ -44,10 +30,15 @@ source ./install/local_setup.sh
4430
4531

4632
### Launch preview
33+
34+
Start the driver:
4735
```bash
4836
ros2 launch robotiq_hande_driver gripper_controller_preview.launch.py use_fake_hardware:=true
49-
# In other terminal
50-
ros2 action send_goal /gripper_action_controller/gripper_cmd control_msgs/action/ParallelGripperCommand "command:
37+
```
38+
39+
Send a command to the gripper in another terminal:
40+
```bash
41+
ros2 action send_goal /gripper_action_controller/gripper_cmd control_msgs/action/GripperCommand \
5142
"command:
5243
header:
5344
position: 0.0
@@ -63,8 +54,97 @@ ros2 action send_goal /gripper_action_controller/gripper_cmd control_msgs/action
6354
"
6455
```
6556

66-
### Examples
67-
**An example integration usage can be find** in the [AGH-CEAI/aegis_ros](https://github.com/AGH-CEAI/aegis_ros) repository.
57+
## Connection modes
58+
59+
You can run the gripper in three ways.
60+
61+
### Without the physical hardware
62+
63+
If you only want to test the gripper behavior or visualize it in RViz without connecting to the actual device, you can use the fake hardware mode. In this case, simply pass the `use_fake_hardware:=true` argument:
64+
```bash
65+
ros2 launch robotiq_hande_driver gripper_controller_preview.launch.py use_fake_hardware:=true
66+
```
67+
68+
All other connection options will be ignored; this mode does not communicate with any physical port or network but simulates responses and allows the controller to run.
69+
70+
### Modbus RTU
71+
72+
If you want to work with the real gripper via direct serial communication, the computer connects to the gripper through a USB-to-RS485 adapter. The wiring is represented as:
73+
74+
Computer → USB adapter ↔ RS485 ↔ Hand-E gripper
75+
76+
In this case, you need to set `use_fake_hardware:=false` and provide serial port to establish connection using `tty_port`:
77+
```bash
78+
ros2 launch robotiq_hande_driver gripper_controller_preview.launch.py use_fake_hardware:=false tty_port:=/dev/ttyUSB0
79+
```
80+
81+
You can check available serial devices with:
82+
```bash
83+
dmesg | grep tty
84+
```
85+
86+
or
87+
88+
```bash
89+
ls -l /dev/tty*
90+
```
91+
92+
Make sure your user has permissions to access the serial port:
93+
```bash
94+
sudo usermod -a -G dialout $USER
95+
```
96+
97+
### Modbus RTU tunneled over TCP via UR Tool Communication
98+
99+
If your setup involves a UR robot, its controller can expose the RS-485 tool port over TCP using the pTool Communication URCap](https://docs.universal-robots.com/Universal_Robots_ROS2_Documentation/doc/ur_robot_driver/ur_robot_driver/doc/setup_tool_communication.html). The wiring is represented as:
100+
101+
UR controller RS-485 tool port ↔ URCap forwarder ↔ TCP socket ↔ Computer
102+
103+
Although this is a TCP connection, the driver uses a pseudo-TTY to translate TCP packets into RTU frames. Typically, the virtual serial port is `/tmp/ttyUR`.
104+
105+
To enable this mode, set `use_fake_hardware:=false`, `create_socat_tty:=true`, and specify the `socat_ip_address` and `socat_port` of the UR forwarder:
106+
```bash
107+
ros2 launch robotiq_hande_driver gripper_controller_preview.launch.py \
108+
use_fake_hardware:=false \
109+
create_socat_tty:=true \
110+
tty_port:=/tmp/ttyUR \
111+
socat_ip_address:=192.168.1.2 \
112+
socat_port:=54321 \
113+
frequency_hz:=10 \
114+
launch_rviz:=true
115+
```
116+
117+
The driver will then use `tty_port:=/tmp/ttyUR` as if it were a real serial port.
118+
119+
You can also start `socat` manually, for example:
120+
```bash
121+
socat pty,link=/tmp/ttyUR,raw,ignoreeof,waitslave tcp:192.168.100.10:54321
122+
```
123+
124+
> [!WARNING]
125+
> Do not use both the `use_tool_communication:=true` flag for the **ur_driver** and the `create_socat_tty:=true` flag for the **robotiq_hande_driver**!
126+
> Both options will invoke the `socat` command to create the `/tmp/ttyUR` virtual serial port.
127+
> However, the initialization of the Hand-E driver may suffer from a race condition: **the tty link must exist before initialization**.
128+
> It is recommended to use the provided `create_socat_tty` option.
129+
130+
## Integration with (other) robots
131+
132+
To integrate the Robotiq Hand-E gripper into your existing robot, you first need to create a [Xacro (URDF) file](https://docs.ros.org/en/humble/Tutorials/Intermediate/URDF/URDF-Main.html) that includes the Hand-E macros and defines all necessary parameters.
133+
134+
A working example of such a file can be found [here](https://github.com/AGH-CEAI/aegis_ros/blob/humble-devel/aegis_description/urdf/modules/robotiq_hande_gripper.xacro). You can use this file as a starting point for your own integration.
135+
136+
Next, include this Xacro file in your main robot description tree at the appropriate tool link.
137+
138+
An example of including it in a robot Xacro can be found [here](https://github.com/AGH-CEAI/aegis_ros/blob/humble-devel/aegis_description/urdf/aegis.xacro).
139+
140+
The included robotiq_hande_gripper macro automatically sets up the `<ros2_control>` block pointing to the Robotiq Hand-E driver plugin. This ensures that your robot can control the gripper via the standard ROS 2 control interfaces.
141+
142+
You can easliy dig into the `ros2_control` concepts with [its documentation](https://control.ros.org/rolling/doc/ros2_control/doc/index.html#concepts). There is also a [plenty of examples](https://control.ros.org/humble/doc/ros2_control_demos/doc/index.html#examples)
143+
144+
> [!IMPORTANT]
145+
> The `robotiq_hande_driver` currently provides only a **hardware component** (i.e. _hardware interface_) to control the fingers' joints.
146+
147+
The included `robotiq_hande_gripper` macro automatically sets up the `<ros2_control>` block pointing to the Robotiq Hand-E driver plugin. This ensures that your robot can control the gripper via the standard ROS 2 control interfaces, including the gripper action controller and joint state broadcaster, without additional manual plugin configuration.
68148

69149
---
70150
## Development notes
@@ -88,4 +168,5 @@ cd ~/ceai/ros_ws/build/robotiq_hande_driver
88168

89169
---
90170
## License
171+
91172
This repository is licensed under the Apache 2.0, see LICENSE for details.

robotiq_hande_driver/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
* [PR-27](https://github.com/AGH-CEAI/robotiq_hande_driver/pull/27) - Added additional launch arguments and provided better instructions in README.
13+
1214
* [PR-21](https://github.com/AGH-CEAI/robotiq_hande_driver/pull/21) - Added:
1315
* `SocatManager` for managing the external `socat` process.
1416
* Added colored logging.
@@ -20,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2022
### Changed
2123

2224
* [PR-26](https://github.com/AGH-CEAI/robotiq_hande_driver/pull/26) - Migration from ROS 2 Humble to ROS 2 Jazzy.
25+
* [PR-27](https://github.com/AGH-CEAI/robotiq_hande_driver/pull/27) - Renamed `ip_adress` to `socat_ip_address` and `port` to `socat_port`.
2326
* [PR-21](https://github.com/AGH-CEAI/robotiq_hande_driver/pull/21) - Refactored the modbus communication to use multithreads:
2427
* Renamed `application.hpp/cpp` to `hande_gripper.hpp/cpp`.
2528
* Changed plain arrays `uint8_t bytes_[]` into `std::array<uint8_t, *>`.
@@ -37,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3740

3841
### Fixed
3942

43+
* [PR-25](https://github.com/AGH-CEAI/robotiq_hande_driver/pull/25) - Fixed wrong type for the force command interface (from `HW_IF_POSITION` to `HW_IF_EFFORT`).
4044
* [PR-21](https://github.com/AGH-CEAI/robotiq_hande_driver/pull/21) - Fixed:
4145
* Fixed integration with - UR's RTDE communication protocol ([aegis_ros#38](https://github.com/AGH-CEAI/aegis_ros/issues/38)).
4246
* Re-enabled the `-Werror` flag #5.

robotiq_hande_driver/CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ cmake_minimum_required(VERSION 3.16)
22
project(robotiq_hande_driver)
33

44
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
5-
# Flag `-Wno-deprecated-copy` is related to the ROS Humble's bundled gmock version.
6-
add_compile_options(
7-
-Wall
8-
-Wextra
9-
-Wpedantic
10-
-Werror
11-
-Wno-deprecated-copy)
5+
# If you got problems with ROS Humble's bundled gmock version: a) change the compiler to clang >=
6+
# 14.0.0 b) add flag `-Wno-deprecated-copy`
7+
add_compile_options(-Wall -Wextra -Wpedantic -Werror)
128
endif()
139

1410
include(FindPkgConfig)

robotiq_hande_driver/bringup/launch/gripper_controller_preview.launch.py

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,42 @@ def generate_launch_description():
3838
DeclareLaunchArgument(
3939
"tf_prefix",
4040
default_value="",
41-
description="transforms prefix",
41+
description="Add prefix to the all robot's links & joints.",
42+
)
43+
)
44+
declared_arguments.append(
45+
DeclareLaunchArgument(
46+
"frequency_hz",
47+
default_value="10",
48+
description="Set update rate for controller.",
49+
)
50+
)
51+
declared_arguments.append(
52+
DeclareLaunchArgument(
53+
"tty_port",
54+
default_value="/tmp/ttyUR",
55+
description="Set serial port for RTU communication.",
56+
)
57+
)
58+
declared_arguments.append(
59+
DeclareLaunchArgument(
60+
"create_socat_tty",
61+
default_value="false",
62+
description="Create virtual serial port in Linux for RTU simulation.",
63+
)
64+
)
65+
declared_arguments.append(
66+
DeclareLaunchArgument(
67+
"socat_ip_address",
68+
default_value="192.168.100.10",
69+
description="Set IP address for TCP connection.",
70+
)
71+
)
72+
declared_arguments.append(
73+
DeclareLaunchArgument(
74+
"socat_port",
75+
default_value="54321",
76+
description="Set TCP port for connection.",
4277
)
4378
)
4479

@@ -107,6 +142,11 @@ def prepare_robot_state_publisher_node() -> Node:
107142
# tf_prefix is implicitly used in ParameterValue()
108143
tf_prefix = LaunchConfiguration("tf_prefix", default="") # noqa: F841
109144
use_fake_hardware = LaunchConfiguration("use_fake_hardware")
145+
frequency_hz = LaunchConfiguration("frequency_hz")
146+
tty_port = LaunchConfiguration("tty_port")
147+
create_socat_tty = LaunchConfiguration("create_socat_tty")
148+
socat_ip_address = LaunchConfiguration("socat_ip_address")
149+
socat_port = LaunchConfiguration("socat_port")
110150

111151
robot_description_str = Command(
112152
[
@@ -122,6 +162,24 @@ def prepare_robot_state_publisher_node() -> Node:
122162
" ",
123163
"use_fake_hardware:=",
124164
use_fake_hardware,
165+
" ",
166+
"tf_prefix:=",
167+
tf_prefix,
168+
" ",
169+
"frequency_hz:=",
170+
frequency_hz,
171+
" ",
172+
"tty_port:=",
173+
tty_port,
174+
" ",
175+
"create_socat_tty:=",
176+
create_socat_tty,
177+
" ",
178+
"socat_ip_address:=",
179+
socat_ip_address,
180+
" ",
181+
"socat_port:=",
182+
socat_port,
125183
]
126184
)
127185
return Node(

robotiq_hande_driver/hardware/src/hande_hardware_interface.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ HWI::CallbackReturn RobotiqHandeHardwareInterface::on_init(
3838
bool manage_virutal_serial = str_to_lower(info_.hardware_parameters["create_socat_tty"])
3939
== "true";
4040
if(manage_virutal_serial) {
41-
auto ip_addr = info_.hardware_parameters["ip_adress"];
42-
auto port = info_.hardware_parameters["port"];
41+
auto ip_addr = info_.hardware_parameters["socat_ip_address"];
42+
auto port = info_.hardware_parameters["socat_port"];
4343
auto tty_port = info_.hardware_parameters["tty_port"];
4444

4545
RCLCPP_INFO(
@@ -173,7 +173,7 @@ std::vector<HWI::CommandInterface> RobotiqHandeHardwareInterface::export_command
173173
hardware_interface::HW_IF_POSITION,
174174
&cmd_position_));
175175
command_interfaces.emplace_back(hardware_interface::CommandInterface(
176-
info_.joints[LEFT_FINGER_JOINT_ID].name, hardware_interface::HW_IF_POSITION, &cmd_force_));
176+
info_.joints[LEFT_FINGER_JOINT_ID].name, hardware_interface::HW_IF_EFFORT, &cmd_force_));
177177

178178
return command_interfaces;
179179
}

robotiq_hande_driver/test/test_load_hw_interface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class TestHWInterface : public ::testing::Test {
4747
<param name="slave_id">9</param>
4848
<param name="frequency_hz">10</param>
4949
<param name="create_socat_tty">false</param>
50-
<param name="ip_adress">127.0.0.1</param>
51-
<param name="port">8888</param>
50+
<param name="socat_ip_address">127.0.0.1</param>
51+
<param name="socat_port">8888</param>
5252
</hardware>
5353
<joint name="joint1">
5454
<command_interface name="position"/>

0 commit comments

Comments
 (0)