From 003f5c5a517b90037f5b2614dd6df33db1d29500 Mon Sep 17 00:00:00 2001 From: Joe Dong Date: Wed, 17 Jul 2024 20:32:10 +0800 Subject: [PATCH] chore: Update multi camera launch example --- .../launch/multi_camera_synced.launch.py | 56 +++++++++---------- .../scripts/generate_orbbec_launch.sh | 2 +- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/orbbec_camera/launch/multi_camera_synced.launch.py b/orbbec_camera/launch/multi_camera_synced.launch.py index f462a9ba..aef4ad7a 100644 --- a/orbbec_camera/launch/multi_camera_synced.launch.py +++ b/orbbec_camera/launch/multi_camera_synced.launch.py @@ -1,9 +1,8 @@ -from launch import LaunchDescription -from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, GroupAction, ExecuteProcess -from launch.launch_description_sources import PythonLaunchDescriptionSource -from launch_ros.actions import Node -from ament_index_python.packages import get_package_share_directory import os +from ament_index_python.packages import get_package_share_directory +from launch import LaunchDescription +from launch.actions import IncludeLaunchDescription, GroupAction, TimerAction +from launch.launch_description_sources import PythonLaunchDescriptionSource def generate_launch_description(): @@ -12,7 +11,7 @@ def generate_launch_description(): launch_file_dir = os.path.join(package_dir, 'launch') config_file_dir = os.path.join(package_dir, 'config') config_file_path = os.path.join(config_file_dir, 'camera_params.yaml') - launch1_include = IncludeLaunchDescription( + front_camera = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(launch_file_dir, 'gemini_330_series.launch.py') ), @@ -20,12 +19,12 @@ def generate_launch_description(): 'camera_name': 'front_camera', 'usb_port': '2-1.1', 'device_num': '4', - 'sync_mode': 'primary', + 'sync_mode': 'software_triggering', 'config_file_path': config_file_path, }.items() ) - launch2_include = IncludeLaunchDescription( + left_camera = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(launch_file_dir, 'gemini_330_series.launch.py') ), @@ -33,11 +32,23 @@ def generate_launch_description(): 'camera_name': 'left_camera', 'usb_port': '2-1.2.1', 'device_num': '4', - 'sync_mode': 'secondary_synced', + 'sync_mode': 'hardware_triggering', 'config_file_path': config_file_path, }.items() ) - launch3_include = IncludeLaunchDescription( + rear_camera = IncludeLaunchDescription( + PythonLaunchDescriptionSource( + os.path.join(launch_file_dir, 'gemini_330_series.launch.py') + ), + launch_arguments={ + 'camera_name': 'rear_camera', + 'usb_port': '2-1.2.1', + 'device_num': '4', + 'sync_mode': 'hardware_triggering', + 'config_file_path': config_file_path, + }.items() + ) + right_camera = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(launch_file_dir, 'gemini_330_series.launch.py') ), @@ -45,19 +56,7 @@ def generate_launch_description(): 'camera_name': 'right_camera', 'usb_port': '2-1.2.1', 'device_num': '4', - 'sync_mode': 'secondary_synced', - 'config_file_path': config_file_path, - }.items() - ) - launch4_include = IncludeLaunchDescription( - PythonLaunchDescriptionSource( - os.path.join(launch_file_dir, 'gemini_330_series.launch.py') - ), - launch_arguments={ - 'camera_name': 'right_camera', - 'usb_port': '2-1.2.1', - 'device_num': '4', - 'sync_mode': 'secondary_synced', + 'sync_mode': 'hardware_triggering', 'config_file_path': config_file_path, }.items() ) @@ -66,10 +65,11 @@ def generate_launch_description(): # Launch description ld = LaunchDescription([ - GroupAction([launch2_include]), - GroupAction([launch3_include]), - GroupAction([launch4_include]), - GroupAction([launch1_include]), # The primary camera should be launched at last + GroupAction([rear_camera]), + GroupAction([left_camera]), + GroupAction([right_camera]), + TimerAction(period=3.0, actions=[GroupAction([front_camera])]), # The primary camera should be launched at last + ]) - return ld + return ld \ No newline at end of file diff --git a/orbbec_camera/scripts/generate_orbbec_launch.sh b/orbbec_camera/scripts/generate_orbbec_launch.sh index 6d6edce6..92044a9c 100755 --- a/orbbec_camera/scripts/generate_orbbec_launch.sh +++ b/orbbec_camera/scripts/generate_orbbec_launch.sh @@ -101,7 +101,7 @@ def generate_launch_description(): GroupAction([rear_camera]), GroupAction([left_camera]), GroupAction([right_camera]), - TimerAction(period=3.0, actions=[GroupAction([front_camera])]), + TimerAction(period=3.0, actions=[GroupAction([front_camera])]), # The primary camera should be launched at last ])