Skip to content

Commit f015749

Browse files
destogllivanov93AndyZe
authored
Add support for gpios, update MoveIt and ros2_control launching (#66)
* Add ur_msgs as dependency. * Bare bone tool io controller. * Register all non-joint interfaces. * Fix typo. * Configure state and command interfaces in gpio controller. * Fix clang issue. * Register needed services and publishers. * Reorganize state and command interfaces for easier enumeration. * Update licence. * Include success check for io service. * Fix ci. * Publish data of interest. * Clang tidy. * Apply suggestions from code review * Launch Arguments for xacro are working, not all params added * Moved files and one step further with the Arguemnts * Add launch for all version of UR robots * Small updated from offline review * Some rewrapping and testing GPIO controller. * Reduce unintended changes * Readme grammar check and minor re-org * Minor comment and typo cleanup * Reduce duplication of default launch args * Initial add of moveit configs * Added MoveIt configs and example launch file * Remove unused mongodb node * Enabled monogodb * Add condistion check for dashboard client and start command for MoveIt. * Added protection to add false joints * Debug io controller and interfaces * Use scaled controller in example * Removed dashboard client node from default start * Updated README and use fixed frame in MoveIt. * [WIP] Hard-code launch config for UR5e * RViz MoveIt plugin actually loads. Controllers do not. * Revert changes and try correct MoveIt. * Set speed scaling in percetange. * Separete control and moveit launch files an correct MoveIt configuration * Add again planning scene parameters Co-authored-by: Lovro <[email protected]> Co-authored-by: AndyZe <[email protected]>
1 parent 5d1af17 commit f015749

File tree

59 files changed

+1757
-1808
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1757
-1808
lines changed

README.md

Lines changed: 109 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,140 @@
11
# Universal Robots ROS2 Driver
22

3-
Alpha version of the ROS2 Universal Robots driver. Should be transferred to the Universal Robots org when ready.
3+
Beta version of the ROS2 Universal Robots driver. Should be transferred to the Universal Robots org when ready.
44

5-
## General driver information
6-
Driver currently only supports position joint interface which means only position-based controllers can be used with
7-
the ROS2 driver. [Universal Robots Client Library](https://github.com/UniversalRobots/Universal_Robots_Client_Library) includes also
8-
velocity-based control whose support will be addressed in additional development of ROS2 driver.
95

10-
## Requirements
6+
## Packages in the Repository:
117

12-
Follow the [instructions](https://github.com/UniversalRobots/Universal_Robots_ROS_Driver#setting-up-a-ur-robot-for-ur_robot_driver) in the paragraph
13-
[`Prepare the robot` ](https://github.com/UniversalRobots/Universal_Robots_ROS_Driver#prepare-the-robot)
8+
- `ur_bringup` - launch file and run-time configurations, e.g. controllers.
9+
- `ur_controllers` - implementations of controllers specific for UR robots.
10+
- `ur_dashboard_msgs` - package defining messages used by dashboard node.
11+
- `ur_description` - description files for the UR robots: meshes, URDF/XACRO files, etc.
12+
- `ur_moveit` - example MoveIt configuration for UR robots.
13+
- `ur_robot_driver` - driver / hardware interface for communication with UR robots.
1414

15-
## Build Instructions
1615

17-
To build this package follow the [instructions](https://index.ros.org/doc/ros2/Tutorials/Workspace/Creating-A-Workspace/) for installation of ROS2.
16+
## Getting Started
1817

19-
After installation create a ROS Foxy workspace:
20-
```
21-
cd $HOME
22-
mkdir -p ws_driver/src
23-
cd ws_driver
24-
source /opt/ros/$ROS_DISTRO/setup.bash
18+
1. [Install ROS2 Foxy](https://index.ros.org/doc/ros2/Installation/Foxy/Linux-Install-Debians/).
2519

26-
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
20+
2. Create a new ROS2 workspace:
21+
```
22+
export COLCON_WS=~/workspace/ros_ws_foxy_ur_driver
23+
mkdir -p $COLCON_WS/src
24+
```
2725

28-
```
26+
3. Pull relevant packages, install dependencies, compile, and source the workspace by using:
27+
```
28+
cd $COLCON_WS
29+
git clone [email protected]:PickNikRobotics/Universal_Robots_ROS2_Driver.git src/Universal_Robots_ROS2_Driver --branch develop
30+
vcs import src --skip-existing --input src/Universal_Robots_ROS2_Driver/Universal_Robots_ROS2_Driver.repos
31+
rosdep install --ignore-src --from-paths src -y -r
32+
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
33+
source install/setup.bash
34+
```
2935

30-
Clone this repo into the `src/` directory, then:
36+
**NOTE**: If you are a ROS2 beginner and get lost consult the [references - section](#references).
3137

32-
```
33-
# Clone source-based dependencies into src/ directory
34-
vcs import --skip-existing --input src/Universal_Robots_ROS2_Driver/.repos.yaml src
3538

36-
# Install package-based dependencies
37-
rosdep install -y --rosdistro $ROS_DISTRO --ignore-src --from-paths src
39+
## How to Use the ROS2 Driver for UR Robots
3840

39-
# Build sources
40-
source /opt/ros/$ROS_DISTRO/setup.bash
41-
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
42-
```
43-
Source the workspace:
41+
For starting the driver there are three main launch files in the `ur_bringup` package.
4442

45-
```
46-
cd ~/ws_driver
47-
source install/setup.bash
48-
```
43+
- `ur_control.launch.py` - starts ros2_control node including hardware interface, joint state broadcaster and a controller. This launch file also starts `dashboard_client` if real robot is used.
44+
- `ur_moveit.launch.py` - start everything from `ur_control.launch.py` plus an example scenario with [MoveIt2](https://moveit.ros.org/).
45+
- `ur_dashboard_client.launch.py` - start the dashboard client for UR robots.
4946

50-
Start the driver:
47+
Also, there are predefined launch files for all supported types of UR robots.
5148

52-
```
53-
ros2 launch ur_ros2_control_demos ur5_e_system_position_only.launch.py
54-
```
49+
The arguments for launch files can be listed using `ros2 launch ur_bringup <launch_file_name>.launch.py --show-args`.
50+
The most relevant arguments are the following:
5551

56-
Start the `joint_state_controller`:
52+
- `ur_type` (*mandatory*) - a type of used UR robot (*ur3*, *ur3e*, *ur5*, *ur5e*, *ur10*, *ur10e*, or *ur16e*).
53+
- `robot_ip` (*mandatory*) - IP address by which the root can be reached.
54+
- `use_fake_hardware` (default: *false*) - use simple hardware emulator from ros2_control.
55+
Useful for testing launch files, descriptions, etc. See explanation below.
56+
- `fake_sensor_commands` (default: *false*) - enables setting sensor values for the hardware emulators.
57+
Useful for offline testing of controllers.
58+
- `robot_controller` (default: *joint_trajectory_controller*) - controller for robot joints to be started.
59+
Available controllers: *joint_trajectory_controller*, *scaled_joint_trajectory_controller*.
60+
Note: *joint_state_broadcaster*, *speed_scaling_state_broadcaster*, *force_torque_sensor_broadcaster*, and *io_and_status_controller* will always start.
5761

58-
```
59-
ros2 control load_start_controller joint_state_controller
60-
```
62+
*HINT*: list all loaded controllers using `ros2 control list_controllers` command.
6163

62-
Start the `forward_command_controller`:
64+
**NOTE**: The package can simulate hardware with the ros2_control `FakeSystem`. This emulator enables an environment for testing of "piping" of hardware and controllers, as well as testing robot's descriptions. For more details see [ros2_control documentation](https://ros-controls.github.io/control.ros.org/) for more details..
6365

64-
```
65-
ros2 control load_start_controller forward_command_controller_position
66-
```
66+
### Example Commands for Testing the Driver
6767

68-
## Run a test node
69-
Run a test node which will publish joint commands on /forward_command_controller_position/commands (std_msgs::msg::Float64MultiArray)
70-
after checking the current joint states (to create minimal increment for safety). The node commands increment of 0.1 radians for each
71-
joint. The commands are incremented in regards to /joint_states found when the node is run.
68+
1. To start the robot driver and controllers, use:
69+
```
70+
ros2 launch ur_bringup ur_control.launch.py ur_type:=ur5e robot_ip:=yyy.yyy.yyy.yyy use_fake_hardware:=true
71+
```
72+
For an offline test with the emulated hardware you can just copy-paste this line.
73+
To run on the hardware, write the IP address of your robot and omit the `use_fake_hardware` argument.
7274

73-
```
74-
ros2 run ur_ros2_control_demos test_driver
75-
```
75+
**NOTE**: If controllers are not starting automatically, i.e., the robot state is not shown in rviz, you can start them manually:
76+
```
77+
ros2 control load_controller --state joint_state_broadcaster
78+
ros2 control load_controller --state joint_trajectory_controller
79+
```
7680

77-
## Contributor guidelines
78-
Code is auto-formatted with clang-format 10 whenever a git commit is made. Please ensure these dependencies are installed so pre-commit formatting works:
81+
To check the controllers' state use `ros2 control list_controllers` command.
7982

80-
`pip3 install pre-commit`
81-
`sudo apt install clang-format-10`
83+
2. Send some goal to the Joint Trajectory Controller by using a demo node from [ros2_control_demos](https://github.com/ros-controls/ros2_control_demos) package by starting the following command in another terminal:
84+
```
85+
ros2 launch ur_bringup test_joint_trajectory_controller.launch.py
86+
```
87+
After a few seconds the robot should move.
8288

83-
Prepare the pre-commit formatting to run like this:
89+
3. To test another controller, simply define it using `robot_controller` argument:
90+
```
91+
ros2 launch ur_bringup ur_control.launch.py ur_type:=ur5e robot_ip:=yyy.yyy.yyy.yyy robot_controller:=scaled_joint_trajectory_controller use_fake_hardware:=true
92+
```
93+
And send the command using demo node:
94+
```
95+
ros2 launch ur_bringup test_scaled_joint_trajectory_controller.launch.py
96+
```
97+
After a few seconds the robot should move (or jump when using emulation).
98+
99+
4. To test the driver with example MoveIt-setup, start `ur_control` launch file and then start MoveIt using the following command:
100+
```
101+
ros2 launch ur_bringup ur_moveit.launch.py ur_type:=ur5e robot_ip:="xxx.xxx" use_fake_hardware:=true
102+
```
103+
Now you should be able to use MoveIt Plugin in rviz2 to plan and execute trajectories with the robot.
104+
**NOTE**: This results in two instances of rviz2. You can safely close the one without *MotionPlanning* panel.
105+
106+
If you have **issues** shows the correct configuration5 of the robot, try removing and re-adding *MotionPlanning* display.
107+
108+
109+
## Expected Changes in the Near Future
84110

85-
`pre-commit install`
111+
- Using upstream `force_torque_sensor_broadcaster` (ros-controls/ros2_controllers#152)
112+
- Trajectory control currently only supports position commands. In the future, velocity control will be added.
113+
114+
115+
## Contributor Guidelines
116+
Code is auto-formatted with clang-format 10 whenever a git commit is made. Please ensure these dependencies are installed so pre-commit formatting works:
117+
```
118+
pip3 install pre-commit
119+
sudo apt install clang-format-10
120+
```
121+
122+
Prepare the pre-commit formatting to run like this:
123+
```
124+
pre-commit install`
125+
```
86126

87127

88-
## Stuff to add
128+
## References
89129

90-
1. Explation of packages
91-
2. How to start:
92-
- Simple simulation with FakeSystem
93-
- Hardware
130+
Here are some useful references for developing with ROS2:
94131

95-
3. How to test:
96-
- Using forward_command_controller
97-
- Using joint_trajectory_controller
132+
- [Official ROS2 Tutorials](https://index.ros.org/doc/ros2/Tutorials/)
133+
* [Luanchfile](https://index.ros.org/doc/ros2/Tutorials/Launch-Files/Creating-Launch-Files/)
134+
* [Package](https://index.ros.org/doc/ros2/Tutorials/Creating-Your-First-ROS2-Package/)
135+
* [Parameters](https://index.ros.org/doc/ros2/Tutorials/Parameters/Understanding-ROS2-Parameters/)
136+
* [Workspace](https://index.ros.org/doc/ros2/Tutorials/Workspace/Creating-A-Workspace/)
137+
- [Example ROS packages](https://github.com/ros2/examples)
138+
- [Colcon Documentation](https://colcon.readthedocs.io/en/released/#)
139+
- [ROS2 Design Documentation](https://design.ros2.org/)
140+
- [ROS2 Launch Architecture](https://github.com/ros2/launch/blob/master/launch/doc/source/architecture.rst)

Universal_Robots_ROS2_Driver.ci.repos

Lines changed: 0 additions & 1 deletion
This file was deleted.

Universal_Robots_ROS2_Driver.repos

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ repositories:
33
type: git
44
url: https://github.com/ros-controls/control_msgs.git
55
version: foxy-devel
6-
geometric_shapes:
6+
moveit2:
77
type: git
8-
url: https://github.com/ros-planning/geometric_shapes.git
9-
version: ros2
10-
realtime_tools:
11-
type: git
12-
url: https://github.com/ros-controls/realtime_tools.git
13-
version: foxy-devel
8+
url: https://github.com/ros-planning/moveit2.git
9+
version: main
1410
ros2_control:
1511
type: git
1612
url: https://github.com/ros-controls/ros2_control.git
1713
version: master
14+
ros2_control_demos:
15+
type: git
16+
url: https://github.com/ros-controls/ros2_control_demos.git
17+
version: add_demo_nodes
1818
ros2_controllers:
1919
type: git
2020
url: https://github.com/ros-controls/ros2_controllers.git
@@ -27,7 +27,11 @@ repositories:
2727
type: git
2828
url: https://github.com/PickNikRobotics/Universal_Robots_Client_Library.git
2929
version: foxy-devel
30-
warehouse_ros:
30+
ur_msgs:
31+
type: git
32+
url: https://github.com/destogl/ur_msgs.git
33+
version: ros2
34+
warehouse_ros_mongo:
3135
type: git
32-
url: https://github.com/ros-planning/warehouse_ros.git
36+
url: https://github.com/ros-planning/warehouse_ros_mongo
3337
version: ros2

ur_bringup/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(ur_bringup)
3+
4+
find_package(ament_cmake REQUIRED)
5+
6+
install(DIRECTORY config launch
7+
DESTINATION share/${PROJECT_NAME}
8+
)
9+
10+
ament_package()

ur_ros2_control_demos/config/test_goal_publishers_config.yaml renamed to ur_bringup/config/test_goal_publishers_config.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
publisher_forward_position_controller:
1+
publisher_scaled_joint_trajectory_controller:
22
ros__parameters:
33

4-
controller_name: "forward_position_controller"
5-
wait_sec_between_publish: 5
4+
controller_name: "scaled_joint_trajectory_controller"
5+
wait_sec_between_publish: 6
66

77
goal_names: ["pos1", "pos2", "pos3", "pos4"]
88
pos1: [0.785, -1.57, 0.785, 0.785, 0.785, 0.785]
99
pos2: [0.0, -1.57, 0.0, 0.0, 0.0, 0.0]
10-
pos3: [-0.785, -1.57, -0.785, -0.785, -0.785, -0.785]
10+
pos3: [0.0, -1.57, 0.0, 0.0, -0.785, 0.0]
1111
pos4: [0.0, -1.57, 0.0, 0.0, 0.0, 0.0]
1212

13+
joints:
14+
- shoulder_pan_joint
15+
- shoulder_lift_joint
16+
- elbow_joint
17+
- wrist_1_joint
18+
- wrist_2_joint
19+
- wrist_3_joint
20+
1321

1422
publisher_joint_trajectory_controller:
1523
ros__parameters:
@@ -20,7 +28,7 @@ publisher_joint_trajectory_controller:
2028
goal_names: ["pos1", "pos2", "pos3", "pos4"]
2129
pos1: [0.785, -1.57, 0.785, 0.785, 0.785, 0.785]
2230
pos2: [0.0, -1.57, 0.0, 0.0, 0.0, 0.0]
23-
pos3: [-0.785, -1.57, -0.785, -0.785, -0.785, -0.785]
31+
pos3: [0.0, -1.57, 0.0, 0.0, -0.785, 0.0]
2432
pos4: [0.0, -1.57, 0.0, 0.0, 0.0, 0.0]
2533

2634
joints:

ur_ros2_control_demos/config/ur_controllers.yaml renamed to ur_bringup/config/ur_controllers.yaml

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,44 @@ controller_manager:
22
ros__parameters:
33
update_rate: 600 # Hz
44

5-
forward_position_controller:
6-
type: forward_command_controller/ForwardCommandController
5+
joint_state_broadcaster:
6+
type: joint_state_broadcaster/JointStateBroadcaster
77

8-
joint_state_controller:
9-
type: joint_state_controller/JointStateController
8+
io_and_status_controller:
9+
type: ur_controllers/GPIOController
1010

11-
speed_scaling_state_controller:
12-
type: ur_controllers/SpeedScalingStateController
11+
speed_scaling_state_broadcaster:
12+
type: ur_controllers/SpeedScalingStateBroadcaster
13+
14+
force_torque_sensor_broadcaster:
15+
type: ur_controllers/ForceTorqueStateBroadcaster
1316

1417
joint_trajectory_controller:
1518
type: joint_trajectory_controller/JointTrajectoryController
1619

17-
force_torque_state_controller:
18-
type: ur_controllers/ForceTorqueStateController
19-
2020
scaled_joint_trajectory_controller:
2121
type: ur_controllers/ScaledJointTrajectoryController
2222

23+
24+
speed_scaling_state_broadcaster:
25+
ros__parameters:
26+
state_publish_rate: 100.0
27+
28+
29+
force_torque_sensor_broadcaster:
30+
ros__parameters:
31+
sensor_name: tcp_fts_sensor
32+
state_interface_names:
33+
- force.x
34+
- force.y
35+
- force.z
36+
- torque.x
37+
- torque.y
38+
- torque.z
39+
frame_id: tool0
40+
topic_name: ft_data
41+
42+
2343
joint_trajectory_controller:
2444
ros__parameters:
2545
joints:
@@ -36,6 +56,7 @@ joint_trajectory_controller:
3656
stopped_velocity_tolerance: 0.0
3757
goal_time: 0.0
3858

59+
3960
scaled_joint_trajectory_controller:
4061
ros__parameters:
4162
joints:
@@ -51,31 +72,3 @@ scaled_joint_trajectory_controller:
5172
constraints:
5273
stopped_velocity_tolerance: 0.2
5374
goal_time: 0.0
54-
55-
speed_scaling_state_controller:
56-
ros__parameters:
57-
state_publish_rate: 100.0
58-
59-
forward_position_controller:
60-
ros__parameters:
61-
joints:
62-
- shoulder_pan_joint
63-
- shoulder_lift_joint
64-
- elbow_joint
65-
- wrist_1_joint
66-
- wrist_2_joint
67-
- wrist_3_joint
68-
interface_name: position
69-
70-
force_torque_state_controller:
71-
ros__parameters:
72-
sensor_name: tcp_fts_sensor
73-
state_interface_names:
74-
- fx
75-
- fy
76-
- fz
77-
- tx
78-
- ty
79-
- tz
80-
frame_id: tool0
81-
topic_name: ft_data

0 commit comments

Comments
 (0)