Skip to content

Commit

Permalink
Merge branch 'main' into fix/goal_time_violated
Browse files Browse the repository at this point in the history
  • Loading branch information
fmauch authored May 22, 2024
2 parents 7bd9e36 + f5b9bd4 commit 5659b14
Show file tree
Hide file tree
Showing 49 changed files with 1,483 additions and 1,071 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: 3.10.4
- name: Install system hooks
run: sudo apt-get install clang-format-14 cppcheck
- uses: pre-commit/[email protected].0
- uses: pre-commit/[email protected].1
with:
extra_args: --all-files --hook-stage manual
6 changes: 3 additions & 3 deletions .github/workflows/coverage-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ on:
jobs:
coverage:
name: coverage build
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
container:
image: ubuntu:jammy
image: ubuntu:noble
strategy:
fail-fast: false
env:
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
file: ros_ws/lcov/total_coverage.info
flags: unittests
name: codecov-umbrella
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: colcon-logs-${{ matrix.os }}
path: ros_ws/log
1 change: 1 addition & 0 deletions .github/workflows/reusable_ici.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ jobs:
ROS_DISTRO: ${{ inputs.ros_distro }}
ROS_REPO: ${{ inputs.ros_repo }}
CMAKE_ARGS: -DUR_ROBOT_DRIVER_BUILD_INTEGRATION_TESTS=ON
ADDITIONAL_DEBS: docker.io netcat-openbsd # Needed for integration tests
4 changes: 2 additions & 2 deletions .github/workflows/update-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
steps:
# Setup pre-commit
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: 3.10.4
- name: Install pre-commit
Expand All @@ -28,7 +28,7 @@ jobs:
# Create pull request
- name: Create pull-request
id: cpr
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v6
with:
branch: update-ci/pre-commit-autoupdate
delete-branch: true
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ repos:

# Python hooks
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.15.1
hooks:
- id: pyupgrade
args: [--py36-plus]

- repo: https://github.com/psf/black
rev: 23.11.0
rev: 24.2.0
hooks:
- id: black
args: ["--line-length=100"]
Expand All @@ -51,7 +51,7 @@ repos:
args: ["--ignore=D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D401,D404"]

- repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
args: ["--ignore=E501,W503"]
Expand Down
4 changes: 2 additions & 2 deletions Universal_Robots_ROS2_Driver.iron.repos
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ repositories:
ros2_control:
type: git
url: https://github.com/ros-controls/ros2_control.git
version: master
version: iron
ros2_controllers:
type: git
url: https://github.com/ros-controls/ros2_controllers
version: master
version: iron
kinematics_interface:
type: git
url: https://github.com/ros-controls/kinematics_interface.git
Expand Down
9 changes: 9 additions & 0 deletions ur/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
Changelog for package ur
^^^^^^^^^^^^^^^^^^^^^^^^

2.4.5 (2024-05-16)
------------------

2.4.4 (2024-04-04)
------------------

2.4.3 (2024-02-02)
------------------

2.4.2 (2023-11-23)
------------------

Expand Down
2 changes: 1 addition & 1 deletion ur/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>ur</name>
<version>2.4.2</version>
<version>2.4.5</version>
<description>Metapackage for universal robots</description>
<maintainer email="[email protected]">Felix Exner</maintainer>
<maintainer email="[email protected]">Robert Wilbrandt</maintainer>
Expand Down
9 changes: 9 additions & 0 deletions ur_calibration/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
Changelog for package ur_calibration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2.4.5 (2024-05-16)
------------------

2.4.4 (2024-04-04)
------------------

2.4.3 (2024-02-02)
------------------

2.4.2 (2023-11-23)
------------------

Expand Down
69 changes: 1 addition & 68 deletions ur_calibration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,71 +8,4 @@ make use of this in ROS, you first have to extract the calibration information f
Though this step is not necessary, to control the robot using this driver, it is highly recommended
to do so, as end effector positions might be off in the magnitude of centimeters.

## Nodes
### calibration_correction
This node extracts calibration information directly from a robot, calculates the URDF correction and
saves it into a .yaml file.

In the launch folder of the ur_calibration package is a helper script:

```bash
$ ros2 launch ur_calibration calibration_correction.launch.py \
robot_ip:=<robot_ip> target_filename:="${HOME}/my_robot_calibration.yaml"
```

For the parameter `robot_ip` insert the IP address on which the ROS pc can reach the robot. As
`target_filename` provide an absolute path where the result will be saved to.

