Skip to content

Commit

Permalink
Add activation tests for iiqka and kss drivers (#138)
Browse files Browse the repository at this point in the history
* fix doc

* add test that also activates the driver

* add activation test for rsi

* fix effort controller name

* run Ci weekly

* add test_depend

* add kuka_controllers as exec_depend

* fix depends

* try test_depend

* add upstream

* try hacky upstream ws solution

* fix deps

* format

* fix md and add ptp home

* remove post_shutdown

* extend md with krl home pos

---------

Co-authored-by: Aron Svastits <svastits1@gmail.com>
  • Loading branch information
Svastits and Aron Svastits authored Jan 12, 2024
1 parent 0985ef3 commit 9a0b8c6
Show file tree
Hide file tree
Showing 17 changed files with 205 additions and 26 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/industrial_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ on:
branches:
- master

schedule:
# Run every Monday at 1PM UTC
- cron: 0 13 * * 1

jobs:
industrial_ci:
name: ROS-Industrial CI
Expand All @@ -32,7 +36,9 @@ jobs:
BUILDER: colcon
ANALYZER: sonarqube
TEST_COVERAGE: true
UPSTREAM_WORKSPACE: 'github:kroshu/kuka_robot_descriptions#master'
# Hacky solution needed to be able to build upstream WS:
# kuka_driver_interfaces and kuka_drivers_core must be also added to upstream
UPSTREAM_WORKSPACE: 'github:kroshu/kuka_robot_descriptions#master github:kroshu/kuka_controllers#master github:kroshu/kuka_drivers#master -kuka_drivers/examples -kuka_drivers/kuka_drivers -kuka_drivers/kuka_iiqka_eac_driver -kuka_drivers/kuka_kss_rsi_driver -kuka_drivers/kuka_sunrise_fri_driver'
CMAKE_ARGS: '-DMOCK_FRI=ON'
ROS_DISTRO: humble
env:
Expand Down
25 changes: 8 additions & 17 deletions doc/wiki/KSS_RSI.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,13 @@ Windows runs behind the SmartHMI on the teach pad. Make sure that the **Windows
There should already be an interface checked out as the **Windows interface**.
- **Windows interface checkbox** should be checked.
2. Add a new network for RSI:

**KRC4:**
- Minimize the SmartHMI (**Start-up > Service > Minimize HMI**).
- Run **RSI-Network** from the Windows Start menu (**All Programs > RSI-Network**).
- Check that the **Network - Kuka User Interface** shows the Windows interface with the specified IP address.
- Add a new IP address on another subnet for the **RSI interface**.
- Select the entry **New** under **RSI Ethernet** in the tree structure and press **Edit**.
- Enter the IP address and confirm with **OK**.
- Close **RSI-Network** and maximize the SmartHMI.

**KRC5:**
- Press the **Advanced** button and **New interface**.
- Select **Mixed IP address** and keep the default **Receiving task: Target subnet** and **Real-time receiving Task: UDP**
- Set the IP address to a different subnet then the **KLI interface**.
- **Default gateway**: leave it empty
- **Windows interface checkbox** should NOT be checked
- Press the **Advanced** button and **New interface**.
- Select **Mixed IP address** and keep the default settings:
- **Receiving task: Target subnet**
- **Real-time receiving Task: UDP**
- Set the IP address to a different subnet then the **KLI interface**.
- **Default gateway**: leave it empty
- **Windows interface checkbox** should NOT be checked

3. Reboot the controller with a cold restart (**Shutdown > Check *Force cold start* and *Reload files* > Reboot control PC**).

Expand All @@ -48,7 +39,7 @@ There are 3 files necessary for RSI that are available in the `krl` directory:
- The `IP_NUMBER` tag should be modified so that it corresponds to the IP address previously added for your (real-time) PC.
- The `PORT` might be left as it is (59152), but can be also changed if a different port is to be used on the client machine.

- `ros_rsi.src`: This contains the KRL program that starts external control and should not be modified.
- `ros_rsi.src`: This contains the KRL program that starts external control. The program contains a movement to the (0, -90, 90, 0, 90, 0) position, as the first motion instruction in a KRL program must define an unambiguous starting position. The goal position might be modified if necessary, the other parts of the program should be left unchanged.
- `ros_rsi.rsix`: This contains the RSI context (can be visualized with **RSIVisual**). It can be modified for example to add filtering behaviour, but this is not recommended and should be implemented on the client side instead.
- For older RSI versions (<=4.0.3), the context can only be defined in 3 different files: `ros_rsi.rsi.xml`, `ros_rsi.rsi.diagram` and `ros_rsi.rsi`, these can be found under `krl/deprecated`. In this case, these 3 files should be copied to the controller instead of the `ros_rsi.rsix`.

Expand Down
2 changes: 1 addition & 1 deletion doc/wiki/iiQKA_EAC.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The IP address of the client machine and robot controller must be provided as a
To start the driver, two launch file are available, with and without `rviz`. To launch (without `rviz`), run:

```
ros2 launch kuka_iiqka_eac_driver startup.launch.py client_ip:=0.0.0.0 controller_ip=0.0.0.0
ros2 launch kuka_iiqka_eac_driver startup.launch.py client_ip:=0.0.0.0 controller_ip:=0.0.0.0
```

This starts the 3 core components of every driver (described in the *Non-real-time interface* section of the [project overview](Project%20overview.md)) and the following controllers:
Expand Down
1 change: 1 addition & 0 deletions kuka_iiqka_eac_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ install(DIRECTORY config launch test
if(BUILD_TESTING)
find_package(launch_testing_ament_cmake)
add_launch_test(test/test_driver_startup.py)
add_launch_test(test/test_driver_activation.py)
add_launch_test(test/test_multi_robot_startup.py)
endif()

Expand Down
5 changes: 5 additions & 0 deletions kuka_iiqka_eac_driver/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
<exec_depend>kuka_lbr_iisy_support</exec_depend>
<exec_depend>ros2_control</exec_depend>
<exec_depend>ros2_controllers</exec_depend>
<exec_depend>joint_group_impedance_controller</exec_depend>
<exec_depend>effort_controllers</exec_depend>
<exec_depend>control_mode_handler</exec_depend>

<test_depend>ros2lifecycle</test_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down
81 changes: 81 additions & 0 deletions kuka_iiqka_eac_driver/test/test_driver_activation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright 2024 Áron Svastits
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest

import launch
import launch.actions
import launch_testing.actions
import launch_testing.markers
import pytest

from launch.launch_description_sources.python_launch_description_source import (
PythonLaunchDescriptionSource,
)
from launch.actions.include_launch_description import IncludeLaunchDescription
from ament_index_python.packages import get_package_share_directory


# Launch driver startup
@pytest.mark.launch_test
@launch_testing.markers.keep_alive
def generate_test_description():
return launch.LaunchDescription(
[
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[
get_package_share_directory("kuka_iiqka_eac_driver"),
"/launch/",
"startup.launch.py",
]
)
),
launch.actions.TimerAction(
period=2.0,
actions=[
launch.actions.ExecuteProcess(
cmd=["ros2", "lifecycle", "set", "robot_manager", "configure"],
output="screen",
),
],
),
launch.actions.TimerAction(
period=4.0,
actions=[
launch.actions.ExecuteProcess(
cmd=["ros2", "lifecycle", "set", "robot_manager", "activate"],
output="screen",
),
],
),
launch_testing.actions.ReadyToTest(),
]
)


