Skip to content

Commit 1ebafe3

Browse files
authored
Improve README setup instructions (#27)
1 parent 7728dc7 commit 1ebafe3

File tree

5 files changed

+171
-28
lines changed

5 files changed

+171
-28
lines changed

README.md

Lines changed: 104 additions & 23 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,18 +30,112 @@ 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
37+
```
38+
39+
Send a command to the gripper in another terminal:
40+
```bash
5041
ros2 action send_goal /gripper_action_controller/gripper_cmd control_msgs/action/GripperCommand \
5142
"command:
5243
position: 0.0
5344
max_effort: 0.0
5445
"
5546
```
5647

57-
### Examples
58-
**An example integration usage can be find** in the [AGH-CEAI/aegis_ros](https://github.com/AGH-CEAI/aegis_ros) repository.
48+
## Connection modes
49+
50+
You can run the gripper in three ways.
51+
52+
### Without the physical hardware
53+
54+
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:
55+
```bash
56+
ros2 launch robotiq_hande_driver gripper_controller_preview.launch.py use_fake_hardware:=true
57+
```
58+
59+
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.
60+
61+
### Modbus RTU
62+
63+
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:
64+
65+
Computer → USB adapter ↔ RS485 ↔ Hand-E gripper
66+
67+
In this case, you need to set `use_fake_hardware:=false` and provide serial port to establish connection using `tty_port`:
68+
```bash
69+
ros2 launch robotiq_hande_driver gripper_controller_preview.launch.py use_fake_hardware:=false tty_port:=/dev/ttyUSB0
70+
```
71+
72+
You can check available serial devices with:
73+
```bash
74+
dmesg | grep tty
75+
```
76+
77+
or
78+
79+
```bash
80+
ls -l /dev/tty*
81+
```
82+
83+
Make sure your user has permissions to access the serial port:
84+
```bash
85+
sudo usermod -a -G dialout $USER
86+
```
87+
88+
### Modbus RTU tunneled over TCP via UR Tool Communication
89+
90+
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:
91+
92+
UR controller RS-485 tool port ↔ URCap forwarder ↔ TCP socket ↔ Computer
93+
94+
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`.
95+
96+
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:
97+
```bash
98+
ros2 launch robotiq_hande_driver gripper_controller_preview.launch.py \
99+
use_fake_hardware:=false \
100+
create_socat_tty:=true \
101+
tty_port:=/tmp/ttyUR \
102+
socat_ip_address:=192.168.1.2 \
103+
socat_port:=54321 \
104+
frequency_hz:=10 \
105+
launch_rviz:=true
106+
```
107+
108+
The driver will then use `tty_port:=/tmp/ttyUR` as if it were a real serial port.
109+
110+
You can also start `socat` manually, for example:
111+
```bash
112+
socat pty,link=/tmp/ttyUR,raw,ignoreeof,waitslave tcp:192.168.100.10:54321
113+
```
114+
115+
> [!WARNING]
116+
> 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**!
117+
> Both options will invoke the `socat` command to create the `/tmp/ttyUR` virtual serial port.
118+
> However, the initialization of the Hand-E driver may suffer from a race condition: **the tty link must exist before initialization**.
119+
> It is recommended to use the provided `create_socat_tty` option.
120+
121+
## Integration with (other) robots
122+
123+
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.
124+
125+
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.
126+
127+
Next, include this Xacro file in your main robot description tree at the appropriate tool link.
128+
129+
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).
130+
131+
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.
132+
133+
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)
134+
135+
> [!IMPORTANT]
136+
> The `robotiq_hande_driver` currently provides only a **hardware component** (i.e. _hardware interface_) to control the fingers' joints.
137+
138+
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.
59139

60140
---
61141
## Development notes
@@ -79,4 +159,5 @@ cd ~/ceai/ros_ws/build/robotiq_hande_driver
79159

80160
---
81161
## License
162+
82163
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.
@@ -19,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1921

2022
### Changed
2123

24+
* [PR-27](https://github.com/AGH-CEAI/robotiq_hande_driver/pull/27) - Renamed `ip_adress` to `socat_ip_address` and `port` to `socat_port`.
25+
2226
* [PR-21](https://github.com/AGH-CEAI/robotiq_hande_driver/pull/21) - Refactored the modbus communication to use multithreads:
2327
* Renamed `application.hpp/cpp` to `hande_gripper.hpp/cpp`.
2428
* Changed plain arrays `uint8_t bytes_[]` into `std::array<uint8_t, *>`.

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ HWI::CallbackReturn RobotiqHandeHardwareInterface::on_init(const HWI::HardwareIn
3737
bool manage_virutal_serial = str_to_lower(info_.hardware_parameters["create_socat_tty"])
3838
== "true";
3939
if(manage_virutal_serial) {
40-
auto ip_addr = info_.hardware_parameters["ip_adress"];
41-
auto port = info_.hardware_parameters["port"];
40+
auto ip_addr = info_.hardware_parameters["socat_ip_address"];
41+
auto port = info_.hardware_parameters["socat_port"];
4242
auto tty_port = info_.hardware_parameters["tty_port"];
4343

4444
RCLCPP_INFO(

robotiq_hande_driver/test/test_load_hw_interface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class TestHWInterface : public ::testing::Test {
3636
<param name="slave_id">9</param>
3737
<param name="frequency_hz">10</param>
3838
<param name="create_socat_tty">false</param>
39-
<param name="ip_adress">127.0.0.1</param>
40-
<param name="port">8888</param>
39+
<param name="socat_ip_address">127.0.0.1</param>
40+
<param name="socat_port">8888</param>
4141
</hardware>
4242
<joint name="joint1">
4343
<command_interface name="position"/>

0 commit comments

Comments
 (0)