add launch scripts for Orbbec cameras and algorithms, and integrate the use of component containers

This commit is contained in:
datean
2024-11-27 20:58:27 +08:00
parent 90dfddeaa0
commit b2b3be6075
6 changed files with 132 additions and 33 deletions
+12
View File
@@ -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()
@@ -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,
]
)
+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>isaac_orbbec_launch</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="[email protected]">toosimple</maintainer>
<license>Apache License 2.0</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
@@ -10,7 +10,7 @@
<!-- File log output level --> <!-- File log output level -->
<FileLogLevel>0</FileLogLevel> <FileLogLevel>0</FileLogLevel>
<!-- Console log output level --> <!-- Console log output level -->
<ConsoleLogLevel>3</ConsoleLogLevel> <ConsoleLogLevel>4</ConsoleLogLevel>
<!-- Default log output file path, string type. If this item is not configured, the default <!-- Default log output file path, string type. If this item is not configured, the default
path will be used: Win/Linux: "./Log"; Android: "/sdcard/orbbec/Log" --> path will be used: Win/Linux: "./Log"; Android: "/sdcard/orbbec/Log" -->
<!-- <OutputDir>./log</OutputDir> --> <!-- <OutputDir>./log</OutputDir> -->
@@ -188,7 +188,7 @@ def generate_launch_description():
DeclareLaunchArgument('interleave_skip_index', default_value='0'), # 0:skip pattern ir 1: skip flood ir DeclareLaunchArgument('interleave_skip_index', default_value='0'), # 0:skip pattern ir 1: skip flood ir
DeclareLaunchArgument('use_intra_process_comms', default_value='false'), DeclareLaunchArgument('use_intra_process_comms', default_value='false'),
DeclareLaunchArgument('attach_to_shared_component_container', 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_duration', default_value='5000.0'),
DeclareLaunchArgument('delta_fps', default_value='2'), DeclareLaunchArgument('delta_fps', default_value='2'),
] ]
@@ -212,9 +212,9 @@ def generate_launch_description():
] ]
else: else:
attach_to_shared_component_container_arg = LaunchConfiguration('attach_to_shared_component_container', default=False) 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, name=component_container_name_arg,
package='rclcpp_components', package='rclcpp_components',
executable='component_container_mt', executable='component_container_mt',
@@ -222,7 +222,7 @@ def generate_launch_description():
condition=UnlessCondition(attach_to_shared_component_container_arg) condition=UnlessCondition(attach_to_shared_component_container_arg)
) )
return [ return [
orbbec_container, shared_orbbec_container,
LoadComposableNodes( LoadComposableNodes(
target_container=component_container_name_arg, target_container=component_container_name_arg,
composable_node_descriptions=[ composable_node_descriptions=[
@@ -7,6 +7,7 @@ from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.actions import DeclareLaunchArgument from launch.actions import DeclareLaunchArgument
from launch.conditions import UnlessCondition, IfCondition from launch.conditions import UnlessCondition, IfCondition
from launch.substitutions import LaunchConfiguration from launch.substitutions import LaunchConfiguration
from launch.substitutions import TextSubstitution
def generate_launch_description(): def generate_launch_description():
# Include launch files # Include launch files
@@ -15,22 +16,29 @@ def generate_launch_description():
config_file_dir = os.path.join(package_dir, "config") config_file_dir = os.path.join(package_dir, "config")
config_file_path = os.path.join(config_file_dir, "camera_params.yaml") 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', 'use_intra_process_comms', default_value='true',
) )
attach_to_shared_component_container_arg = DeclareLaunchArgument( attach_to_shared_component_container_declare = DeclareLaunchArgument(
'attach_to_shared_component_container', default_value='true', '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" attach_to_shared_component_container_arg = LaunchConfiguration('attach_to_shared_component_container', default=False)
shared_container = Node( component_container_name_arg = LaunchConfiguration('component_container_name', default='shared_orbbec_container')
name=shared_container_name,
shared_orbbec_container = Node(
name=component_container_name_arg,
package='rclcpp_components', package='rclcpp_components',
executable='component_container_mt', executable='component_container_mt',
output='screen', 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( front_camera = IncludeLaunchDescription(
PythonLaunchDescriptionSource( PythonLaunchDescriptionSource(
os.path.join(launch_file_dir, "gemini_330_series_interleave_laser_g335L.launch.py") 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", "sync_mode": "primary",
"config_file_path": config_file_path, "config_file_path": config_file_path,
'use_intra_process_comms': LaunchConfiguration("use_intra_process_comms"), 'use_intra_process_comms': LaunchConfiguration("use_intra_process_comms"),
'attach_to_shared_component_container': LaunchConfiguration("attach_to_shared_component_container"), 'attach_to_shared_component_container': attach_to_shared_component_container_arg,
'component_container_name': shared_container_name, 'component_container_name': component_container_name_arg,
}.items(), }.items(),
) )
left_camera = IncludeLaunchDescription( left_camera = IncludeLaunchDescription(
PythonLaunchDescriptionSource( PythonLaunchDescriptionSource(
os.path.join(launch_file_dir, "gemini_330_series_interleave_laser_g335L.launch.py") 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", "sync_mode": "secondary_synced",
"config_file_path": config_file_path, "config_file_path": config_file_path,
'use_intra_process_comms': LaunchConfiguration("use_intra_process_comms"), 'use_intra_process_comms': LaunchConfiguration("use_intra_process_comms"),
'attach_to_shared_component_container': LaunchConfiguration("attach_to_shared_component_container"), 'attach_to_shared_component_container': attach_to_shared_component_container_arg,
'component_container_name': shared_container_name, 'component_container_name': component_container_name_arg,
}.items(), }.items(),
) )
right_camera = IncludeLaunchDescription( right_camera = IncludeLaunchDescription(
@@ -73,8 +80,8 @@ def generate_launch_description():
"sync_mode": "secondary_synced", "sync_mode": "secondary_synced",
"config_file_path": config_file_path, "config_file_path": config_file_path,
'use_intra_process_comms': LaunchConfiguration("use_intra_process_comms"), 'use_intra_process_comms': LaunchConfiguration("use_intra_process_comms"),
'attach_to_shared_component_container': LaunchConfiguration("attach_to_shared_component_container"), 'attach_to_shared_component_container': attach_to_shared_component_container_arg,
'component_container_name': shared_container_name, 'component_container_name': component_container_name_arg,
}.items(), }.items(),
) )
rear_camera = IncludeLaunchDescription( rear_camera = IncludeLaunchDescription(
@@ -88,20 +95,11 @@ def generate_launch_description():
"sync_mode": "secondary_synced", "sync_mode": "secondary_synced",
"config_file_path": config_file_path, "config_file_path": config_file_path,
'use_intra_process_comms': LaunchConfiguration("use_intra_process_comms"), 'use_intra_process_comms': LaunchConfiguration("use_intra_process_comms"),
'attach_to_shared_component_container': LaunchConfiguration("attach_to_shared_component_container"), 'attach_to_shared_component_container': attach_to_shared_component_container_arg,
'component_container_name': shared_container_name, 'component_container_name': component_container_name_arg,
}.items(), }.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( delayed_left_camera = TimerAction(
period=0.5, period=0.5,
actions=[left_camera], actions=[left_camera],
@@ -120,9 +118,10 @@ def generate_launch_description():
) )
ld = LaunchDescription( ld = LaunchDescription(
[ [
use_intra_process_comms_arg, use_intra_process_comms_declare,
attach_to_shared_component_container_arg, attach_to_shared_component_container_declare,
shared_container, component_container_name_declare,
shared_orbbec_container,
delayed_left_camera, delayed_left_camera,
delayed_right_camera, delayed_right_camera,
delayed_rear_camera, delayed_rear_camera,