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..8eef30cc --- /dev/null +++ b/autoware_utils/autoware_utils/respawnable_node_container.py @@ -0,0 +1,32 @@ +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): + """ + 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.05, + **kwargs + ) -> None: + super().__init__( + name=name, + namespace=namespace, + composable_node_descriptions=composable_node_descriptions, + 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