2024-07-09 13:55:34 +08:00
|
|
|
import os
|
2024-07-17 20:32:10 +08:00
|
|
|
from ament_index_python.packages import get_package_share_directory
|
|
|
|
|
from launch import LaunchDescription
|
2024-09-12 16:49:13 +08:00
|
|
|
from launch_ros.actions import Node
|
2024-07-17 20:32:10 +08:00
|
|
|
from launch.actions import IncludeLaunchDescription, GroupAction, TimerAction
|
|
|
|
|
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
2024-11-27 11:13:38 +08:00
|
|
|
from launch.actions import DeclareLaunchArgument
|
|
|
|
|
from launch.conditions import UnlessCondition, IfCondition
|
|
|
|
|
from launch.substitutions import LaunchConfiguration
|
2024-11-27 20:58:27 +08:00
|
|
|
from launch.substitutions import TextSubstitution
|
2025-03-26 15:11:11 +08:00
|
|
|
from launch_ros.actions import Node, LoadComposableNodes
|
|
|
|
|
from launch_ros.descriptions import ComposableNode
|
2024-07-09 13:55:34 +08:00
|
|
|
|
|
|
|
|
def generate_launch_description():
|
|
|
|
|
# Include launch files
|
2024-09-12 16:49:13 +08:00
|
|
|
package_dir = get_package_share_directory("orbbec_camera")
|
|
|
|
|
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")
|
2025-03-24 21:55:35 +08:00
|
|
|
secondary_config_file_path = os.path.join(config_file_dir, "camera_secondary_params.yaml")
|
2024-11-06 20:04:23 +08:00
|
|
|
|
2024-11-27 20:58:27 +08:00
|
|
|
use_intra_process_comms_declare = DeclareLaunchArgument(
|
2024-11-27 22:16:14 +08:00
|
|
|
'use_intra_process_comms', default_value='false',
|
2024-11-27 11:13:38 +08:00
|
|
|
)
|
2024-11-27 20:58:27 +08:00
|
|
|
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'
|
2024-11-27 11:13:38 +08:00
|
|
|
)
|
|
|
|
|
|
2024-11-27 20:58:27 +08:00
|
|
|
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,
|
2024-11-27 11:13:38 +08:00
|
|
|
package='rclcpp_components',
|
|
|
|
|
executable='component_container_mt',
|
|
|
|
|
output='screen',
|
2024-11-27 20:58:27 +08:00
|
|
|
condition=UnlessCondition(attach_to_shared_component_container_arg)
|
2024-11-27 11:13:38 +08:00
|
|
|
)
|
|
|
|
|
|
2025-03-26 15:11:11 +08:00
|
|
|
save_rgbir = LoadComposableNodes(
|
|
|
|
|
target_container=component_container_name_arg,
|
|
|
|
|
composable_node_descriptions=[
|
|
|
|
|
ComposableNode(
|
|
|
|
|
namespace="save_rgbir",
|
|
|
|
|
name="save_rgbir",
|
|
|
|
|
package="orbbec_camera",
|
|
|
|
|
plugin="orbbec_camera::tools::MultiCameraSubscriber",
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
|
2024-11-27 20:58:27 +08:00
|
|
|
attach_to_shared_component_container_arg = TextSubstitution(text='true')
|
|
|
|
|
|
2024-11-26 23:33:54 +08:00
|
|
|
front_camera = IncludeLaunchDescription(
|
2024-07-09 13:55:34 +08:00
|
|
|
PythonLaunchDescriptionSource(
|
2024-12-24 10:03:32 +08:00
|
|
|
os.path.join(launch_file_dir, "gemini_330_series.launch.py")
|
2024-07-09 13:55:34 +08:00
|
|
|
),
|
|
|
|
|
launch_arguments={
|
2024-11-26 23:33:54 +08:00
|
|
|
"camera_name": "front_camera",
|
2024-12-05 19:56:43 +08:00
|
|
|
"usb_port": "2-1",
|
|
|
|
|
# "usb_port": "gmsl2-4",
|
2024-11-20 14:10:44 +08:00
|
|
|
"device_num": "4",
|
2024-12-05 19:56:43 +08:00
|
|
|
"sync_mode": "primary",
|
|
|
|
|
# "sync_mode": "secondary_synced",
|
2024-11-06 20:04:23 +08:00
|
|
|
"config_file_path": config_file_path,
|
2024-11-27 11:13:38 +08:00
|
|
|
'use_intra_process_comms': LaunchConfiguration("use_intra_process_comms"),
|
2024-11-27 20:58:27 +08:00
|
|
|
'attach_to_shared_component_container': attach_to_shared_component_container_arg,
|
|
|
|
|
'component_container_name': component_container_name_arg,
|
2024-12-05 19:56:43 +08:00
|
|
|
# 'gmsl_trigger_fps': "5990",
|
|
|
|
|
# 'enable_gmsl_trigger': "true",
|
2024-11-06 20:04:23 +08:00
|
|
|
}.items(),
|
|
|
|
|
)
|
2024-11-26 23:33:54 +08:00
|
|
|
left_camera = IncludeLaunchDescription(
|
|
|
|
|
PythonLaunchDescriptionSource(
|
2024-12-26 09:49:48 +08:00
|
|
|
os.path.join(launch_file_dir, "gemini_330_series.launch.py")
|
2024-11-26 23:33:54 +08:00
|
|
|
),
|
|
|
|
|
launch_arguments={
|
|
|
|
|
"camera_name": "left_camera",
|
2024-12-05 19:56:43 +08:00
|
|
|
"usb_port": "2-3.1",
|
|
|
|
|
# "usb_port": "gmsl2-3",
|
2024-11-26 23:33:54 +08:00
|
|
|
"device_num": "4",
|
|
|
|
|
"sync_mode": "secondary_synced",
|
2025-03-24 21:55:35 +08:00
|
|
|
"config_file_path": secondary_config_file_path,
|
2024-11-27 11:13:38 +08:00
|
|
|
'use_intra_process_comms': LaunchConfiguration("use_intra_process_comms"),
|
2024-11-27 20:58:27 +08:00
|
|
|
'attach_to_shared_component_container': attach_to_shared_component_container_arg,
|
|
|
|
|
'component_container_name': component_container_name_arg,
|
2024-11-26 23:33:54 +08:00
|
|
|
}.items(),
|
|
|
|
|
)
|
|
|
|
|
right_camera = IncludeLaunchDescription(
|
|
|
|
|
PythonLaunchDescriptionSource(
|
2024-12-26 09:49:48 +08:00
|
|
|
os.path.join(launch_file_dir, "gemini_330_series.launch.py")
|
2024-11-26 23:33:54 +08:00
|
|
|
),
|
|
|
|
|
launch_arguments={
|
|
|
|
|
"camera_name": "right_camera",
|
2024-12-05 19:56:43 +08:00
|
|
|
"usb_port": "2-3.3",
|
|
|
|
|
# "usb_port": "gmsl2-1",
|
2024-11-26 23:33:54 +08:00
|
|
|
"device_num": "4",
|
|
|
|
|
"sync_mode": "secondary_synced",
|
2025-03-24 21:55:35 +08:00
|
|
|
"config_file_path": secondary_config_file_path,
|
2024-11-27 11:13:38 +08:00
|
|
|
'use_intra_process_comms': LaunchConfiguration("use_intra_process_comms"),
|
2024-11-27 20:58:27 +08:00
|
|
|
'attach_to_shared_component_container': attach_to_shared_component_container_arg,
|
|
|
|
|
'component_container_name': component_container_name_arg,
|
2024-11-26 23:33:54 +08:00
|
|
|
}.items(),
|
|
|
|
|
)
|
|
|
|
|
rear_camera = IncludeLaunchDescription(
|
|
|
|
|
PythonLaunchDescriptionSource(
|
2024-12-26 09:49:48 +08:00
|
|
|
os.path.join(launch_file_dir, "gemini_330_series.launch.py")
|
2024-11-26 23:33:54 +08:00
|
|
|
),
|
|
|
|
|
launch_arguments={
|
|
|
|
|
"camera_name": "rear_camera",
|
2024-12-05 19:56:43 +08:00
|
|
|
"usb_port": "2-2",
|
|
|
|
|
# "usb_port": "gmsl2-7",
|
2024-11-26 23:33:54 +08:00
|
|
|
"device_num": "4",
|
|
|
|
|
"sync_mode": "secondary_synced",
|
2025-03-24 21:55:35 +08:00
|
|
|
"config_file_path": secondary_config_file_path,
|
2024-11-27 11:13:38 +08:00
|
|
|
'use_intra_process_comms': LaunchConfiguration("use_intra_process_comms"),
|
2024-11-27 20:58:27 +08:00
|
|
|
'attach_to_shared_component_container': attach_to_shared_component_container_arg,
|
|
|
|
|
'component_container_name': component_container_name_arg,
|
2024-11-26 23:33:54 +08:00
|
|
|
}.items(),
|
2024-11-06 20:04:23 +08:00
|
|
|
)
|
2024-07-09 13:55:34 +08:00
|
|
|
|
2024-11-27 11:13:38 +08:00
|
|
|
delayed_left_camera = TimerAction(
|
2024-12-25 19:42:03 +08:00
|
|
|
period=0.0,
|
2024-11-27 11:13:38 +08:00
|
|
|
actions=[left_camera],
|
|
|
|
|
)
|
|
|
|
|
delayed_right_camera = TimerAction(
|
2025-03-17 18:13:34 +08:00
|
|
|
period=4.0,
|
2024-11-27 11:13:38 +08:00
|
|
|
actions=[right_camera],
|
|
|
|
|
)
|
|
|
|
|
delayed_rear_camera = TimerAction(
|
2025-03-17 18:13:34 +08:00
|
|
|
period=6.0,
|
2024-11-27 11:13:38 +08:00
|
|
|
actions=[rear_camera],
|
|
|
|
|
)
|
|
|
|
|
delayed_front_camera = TimerAction(
|
2025-03-17 18:13:34 +08:00
|
|
|
period=8.0,
|
2024-11-27 11:13:38 +08:00
|
|
|
actions=[front_camera],
|
|
|
|
|
)
|
2025-03-26 15:11:11 +08:00
|
|
|
delayed_save_rgbir = TimerAction(
|
|
|
|
|
period=16.0,
|
|
|
|
|
actions=[save_rgbir],
|
|
|
|
|
)
|
2024-09-12 16:49:13 +08:00
|
|
|
ld = LaunchDescription(
|
2024-11-26 23:33:54 +08:00
|
|
|
[
|
2024-11-27 20:58:27 +08:00
|
|
|
use_intra_process_comms_declare,
|
|
|
|
|
attach_to_shared_component_container_declare,
|
|
|
|
|
component_container_name_declare,
|
|
|
|
|
shared_orbbec_container,
|
2024-11-27 11:13:38 +08:00
|
|
|
delayed_left_camera,
|
|
|
|
|
delayed_right_camera,
|
|
|
|
|
delayed_rear_camera,
|
|
|
|
|
delayed_front_camera,
|
2025-03-26 15:11:11 +08:00
|
|
|
delayed_save_rgbir,
|
2024-11-26 23:33:54 +08:00
|
|
|
]
|
2024-09-12 16:49:13 +08:00
|
|
|
)
|
2024-07-17 20:32:10 +08:00
|
|
|
|
2024-11-26 23:33:54 +08:00
|
|
|
return ld
|