From 21b05c46a84a5ce35fc62035f5bfa2f84de37e64 Mon Sep 17 00:00:00 2001 From: bartek-kc Date: Wed, 26 Oct 2022 18:36:00 +0200 Subject: [PATCH 1/4] Added Python module with delegate class for launching respawnable node containers --- autoware_utils/CMakeLists.txt | 4 +++ autoware_utils/autoware_utils/__init__.py | 0 .../respawnable_node_container.py | 29 +++++++++++++++++++ autoware_utils/package.xml | 2 ++ 4 files changed, 35 insertions(+) create mode 100644 autoware_utils/autoware_utils/__init__.py create mode 100644 autoware_utils/autoware_utils/respawnable_node_container.py diff --git a/autoware_utils/CMakeLists.txt b/autoware_utils/CMakeLists.txt index 21eb4ad2..43e8b9dd 100644 --- a/autoware_utils/CMakeLists.txt +++ b/autoware_utils/CMakeLists.txt @@ -2,12 +2,16 @@ cmake_minimum_required(VERSION 3.14) project(autoware_utils) find_package(autoware_cmake REQUIRED) +find_package(ament_cmake_python REQUIRED) +find_package(rclpy REQUIRED) autoware_package() ament_auto_add_library(autoware_utils SHARED src/autoware_utils.cpp ) +ament_python_install_package(${PROJECT_NAME}) + if(BUILD_TESTING) file(GLOB_RECURSE test_files test/**/*.cpp) ament_add_ros_isolated_gtest(test_autoware_utils ${test_files}) diff --git a/autoware_utils/autoware_utils/__init__.py b/autoware_utils/autoware_utils/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/autoware_utils/autoware_utils/respawnable_node_container.py b/autoware_utils/autoware_utils/respawnable_node_container.py new file mode 100644 index 00000000..55ba2622 --- /dev/null +++ b/autoware_utils/autoware_utils/respawnable_node_container.py @@ -0,0 +1,29 @@ +from launch_ros.actions import ComposableNodeContainer +from launch_ros.descriptions import ComposableNode +from typing import List +from typing import Optional + +from launch.some_substitutions_type import SomeSubstitutionsType + +class RespawnableNodeContainer(ComposableNodeContainer): + """ + Action that executes a container node for composable ROS nodes with fixed + respawn flag and time. + """ + + def __init__( + self, + *, + name: SomeSubstitutionsType, + namespace: SomeSubstitutionsType, + composable_node_descriptions: Optional[List[ComposableNode]] = None, + respawn = True, + respawn_delay = 0.5, + **kwargs + ) -> None: + super().__init__( + name=name, + namespace=namespace, + respawn=respawn, + respawn_delay=respawn_delay, + **kwargs) diff --git a/autoware_utils/package.xml b/autoware_utils/package.xml index a26335d4..46dc1af5 100644 --- a/autoware_utils/package.xml +++ b/autoware_utils/package.xml @@ -8,11 +8,13 @@ Apache License 2.0 ament_cmake_auto + ament_cmake_python autoware_cmake builtin_interfaces rclcpp + rclpy ament_cmake_ros From e060fb342f07805bb629de4eb2d5a3789162b131 Mon Sep 17 00:00:00 2001 From: bartek-kc Date: Thu, 27 Oct 2022 01:02:45 +0200 Subject: [PATCH 2/4] Fixed unused argument in RespawnableNodeContainer constructor + added newline at EOF --- autoware_utils/autoware_utils/respawnable_node_container.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/autoware_utils/autoware_utils/respawnable_node_container.py b/autoware_utils/autoware_utils/respawnable_node_container.py index 55ba2622..4a8bfe90 100644 --- a/autoware_utils/autoware_utils/respawnable_node_container.py +++ b/autoware_utils/autoware_utils/respawnable_node_container.py @@ -24,6 +24,8 @@ def __init__( super().__init__( name=name, namespace=namespace, + composable_node_descriptions=composable_node_descriptions, respawn=respawn, respawn_delay=respawn_delay, **kwargs) + From 39218d22889699ba6db7747b32f8346ebbae7771 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 26 Oct 2022 23:35:21 +0000 Subject: [PATCH 3/4] ci(pre-commit): autofix --- .../autoware_utils/respawnable_node_container.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/autoware_utils/autoware_utils/respawnable_node_container.py b/autoware_utils/autoware_utils/respawnable_node_container.py index 4a8bfe90..666583be 100644 --- a/autoware_utils/autoware_utils/respawnable_node_container.py +++ b/autoware_utils/autoware_utils/respawnable_node_container.py @@ -1,9 +1,10 @@ -from launch_ros.actions import ComposableNodeContainer -from launch_ros.descriptions import ComposableNode from typing import List from typing import Optional from launch.some_substitutions_type import SomeSubstitutionsType +from launch_ros.actions import ComposableNodeContainer +from launch_ros.descriptions import ComposableNode + class RespawnableNodeContainer(ComposableNodeContainer): """ @@ -17,8 +18,8 @@ def __init__( name: SomeSubstitutionsType, namespace: SomeSubstitutionsType, composable_node_descriptions: Optional[List[ComposableNode]] = None, - respawn = True, - respawn_delay = 0.5, + respawn=True, + respawn_delay=0.5, **kwargs ) -> None: super().__init__( @@ -27,5 +28,5 @@ def __init__( composable_node_descriptions=composable_node_descriptions, respawn=respawn, respawn_delay=respawn_delay, - **kwargs) - + **kwargs + ) From 61248f96a8b6f7eb415b6b32db35ffd486798cce Mon Sep 17 00:00:00 2001 From: bartek-kc Date: Thu, 3 Nov 2022 23:30:44 +0100 Subject: [PATCH 4/4] Changed time constant --- autoware_utils/autoware_utils/respawnable_node_container.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoware_utils/autoware_utils/respawnable_node_container.py b/autoware_utils/autoware_utils/respawnable_node_container.py index 666583be..8eef30cc 100644 --- a/autoware_utils/autoware_utils/respawnable_node_container.py +++ b/autoware_utils/autoware_utils/respawnable_node_container.py @@ -19,7 +19,7 @@ def __init__( namespace: SomeSubstitutionsType, composable_node_descriptions: Optional[List[ComposableNode]] = None, respawn=True, - respawn_delay=0.5, + respawn_delay=0.05, **kwargs ) -> None: super().__init__(