use shared container to launch 4 camera node

This commit is contained in:
datean
2024-11-27 11:13:38 +08:00
parent 6521015f9c
commit 9bfd47969f
4 changed files with 99 additions and 24 deletions
@@ -4,6 +4,9 @@ from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import IncludeLaunchDescription, GroupAction, TimerAction
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.actions import DeclareLaunchArgument
from launch.conditions import UnlessCondition, IfCondition
from launch.substitutions import LaunchConfiguration
def generate_launch_description():
# Include launch files
@@ -12,6 +15,22 @@ 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', default_value='true',
)
attach_to_shared_component_container_arg = DeclareLaunchArgument(
'attach_to_shared_component_container', default_value='true',
)
shared_container_name = "shared_orbbec_container"
shared_container = Node(
name=shared_container_name,
package='rclcpp_components',
executable='component_container_mt',
output='screen',
condition=IfCondition(LaunchConfiguration('attach_to_shared_component_container'))
)
front_camera = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
os.path.join(launch_file_dir, "gemini_330_series_interleave_laser_g335L.launch.py")
@@ -22,6 +41,9 @@ def generate_launch_description():
"device_num": "4",
"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,
}.items(),
)
@@ -35,6 +57,9 @@ def generate_launch_description():
"device_num": "4",
"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,
}.items(),
)
right_camera = IncludeLaunchDescription(
@@ -47,6 +72,9 @@ def generate_launch_description():
"device_num": "4",
"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,
}.items(),
)
rear_camera = IncludeLaunchDescription(
@@ -59,16 +87,46 @@ def generate_launch_description():
"device_num": "4",
"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,
}.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],
)
delayed_right_camera = TimerAction(
period=0.5,
actions=[right_camera],
)
delayed_rear_camera = TimerAction(
period=0.5,
actions=[rear_camera],
)
delayed_front_camera = TimerAction(
period=0.5,
actions=[front_camera],
)
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])]),
use_intra_process_comms_arg,
attach_to_shared_component_container_arg,
shared_container,
delayed_left_camera,
delayed_right_camera,
delayed_rear_camera,
delayed_front_camera,
]
)