## Creating a calibration / launch package for all local robots
When dealing with multiple robots in one organization it might make sense to store calibration data
into a package dedicated to that purpose only. To do so, create a new package (if it doesn't already
exist)

```bash
# Replace your actual colcon_ws folder
$ cd <colcon_ws>/src
$ ros2 pkg create <organization_name>_ur_launch --build-type ament_cmake --dependencies ur_client_library \
--description "Package containing calibrations and launch files for our UR robots."
# Create a skeleton package
$ mkdir -p <organization_name>_ur_launch/etc
$ mkdir -p <organization_name>_ur_launch/launch
$ echo 'install(DIRECTORY etc launch DESTINATION share/${PROJECT_NAME})' >> <organization_name>_ur_launch/CMakeLists.txt
$ colcon build --packages-select <organization_name>_ur_launch
```

We can use the new package to store the calibration data in that package. We recommend naming each
robot individually, e.g. *ex-ur10-1*.

```bash
$ ros2 launch ur_calibration calibration_correction.launch.py \
robot_ip:=<robot_ip> \
target_filename:="$(ros2 pkg prefix <organization_name>_ur_launch)/share/<organization_name>_ur_launch/etc/ex-ur10-1_calibration.yaml"
```

To make life easier, we create a launchfile for this particular robot. We base it upon the
respective launchfile in the driver:

```bash
# Replace your actual colcon_ws folder
$ cd <colcon_ws>/src/<organization_name>_ur_launch/launch
$ cp $(ros2 pkg prefix ur_robot_driver)/share/ur_robot_driver/launch/ur_control.launch.py ex-ur10-1.launch.py
```

Next, modify the parameter section of the new launchfile to match your actual calibration:

```py
kinematics_params = PathJoinSubstitution(
[FindPackageShare("<organization_name>_ur_launch"), "etc", "", "ex-ur10-1_calibration.yaml"]
)

```

Then, anybody cloning this repository can startup the robot simply by launching

```bash
# Replace your actual colcon_ws folder
$ cd <colcon_ws>
$ colcon build --packages-select <organization_name>_ur_launch
$ ros2 launch <organization_name>_ur_launch ex-ur10-1.launch.py
robot_ip:=xxx.yyy.zzz.www ur_type:=ur5e use_mock_hardware:=false launch_rviz:=true
```
For details please see [doc/index.rst](doc/index.rst)
45 changes: 45 additions & 0 deletions ur_calibration/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

ur_calibration
==============

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.

Each UR robot is calibrated inside the factory giving exact forward and inverse kinematics. To also
make use of this in ROS, you first have to extract the calibration information from the robot.

Though this step is not necessary, to control the robot using this driver, it is highly recommended
to do so, as end effector positions might be off in the magnitude of centimeters.

Nodes
-----

calibration_correction
^^^^^^^^^^^^^^^^^^^^^^

This node extracts calibration information directly from a robot, calculates the URDF correction and
saves it into a .yaml file.

In the launch folder of the ur_calibration package is a helper script:

.. code-block:: bash
$ ros2 launch ur_calibration calibration_correction.launch.py \
robot_ip:=<robot_ip> target_filename:="${HOME}/my_robot_calibration.yaml"
For the parameter ``robot_ip`` insert the IP address on which the ROS pc can reach the robot. As
``target_filename`` provide an absolute path where the result will be saved to.

With that, you can launch your specific robot with the correct calibration using

.. code-block:: bash
$ ros2 launch ur_robot_driver ur_control.launch.py \
ur_type:=ur5e \
robot_ip:=192.168.56.101 \
kinematics_params_file:="${HOME}/my_robot_calibration.yaml"
Adapt the robot model matching to your robot.

Ideally, you would create a package for your custom workcell, as explained in `the custom workcell
tutorial
<https://github.com/UniversalRobots/Universal_Robots_ROS2_Tutorials/blob/main/my_robot_cell/doc/start_ur_driver.rst#extract-the-calibration>`_.
2 changes: 1 addition & 1 deletion ur_calibration/package.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package format="2">
<name>ur_calibration</name>
<version>2.4.2</version>
<version>2.4.5</version>
<description>Package for extracting the factory calibration from a UR robot and change it such that it can be used by ur_description to gain a correct URDF</description>

