Files
OrbbecSDK_ROS2/orbbec_camera/launch/multi_camera_synced.launch.py
T

81 lines
2.9 KiB
Python
Raw Normal View History

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
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")
2024-07-17 20:32:10 +08:00
front_camera = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
2024-09-12 16:49:13 +08:00
os.path.join(launch_file_dir, "gemini_330_series.launch.py")
),
launch_arguments={
2024-09-12 16:49:13 +08:00
"camera_name": "front_camera",
2024-10-21 18:31:11 +08:00
"usb_port": "gmsl2-1",
"device_num": "2",
"sync_mode": "hardware_triggering",
2024-09-12 16:49:13 +08:00
"config_file_path": config_file_path,
2024-10-21 18:31:11 +08:00
"enable_gmsl_trigger": "true",
2024-09-12 16:49:13 +08:00
}.items(),
)
2024-10-21 18:31:11 +08:00
# left_camera = IncludeLaunchDescription(
# PythonLaunchDescriptionSource(
# os.path.join(launch_file_dir, "gemini_330_series.launch.py")
# ),
# launch_arguments={
# "camera_name": "left_camera",
# "usb_port": "gmsl2-2",
# "device_num": "3",
# "sync_mode": "secondary",
# "config_file_path": config_file_path,
# "enable_gmsl_trigger": "false",
# }.items(),
# )
2024-07-17 20:32:10 +08:00
right_camera = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
2024-09-12 16:49:13 +08:00
os.path.join(launch_file_dir, "gemini_330_series.launch.py")
),
launch_arguments={
2024-09-12 16:49:13 +08:00
"camera_name": "right_camera",
2024-10-21 18:31:11 +08:00
"usb_port": "gmsl2-3",
"device_num": "2",
2024-09-12 16:49:13 +08:00
"sync_mode": "hardware_triggering",
"config_file_path": config_file_path,
2024-10-21 18:31:11 +08:00
"enable_gmsl_trigger": "false",
2024-09-12 16:49:13 +08:00
}.items(),
)
2024-10-21 18:31:11 +08:00
# rear_camera = IncludeLaunchDescription(
# PythonLaunchDescriptionSource(
# os.path.join(launch_file_dir, "gemini_330_series.launch.py")
# ),
# launch_arguments={
# "camera_name": "rear_camera",
# "usb_port": "gmsl2-4",
# "device_num": "3",
# "sync_mode": "secondary",
# "config_file_path": config_file_path,
# "enable_gmsl_trigger": "false",
# }.items(),
# )
# Launch description
2024-09-12 16:49:13 +08:00
ld = LaunchDescription(
[
2024-10-21 18:31:11 +08:00
# TimerAction(period=0.5, actions=[GroupAction([rear_camera])]),
TimerAction(period=0.5, actions=[GroupAction([right_camera])]),
# TimerAction(period=0.5, actions=[GroupAction([left_camera])]),
TimerAction(period=0.5, actions=[GroupAction([front_camera])]),
# The primary camera should be launched at last
2024-09-12 16:49:13 +08:00
]
)
2024-07-17 20:32:10 +08:00
2024-09-12 16:49:13 +08:00
return ld