class TestDriverActivation(unittest.TestCase):
def test_read_stdout(self, proc_output):
# Check for successful initialization
proc_output.assertWaitFor("got segment base", timeout=5)
proc_output.assertWaitFor(
"Successful initialization of hardware 'lbr_iisy3_r760'", timeout=5
)
# Check whether disabling automatic activation was successful
proc_output.assertWaitFor("Hardware Component with name '' does not exists", timeout=5)
# Check for successful configuration and activation
proc_output.assertWaitFor(
"Successful 'configure' of hardware 'lbr_iisy3_r760'", timeout=10
)
proc_output.assertWaitFor("Successful 'activate' of hardware 'lbr_iisy3_r760'", timeout=15)
2 changes: 1 addition & 1 deletion kuka_iiqka_eac_driver/test/test_driver_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def generate_test_description():
)


class TestModels(unittest.TestCase):
class TestDriverStartup(unittest.TestCase):
def test_read_stdout(self, proc_output):
# Check for successful initialization
proc_output.assertWaitFor("got segment base", timeout=5)
Expand Down
2 changes: 1 addition & 1 deletion kuka_iiqka_eac_driver/test/test_multi_robot_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def generate_test_description():
)


class TestModels(unittest.TestCase):
class TestMultiStartup(unittest.TestCase):
def test_read_stdout(self, proc_output):
# Check for successful initialization
proc_output.assertWaitFor("got segment test1_base", timeout=20)
Expand Down
1 change: 1 addition & 0 deletions kuka_kss_rsi_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ install(TARGETS ${PROJECT_NAME} robot_manager_node
if(BUILD_TESTING)
find_package(launch_testing_ament_cmake)
add_launch_test(test/test_driver_startup.py)
add_launch_test(test/test_driver_activation.py)
add_launch_test(test/test_multi_robot_startup.py)
endif()

Expand Down
2 changes: 2 additions & 0 deletions kuka_kss_rsi_driver/krl/ros_rsi.src
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ DECL INT CONTID ; ContainerID
;ENDFOLD (USER INI)
;ENDFOLD (INI)

PTP {A1 0, A2 -90, A3 90, A4 0, A5 0, A6 0}

; Create RSI Context
ret = RSI_CREATE("ros_rsi",CONTID,TRUE)
IF (ret <> RSIOK) THEN
Expand Down
3 changes: 3 additions & 0 deletions kuka_kss_rsi_driver/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<exec_depend>ros2_control</exec_depend>
<exec_depend>ros2_controllers</exec_depend>

<test_depend>kuka_rsi_simulator</test_depend>
<test_depend>ros2lifecycle</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
Expand Down
88 changes: 88 additions & 0 deletions kuka_kss_rsi_driver/test/test_driver_activation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Copyright 2024 Áron Svastits
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest

import launch
import launch.actions
import launch_testing.actions
import launch_testing.markers
import pytest

from launch.launch_description_sources.python_launch_description_source import (
PythonLaunchDescriptionSource,
)
from launch.actions.include_launch_description import IncludeLaunchDescription
from ament_index_python.packages import get_package_share_directory


# Launch driver startup
@pytest.mark.launch_test
@launch_testing.markers.keep_alive
def generate_test_description():
return launch.LaunchDescription(
[
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[
get_package_share_directory("kuka_kss_rsi_driver"),
"/launch/",
"startup.launch.py",
]
)
),
IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[
get_package_share_directory("kuka_rsi_simulator"),
"/launch/",
"kuka_rsi_simulator.launch.py",
]
)
),
launch.actions.TimerAction(
period=2.0,
actions=[
launch.actions.ExecuteProcess(
cmd=["ros2", "lifecycle", "set", "robot_manager", "configure"],
output="screen",
),
],
),
launch.actions.TimerAction(
period=4.0,
actions=[
launch.actions.ExecuteProcess(
cmd=["ros2", "lifecycle", "set", "robot_manager", "activate"],
output="screen",
),
],
),
launch_testing.actions.ReadyToTest(),
]
)


