From b2b3be6075b145601991b9ce8adc07ba38245d3d Mon Sep 17 00:00:00 2001 From: datean Date: Wed, 27 Nov 2024 20:58:27 +0800 Subject: [PATCH] add launch scripts for Orbbec cameras and algorithms, and integrate the use of component containers --- isaac_orbbec_launch/CMakeLists.txt | 12 ++++ .../launch/orbbec_perceptor.launch.py | 70 +++++++++++++++++++ isaac_orbbec_launch/package.xml | 18 +++++ orbbec_camera/config/OrbbecSDKConfig_v1.0.xml | 2 +- ...30_series_interleave_laser_g335L.launch.py | 8 +-- .../launch/multi_camera_synced.launch.py | 55 +++++++-------- 6 files changed, 132 insertions(+), 33 deletions(-) create mode 100644 isaac_orbbec_launch/CMakeLists.txt create mode 100644 isaac_orbbec_launch/launch/orbbec_perceptor.launch.py create mode 100644 isaac_orbbec_launch/package.xml diff --git a/isaac_orbbec_launch/CMakeLists.txt b/isaac_orbbec_launch/CMakeLists.txt new file mode 100644 index 00000000..3aa918ba --- /dev/null +++ b/isaac_orbbec_launch/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.8) +project(isaac_orbbec_launch) + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + + +find_package(ament_cmake REQUIRED) +# install the launch files +install(DIRECTORY launch DESTINATION share/${PROJECT_NAME}) +ament_package() diff --git a/isaac_orbbec_launch/launch/orbbec_perceptor.launch.py b/isaac_orbbec_launch/launch/orbbec_perceptor.launch.py new file mode 100644 index 00000000..9b1db15a --- /dev/null +++ b/isaac_orbbec_launch/launch/orbbec_perceptor.launch.py @@ -0,0 +1,70 @@ + +import os +from ament_index_python.packages import get_package_share_directory +from launch import LaunchDescription +from launch_ros.actions import Node +from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription +from launch.conditions import IfCondition, UnlessCondition +from launch.launch_description_sources import PythonLaunchDescriptionSource +from launch.substitutions import LaunchConfiguration +from launch.actions import TimerAction +from launch.actions import GroupAction + +def generate_launch_description(): + orbbec_camera_bringup_dir = get_package_share_directory('orbbec_camera') + perceptor_bringup_dir = get_package_share_directory('isaac_ros_perceptor_bringup') + + perceptor_config_file = DeclareLaunchArgument( + 'perceptor_config_file', default_value='params/orbbec_perceptor_detached.yaml', + description="Perceptor configuration") + from_bag_arg = DeclareLaunchArgument( + 'from_bag', default_value='False', + description='Whether to run from a bag or live realsense data') + bag_path_arg = DeclareLaunchArgument( + 'bag_path', default_value='rosbag2*', + description='Path of the bag (only used if from_bag == True)') + + component_container_name_arg = "shared_orbbec_container" + shared_orbbec_container = Node( + name=component_container_name_arg, + package='rclcpp_components', + executable='component_container_mt', + output='screen') + + orbbec_launch = IncludeLaunchDescription( + PythonLaunchDescriptionSource([os.path.join( + orbbec_camera_bringup_dir, 'launch', 'multi_camera_synced.launch.py')]), + launch_arguments={ + 'attach_to_shared_component_container': 'True', + 'component_container_name': component_container_name_arg}.items(), + condition=UnlessCondition(LaunchConfiguration('from_bag'))) + + perceptor_launch = IncludeLaunchDescription( + PythonLaunchDescriptionSource([os.path.join( + perceptor_bringup_dir, 'launch', 'rgbd_perceptor.launch.py')]), + launch_arguments={'config_file': LaunchConfiguration("perceptor_config_file"), + 'attach_to_shared_component_container': 'True', + 'component_container_name': component_container_name_arg}.items()) + delayed_perceptor_launch = TimerAction( + period=0.5, + actions=[ + GroupAction(actions=[perceptor_launch]) + ] + ) + + bag_play = ExecuteProcess( + cmd=['ros2', 'bag', 'play', LaunchConfiguration('bag_path')], + shell=True, + output='screen', + condition=IfCondition(LaunchConfiguration('from_bag'))) + + return LaunchDescription([ + perceptor_config_file, + from_bag_arg, + bag_path_arg, + shared_orbbec_container, + perceptor_launch, + orbbec_launch, + bag_play, + ] + ) diff --git a/isaac_orbbec_launch/package.xml b/isaac_orbbec_launch/package.xml new file mode 100644 index 00000000..af862ac2 --- /dev/null +++ b/isaac_orbbec_launch/package.xml @@ -0,0 +1,18 @@ + + + + isaac_orbbec_launch + 0.0.0 + TODO: Package description + toosimple + Apache License 2.0 + + ament_cmake + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/orbbec_camera/config/OrbbecSDKConfig_v1.0.xml b/orbbec_camera/config/OrbbecSDKConfig_v1.0.xml index 2eea0655..ea94b21b 100644 --- a/orbbec_camera/config/OrbbecSDKConfig_v1.0.xml +++ b/orbbec_camera/config/OrbbecSDKConfig_v1.0.xml @@ -10,7 +10,7 @@ 0 - 3 + 4 diff --git a/orbbec_camera/launch/gemini_330_series_interleave_laser_g335L.launch.py b/orbbec_camera/launch/gemini_330_series_interleave_laser_g335L.launch.py index f63b74fe..8628479d 100644 --- a/orbbec_camera/launch/gemini_330_series_interleave_laser_g335L.launch.py +++ b/orbbec_camera/launch/gemini_330_series_interleave_laser_g335L.launch.py @@ -188,7 +188,7 @@ def generate_launch_description(): DeclareLaunchArgument('interleave_skip_index', default_value='0'), # 0:skip pattern ir 1: skip flood ir DeclareLaunchArgument('use_intra_process_comms', default_value='false'), DeclareLaunchArgument('attach_to_shared_component_container', default_value='false'), - DeclareLaunchArgument('component_container_name', default_value='orbbec_container'), + DeclareLaunchArgument('component_container_name', default_value='shared_orbbec_container'), DeclareLaunchArgument('delta_duration', default_value='5000.0'), DeclareLaunchArgument('delta_fps', default_value='2'), ] @@ -212,9 +212,9 @@ def generate_launch_description(): ] else: attach_to_shared_component_container_arg = LaunchConfiguration('attach_to_shared_component_container', default=False) - component_container_name_arg = LaunchConfiguration('component_container_name', default='orbbec_container') + component_container_name_arg = LaunchConfiguration('component_container_name', default='shared_orbbec_container') - orbbec_container = Node( + shared_orbbec_container = Node( name=component_container_name_arg, package='rclcpp_components', executable='component_container_mt', @@ -222,7 +222,7 @@ def generate_launch_description(): condition=UnlessCondition(attach_to_shared_component_container_arg) ) return [ - orbbec_container, + shared_orbbec_container, LoadComposableNodes( target_container=component_container_name_arg, composable_node_descriptions=[ diff --git a/orbbec_camera/launch/multi_camera_synced.launch.py b/orbbec_camera/launch/multi_camera_synced.launch.py index 7857e43b..c55f5dfa 100644 --- a/orbbec_camera/launch/multi_camera_synced.launch.py +++ b/orbbec_camera/launch/multi_camera_synced.launch.py @@ -7,6 +7,7 @@ from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.actions import DeclareLaunchArgument from launch.conditions import UnlessCondition, IfCondition from launch.substitutions import LaunchConfiguration +from launch.substitutions import TextSubstitution def generate_launch_description(): # Include launch files @@ -15,22 +16,29 @@ def generate_launch_description(): config_file_dir = os.path.join(package_dir, "config") config_file_path = os.path.join(config_file_dir, "camera_params.yaml") - use_intra_process_comms_arg = DeclareLaunchArgument( + use_intra_process_comms_declare = DeclareLaunchArgument( 'use_intra_process_comms', default_value='true', ) - attach_to_shared_component_container_arg = DeclareLaunchArgument( - 'attach_to_shared_component_container', default_value='true', + attach_to_shared_component_container_declare = DeclareLaunchArgument( + 'attach_to_shared_component_container', default_value='false', + ) + component_container_name_declare = DeclareLaunchArgument( + 'component_container_name', default_value='shared_orbbec_container' ) - shared_container_name = "shared_orbbec_container" - shared_container = Node( - name=shared_container_name, + attach_to_shared_component_container_arg = LaunchConfiguration('attach_to_shared_component_container', default=False) + component_container_name_arg = LaunchConfiguration('component_container_name', default='shared_orbbec_container') + + shared_orbbec_container = Node( + name=component_container_name_arg, package='rclcpp_components', executable='component_container_mt', output='screen', - condition=IfCondition(LaunchConfiguration('attach_to_shared_component_container')) + condition=UnlessCondition(attach_to_shared_component_container_arg) ) + attach_to_shared_component_container_arg = TextSubstitution(text='true') + front_camera = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(launch_file_dir, "gemini_330_series_interleave_laser_g335L.launch.py") @@ -42,11 +50,10 @@ def generate_launch_description(): "sync_mode": "primary", "config_file_path": config_file_path, 'use_intra_process_comms': LaunchConfiguration("use_intra_process_comms"), - 'attach_to_shared_component_container': LaunchConfiguration("attach_to_shared_component_container"), - 'component_container_name': shared_container_name, + 'attach_to_shared_component_container': attach_to_shared_component_container_arg, + 'component_container_name': component_container_name_arg, }.items(), ) - left_camera = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(launch_file_dir, "gemini_330_series_interleave_laser_g335L.launch.py") @@ -58,8 +65,8 @@ def generate_launch_description(): "sync_mode": "secondary_synced", "config_file_path": config_file_path, 'use_intra_process_comms': LaunchConfiguration("use_intra_process_comms"), - 'attach_to_shared_component_container': LaunchConfiguration("attach_to_shared_component_container"), - 'component_container_name': shared_container_name, + 'attach_to_shared_component_container': attach_to_shared_component_container_arg, + 'component_container_name': component_container_name_arg, }.items(), ) right_camera = IncludeLaunchDescription( @@ -73,8 +80,8 @@ def generate_launch_description(): "sync_mode": "secondary_synced", "config_file_path": config_file_path, 'use_intra_process_comms': LaunchConfiguration("use_intra_process_comms"), - 'attach_to_shared_component_container': LaunchConfiguration("attach_to_shared_component_container"), - 'component_container_name': shared_container_name, + 'attach_to_shared_component_container': attach_to_shared_component_container_arg, + 'component_container_name': component_container_name_arg, }.items(), ) rear_camera = IncludeLaunchDescription( @@ -88,20 +95,11 @@ def generate_launch_description(): "sync_mode": "secondary_synced", "config_file_path": config_file_path, 'use_intra_process_comms': LaunchConfiguration("use_intra_process_comms"), - 'attach_to_shared_component_container': LaunchConfiguration("attach_to_shared_component_container"), - 'component_container_name': shared_container_name, + 'attach_to_shared_component_container': attach_to_shared_component_container_arg, + 'component_container_name': component_container_name_arg, }.items(), ) - # Launch description - # ld = LaunchDescription( - # [ - # TimerAction(period=0.5, actions=[GroupAction([left_camera])]), - # TimerAction(period=0.5, actions=[GroupAction([right_camera])]), - # TimerAction(period=0.5, actions=[GroupAction([rear_camera])]), - # TimerAction(period=0.5, actions=[GroupAction([front_camera])]), - # ] - # ) delayed_left_camera = TimerAction( period=0.5, actions=[left_camera], @@ -120,9 +118,10 @@ def generate_launch_description(): ) ld = LaunchDescription( [ - use_intra_process_comms_arg, - attach_to_shared_component_container_arg, - shared_container, + use_intra_process_comms_declare, + attach_to_shared_component_container_declare, + component_container_name_declare, + shared_orbbec_container, delayed_left_camera, delayed_right_camera, delayed_rear_camera,