<maintainer email="[email protected]">Felix Exner</maintainer>
Expand Down
11 changes: 11 additions & 0 deletions ur_controllers/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
Changelog for package ur_controllers
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2.4.5 (2024-05-16)
------------------
* Use latched publishing for robot_mode and safety_mode
* Contributors: Felix Exner

2.4.4 (2024-04-04)
------------------

2.4.3 (2024-02-02)
------------------

2.4.2 (2023-11-23)
------------------
* Update read_state_from_hardware
Expand Down
64 changes: 1 addition & 63 deletions ur_controllers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,66 +11,4 @@ robot family. Currently this contains
* A **scaled_joint_trajectory_controller** that is similar to the *joint_trajectory_controller*,
but it uses the speed scaling reported by the robot to reduce progress in the trajectory.

## About this package
This package contains controllers not being available in the default `ros_control` set. They are
created to support more features offered by the UR robot family. Any of these controllers are
example implementations for certain features and are intended to be generalized and merged
into the default `ros_control` controller set at some future point.

## Controller description
This packages offers a couple of specific controllers that will be explained in the following
sections.
### ur_controllers/SpeedScalingStateBroadcaster
This controller publishes the current actual execution speed as reported by the robot. Values are
floating points between 0 and 1.

In the [`ur_robot_driver`](../ur_robot_driver) this is calculated by multiplying the two [RTDE](https://www.universal-robots.com/articles/ur/real-time-data-exchange-rtde-guide/) data
fields `speed_scaling` (which should be equal to the value shown by the speed slider position on the
teach pendant) and `target_speed_fraction` (Which is the fraction to which execution gets slowed
down by the controller).
### position_controllers/ScaledJointTrajectoryController and velocity_controllers/ScaledJointTrajectoryController
These controllers work similar to the well-known
[`joint_trajectory_controller`](http://wiki.ros.org/joint_trajectory_controller).

However, they are extended to handle the robot's execution speed specifically. Because the default
`joint_trajectory_controller` would interpolate the trajectory with the configured time constraints (ie: always assume maximum velocity and acceleration supported by the robot),
this could lead to significant path deviation due to multiple reasons:
- The speed slider on the robot might not be at 100%, so motion commands sent from ROS would
effectively get scaled down resulting in a slower execution.
- The robot could scale down motions based on configured safety limits resulting in a slower motion
than expected and therefore not reaching the desired target in a control cycle.
- Motions might not be executed at all, e.g. because the robot is E-stopped or in a protective stop
- Motion commands sent to the robot might not be interpreted, e.g. because there is no
[`external_control`](https://github.com/UniversalRobots/Universal_Robots_ROS_Driver#prepare-the-robot)
program node running on the robot controller.
- The program interpreting motion commands could be paused.

The following plot illustrates the problem:
![Trajectory execution with default trajectory controller](doc/traj_without_speed_scaling.png
"Trajectory execution with default trajectory controller")

The graph shows a trajectory with one joint being moved to a target point and back to its starting
point. As the joint's speed is limited to a very low setting on the teach pendant, speed scaling
(black line) activates and limits the joint speed (green line). As a result, the target
trajectory (light blue) doesn't get executed by the robot, but instead the pink trajectory is executed.
The vertical distance between the light blue line and the pink line is the path error in each
control cycle. We can see that the path deviation gets above 300 degrees at some point and the
target point at -6 radians never gets reached.

All of the cases mentioned above are addressed by the scaled trajectory versions. Trajectory execution
can be transparently scaled down using the speed slider on the teach pendant without leading to
additional path deviations. Pausing the program or hitting the E-stop effectively leads to
`speed_scaling` being 0 meaning the trajectory will not be continued until the program is continued.
This way, trajectory executions can be explicitly paused and continued.

With the scaled version of the trajectory controller the example motion shown in the previous diagram becomes:
![Trajectory execution with scaled_joint_trajectory_controller](doc/traj_with_speed_scaling.png
"Trajectory execution with scaled_joint_trajectory_controller")

The deviation between trajectory interpolation on the ROS side and actual robot execution stays minimal and the
robot reaches the intermediate setpoint instead of returning "too early" as in the example above.

Under the hood this is implemented by proceeding the trajectory not by a full time step but only by
the fraction determined by the current speed scaling. If speed scaling is currently at 50% then
interpolation of the current control cycle will start half a time step after the beginning of the
previous control cycle.
For more details please see [doc/index.rst](doc/index.rst)
Loading

0 comments on commit 5659b14

Please sign in to comment.