class TestDriverActivation(unittest.TestCase):
def test_read_stdout(self, proc_output):
# Check for successful initialization
proc_output.assertWaitFor("got segment base", timeout=5)
proc_output.assertWaitFor(
"Successful initialization of hardware 'kr6_r700_sixx'", timeout=5
)
# Check whether disabling automatic activation was successful
proc_output.assertWaitFor("Hardware Component with name '' does not exists", timeout=5)
# Check for successful configuration and activation
proc_output.assertWaitFor("Successful 'configure' of hardware 'kr6_r700_sixx'", timeout=10)
proc_output.assertWaitFor("Successful 'activate' of hardware 'kr6_r700_sixx'", timeout=15)
2 changes: 1 addition & 1 deletion kuka_kss_rsi_driver/test/test_driver_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def generate_test_description():
)


class TestModels(unittest.TestCase):
class TestDriverStartup(unittest.TestCase):
def test_read_stdout(self, proc_output):
# Check for successful initialization
proc_output.assertWaitFor("got segment base", timeout=5)
Expand Down
2 changes: 1 addition & 1 deletion kuka_kss_rsi_driver/test/test_multi_robot_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def generate_test_description():
)


class TestModels(unittest.TestCase):
class TestMultiStartup(unittest.TestCase):
def test_read_stdout(self, proc_output):
# Check for successful initialization
proc_output.assertWaitFor("got segment test1_base", timeout=20)
Expand Down
3 changes: 2 additions & 1 deletion kuka_sunrise_fri_driver/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
<depend>hardware_interface</depend>
<depend>controller_manager_msgs</depend>

<exec_depend>rosidl_default_runtime</exec_depend>
<exec_depend>ros2_control</exec_depend>
<exec_depend>ros2_controllers</exec_depend>
<exec_depend>fri_state_broadcaster</exec_depend>
<exec_depend>fri_configuration_controller</exec_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down
2 changes: 1 addition & 1 deletion kuka_sunrise_fri_driver/test/test_driver_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def generate_test_description():
)


class TestModels(unittest.TestCase):
class TestDriverStartup(unittest.TestCase):
def test_read_stdout(self, proc_output):
# Check for successful initialization
proc_output.assertWaitFor("got segment base", timeout=5)
Expand Down
2 changes: 1 addition & 1 deletion kuka_sunrise_fri_driver/test/test_multi_robot_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def generate_test_description():
)


class TestModels(unittest.TestCase):
class TestMultiStartup(unittest.TestCase):
def test_read_stdout(self, proc_output):
# Check for successful initialization
proc_output.assertWaitFor("got segment test1_base", timeout=20)
Expand Down

0 comments on commit 9a0b8c6

Please sign in to comment.