Skip to content

Commit e448b15

Browse files
Felix Exnerurmahp
andauthored
Add ur_calibration package (#451)
Co-authored-by: Mads Holm Peters <[email protected]>
1 parent 0191f9d commit e448b15

File tree

11 files changed

+1281
-0
lines changed

11 files changed

+1281
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ The driver is compatible across the entire line of UR robots -- from 3 kg payloa
132132
## Packages in the Repository:
133133

134134
- `ur_bringup` - launch file and run-time configurations, e.g. controllers.
135+
- `ur_calibration` - tool for extracting calibration information from a real robot.
135136
- `ur_controllers` - implementations of controllers specific for UR robots.
136137
- `ur_dashboard_msgs` - package defining messages used by dashboard node.
137138
- `ur_description` - description files for the UR robots: meshes, URDF/XACRO files, etc.
@@ -175,6 +176,17 @@ The driver is compatible across the entire line of UR robots -- from 3 kg payloa
175176

176177
4. In the Program tab of the teach pendant, navigate to the URCaps section on the left and add the external control to the robot program by clicking on it. The program can then be executed by pressing the play button. Make sure the robot is turned on. The robot power status will be displayed on the bottom left.
177178

179+
### Extract calibration information
180+
181+
Each UR robot is calibrated inside the factory giving exact forward and inverse kinematics. To also
182+
make use of this in ROS, you first have to extract the calibration information from the robot.
183+
184+
Though this step is not necessary to control the robot using this driver, it is highly recommended
185+
to do so, as otherwise endeffector positions might be off in the magnitude of centimeters.
186+
187+
See the [`ur_calibration`](ur_calibration/README.md) package's documentation for details on
188+
calibration extraction and handling.
189+
178190
## Usage
179191

180192
For starting the driver there are three main launch files in the `ur_bringup` package.

ur_calibration/CMakeLists.txt

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(ur_calibration)
3+
4+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
5+
add_compile_options(-Wall -Wextra -Wpedantic)
6+
endif()
7+
8+
add_compile_options(-Wno-unused-parameter)
9+
10+
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
11+
message("${PROJECT_NAME}: You did not request a specific build type: selecting 'RelWithDebInfo'.")
12+
set(CMAKE_BUILD_TYPE RelWithDebInfo)
13+
endif()
14+
15+
find_package(ament_cmake REQUIRED)
16+
find_package(rclcpp REQUIRED)
17+
find_package(ur_robot_driver REQUIRED)
18+
19+
find_package(Eigen3 REQUIRED)
20+
find_package(yaml-cpp REQUIRED)
21+
find_package(ur_client_library REQUIRED)
22+
23+
set(YAML_CPP_INCLUDE_DIRS ${YAML_CPP_INCLUDE_DIR})
24+
25+
###########
26+
## Build ##
27+
###########
28+
29+
include_directories(
30+
include
31+
${EIGEN3_INCLUDE_DIRS}
32+
${YAML_CPP_INCLUDE_DIRS}
33+
)
34+
35+
add_executable(calibration_correction
36+
src/calibration.cpp
37+
src/calibration_consumer.cpp
38+
src/calibration_correction.cpp
39+
)
40+
target_include_directories(calibration_correction PRIVATE include)
41+
target_link_libraries(calibration_correction
42+
${YAML_CPP_LIBRARIES}
43+
ur_client_library::urcl
44+
)
45+
ament_target_dependencies(
46+
calibration_correction
47+
rclcpp
48+
ur_robot_driver
49+
)
50+
51+
install(TARGETS calibration_correction
52+
RUNTIME DESTINATION lib/${PROJECT_NAME}
53+
)
54+
55+
install(DIRECTORY include/
56+
DESTINATION include
57+
)
58+
59+
install(DIRECTORY launch
60+
DESTINATION share/${PROJECT_NAME}
61+
)
62+
63+
## Add gtest based cpp test target and link libraries
64+
if(BUILD_TESTING)
65+
find_package(ament_cmake_gmock REQUIRED)
66+
67+
# Get the first item (it will be the build space version of the build path).
68+
list(GET ament_index_build_path 0 ament_index_build_path)
69+
if(WIN32)
70+
# On Windows prevent CMake errors and prevent it being evaluated as a list.
71+
string(REPLACE "\\" "/" ament_index_build_path "${ament_index_build_path}")
72+
endif()
73+
74+
ament_add_gmock(
75+
calibration_test
76+
test/calibration_test.cpp
77+
src/calibration.cpp
78+
)
79+
target_include_directories(calibration_test PRIVATE include ${EIGEN3_INCLUDE_DIRS} ${YAML_CPP_INCLUDE_DIRS})
80+
target_link_libraries(calibration_test ${rclcpp_LIBRARIES} ${EIGEN3_LIBRARIES} ${YAML_CPP_LIBRARIES} ur_client_library::urcl)
81+
endif()
82+
83+
ament_export_include_directories(
84+
include
85+
)
86+
ament_export_dependencies(
87+
ur_robot_driver
88+
rclcpp
89+
)
90+
ament_package()

ur_calibration/README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# ur_calibration
2+
3+
Package for extracting the factory calibration from a UR robot and changing it to be used by `ur_description` to gain a correct URDF model.
4+
5+
Each UR robot is calibrated inside the factory giving exact forward and inverse kinematics. To also
6+
make use of this in ROS, you first have to extract the calibration information from the robot.
7+
8+
Though this step is not necessary, to control the robot using this driver, it is highly recommended
9+
to do so, as end effector positions might be off in the magnitude of centimeters.
10+
11+
## Nodes
12+
### calibration_correction
13+
This node extracts calibration information directly from a robot, calculates the URDF correction and
14+
saves it into a .yaml file.
15+
16+
In the launch folder of the ur_calibration package is a helper script:
17+
18+
```bash
19+
$ ros2 launch ur_calibration calibration_correction.launch.py \
20+
robot_ip:=<robot_ip> target_filename:="${HOME}/my_robot_calibration.yaml"
21+
```
22+
23+
For the parameter `robot_ip` insert the IP address on which the ROS pc can reach the robot. As
24+
`target_filename` provide an absolute path where the result will be saved to.
25+
26+
## Creating a calibration / launch package for all local robots
27+
When dealing with multiple robots in one organization it might make sense to store calibration data
28+
into a package dedicated to that purpose only. To do so, create a new package (if it doesn't already
29+
exist)
30+
31+
```bash
32+
# Replace your actual colcon_ws folder
33+
$ cd <colcon_ws>/src
34+
$ ros2 pkg create <organization_name>_ur_launch --build-type ament_cmake --dependencies ur_client_library \
35+
--description "Package containing calibrations and launch files for our UR robots."
36+
# Create a skeleton package
37+
$ mkdir -p <organization_name>_ur_launch/etc
38+
$ mkdir -p <organization_name>_ur_launch/launch
39+
$ echo 'install(DIRECTORY etc launch DESTINATION share/${PROJECT_NAME})' >> <organization_name>_ur_launch/CMakeLists.txt
40+
$ colcon build --packages-select <organization_name>_ur_launch
41+
```
42+
43+
We can use the new package to store the calibration data in that package. We recommend naming each
44+
robot individually, e.g. *ex-ur10-1*.
45+
46+
```bash
47+
$ ros2 launch ur_calibration calibration_correction.launch.py \
48+
robot_ip:=<robot_ip> \
49+
target_filename:="$(ros2 pkg prefix <organization_name>_ur_launch)/share/<organization_name>_ur_launch/etc/ex-ur10-1_calibration.yaml"
50+
```
51+
52+
To make life easier, we create a launchfile for this particular robot. We base it upon the
53+
respective launchfile in the driver:
54+
55+
```bash
56+
# Replace your actual colcon_ws folder
57+
$ cd <colcon_ws>/src/<organization_name>_ur_launch/launch
58+
$ cp $(ros2 pkg prefix ur_bringup)/share/ur_bringup/launch/ur_control.launch.py ex-ur10-1.launch.py
59+
```
60+
61+
Next, modify the parameter section of the new launchfile to match your actual calibration:
62+
63+
```py
64+
kinematics_params = PathJoinSubstitution(
65+
[FindPackageShare("<organization_name>_ur_launch"), "etc", "", "ex-ur10-1_calibration.yaml"]
66+
)
67+
68+
```
69+
70+
Then, anybody cloning this repository can startup the robot simply by launching
71+
72+
```bash
73+
# Replace your actual colcon_ws folder
74+
$ cd <colcon_ws>
75+
$ colcon build --packages-select <organization_name>_ur_launch
76+
$ ros2 launch <organization_name>_ur_launch ex-ur10-1.launch.py
77+
robot_ip:=xxx.yyy.zzz.www ur_type:=ur5e use_fake_hardware:=false launch_rviz:=true
78+
```

0 commit comments

Comments
 (0)