mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-10-08 05:47:45 +08:00
add py launch file
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
from launch_ros.actions import PushRosNamespace
|
||||
from launch.actions import GroupAction
|
||||
from launch_ros.actions import ComposableNodeContainer
|
||||
from launch_ros.descriptions import ComposableNode
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
# Declare arguments
|
||||
args = [
|
||||
DeclareLaunchArgument('camera_name', default_value='camera'),
|
||||
DeclareLaunchArgument('depth_registration', default_value='false'),
|
||||
DeclareLaunchArgument('serial_number', default_value=''),
|
||||
DeclareLaunchArgument('usb_port', default_value=''),
|
||||
DeclareLaunchArgument('device_num', default_value='1'),
|
||||
DeclareLaunchArgument('vendor_id', default_value='0x2bc5'),
|
||||
DeclareLaunchArgument('product_id', default_value=''),
|
||||
DeclareLaunchArgument('enable_point_cloud', default_value='true'),
|
||||
DeclareLaunchArgument('enable_colored_point_cloud', default_value='false'),
|
||||
DeclareLaunchArgument('point_cloud_qos', default_value='default'),
|
||||
DeclareLaunchArgument('connection_delay', default_value='100'),
|
||||
DeclareLaunchArgument('color_width', default_value='640'),
|
||||
DeclareLaunchArgument('color_height', default_value='480'),
|
||||
DeclareLaunchArgument('color_fps', default_value='30'),
|
||||
DeclareLaunchArgument('color_format', default_value='MJPG'),
|
||||
DeclareLaunchArgument('enable_color', default_value='true'),
|
||||
DeclareLaunchArgument('flip_color', default_value='false'),
|
||||
DeclareLaunchArgument('color_qos', default_value='default'),
|
||||
DeclareLaunchArgument('color_camera_info_qos', default_value='default'),
|
||||
DeclareLaunchArgument('enable_color_auto_exposure', default_value='true'),
|
||||
DeclareLaunchArgument('depth_width', default_value='640'),
|
||||
DeclareLaunchArgument('depth_height', default_value='400'),
|
||||
DeclareLaunchArgument('depth_fps', default_value='30'),
|
||||
DeclareLaunchArgument('depth_format', default_value='Y14'),
|
||||
DeclareLaunchArgument('enable_depth', default_value='true'),
|
||||
DeclareLaunchArgument('flip_depth', default_value='false'),
|
||||
DeclareLaunchArgument('depth_qos', default_value='default'),
|
||||
DeclareLaunchArgument('depth_camera_info_qos', default_value='default'),
|
||||
DeclareLaunchArgument('ir_width', default_value='640'),
|
||||
DeclareLaunchArgument('ir_height', default_value='400'),
|
||||
DeclareLaunchArgument('ir_fps', default_value='30'),
|
||||
DeclareLaunchArgument('ir_format', default_value='Y8'),
|
||||
DeclareLaunchArgument('enable_ir', default_value='true'),
|
||||
DeclareLaunchArgument('flip_ir', default_value='false'),
|
||||
DeclareLaunchArgument('ir_qos', default_value='default'),
|
||||
DeclareLaunchArgument('ir_camera_info_qos', default_value='default'),
|
||||
DeclareLaunchArgument('enable_ir_auto_exposure', default_value='true'),
|
||||
DeclareLaunchArgument('publish_tf', default_value='true'),
|
||||
DeclareLaunchArgument('tf_publish_rate', default_value='10.0'),
|
||||
DeclareLaunchArgument('ir_info_url', default_value=''),
|
||||
DeclareLaunchArgument('color_info_url', default_value=''),
|
||||
DeclareLaunchArgument('log_level', default_value='none'),
|
||||
DeclareLaunchArgument('enable_publish_extrinsic', default_value='false'),
|
||||
DeclareLaunchArgument('enable_d2c_viewer', default_value='false'),
|
||||
DeclareLaunchArgument('enable_soft_filter', default_value='true'),
|
||||
DeclareLaunchArgument('enable_ldp', default_value='true'),
|
||||
]
|
||||
|
||||
# Node configuration
|
||||
parameters = [{arg.name: LaunchConfiguration(arg.name)} for arg in args]
|
||||
# Define the ComposableNode
|
||||
compose_node = ComposableNode(
|
||||
package='orbbec_camera',
|
||||
plugin='orbbec_camera::OBCameraNodeDriver',
|
||||
name=LaunchConfiguration('camera_name'),
|
||||
namespace='',
|
||||
parameters=parameters,
|
||||
)
|
||||
# Define the ComposableNodeContainer
|
||||
container = ComposableNodeContainer(
|
||||
name='camera_container',
|
||||
namespace='',
|
||||
package='rclcpp_components',
|
||||
executable='component_container',
|
||||
composable_node_descriptions=[
|
||||
compose_node,
|
||||
],
|
||||
output='screen',
|
||||
)
|
||||
|
||||
# Launch description
|
||||
ld = LaunchDescription(
|
||||
args +
|
||||
[
|
||||
GroupAction([
|
||||
PushRosNamespace(LaunchConfiguration('camera_name')),
|
||||
container
|
||||
])
|
||||
]
|
||||
)
|
||||
return ld
|
||||
@@ -0,0 +1,70 @@
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, GroupAction, ExecuteProcess
|
||||
from launch.substitutions import LaunchConfiguration
|
||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||
from launch_ros.substitutions import FindPackageShare
|
||||
from launch_ros.actions import Node
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
# Declare arguments
|
||||
camera_name = DeclareLaunchArgument('camera_name', default_value='camera')
|
||||
d_sensor = DeclareLaunchArgument('3d_sensor', default_value='gemini2')
|
||||
camera1_prefix = DeclareLaunchArgument('camera1_prefix', default_value='01')
|
||||
camera2_prefix = DeclareLaunchArgument('camera2_prefix', default_value='02')
|
||||
camera1_usb_port = DeclareLaunchArgument('camera1_usb_port', default_value='2-3.3')
|
||||
camera2_usb_port = DeclareLaunchArgument('camera2_usb_port', default_value='1-4.4')
|
||||
device_num = DeclareLaunchArgument('device_num', default_value='2')
|
||||
|
||||
# Node configuration
|
||||
cleanup_node = Node(
|
||||
package='orbbec_camera',
|
||||
executable='ob_cleanup_shm_node',
|
||||
name='camera',
|
||||
output='screen'
|
||||
)
|
||||
|
||||
# Include launch files
|
||||
launch_file_dir = FindPackageShare('orbbec_camera').find('orbbec_camera') + '/launch'
|
||||
launch1_include = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(launch_file_dir + '/' + (LaunchConfiguration('3d_sensor') + '.launch.py')),
|
||||
launch_arguments={
|
||||
'camera_name': 'camera_' + LaunchConfiguration('camera1_prefix'),
|
||||
'usb_port': LaunchConfiguration('camera1_usb_port'),
|
||||
'device_num': LaunchConfiguration('device_num')
|
||||
}.items()
|
||||
)
|
||||
|
||||
launch2_include = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(launch_file_dir + '/' + (LaunchConfiguration('3d_sensor') + '.launch.py')),
|
||||
launch_arguments={
|
||||
'camera_name': 'camera_' + LaunchConfiguration('camera2_prefix'),
|
||||
'usb_port': LaunchConfiguration('camera2_usb_port'),
|
||||
'device_num': LaunchConfiguration('device_num')
|
||||
}.items()
|
||||
)
|
||||
|
||||
# Static TF publisher
|
||||
tf_publisher = Node(
|
||||
package='tf2_ros',
|
||||
executable='static_transform_publisher',
|
||||
name='camera_tf',
|
||||
arguments=['0', '0', '0', '0', '0', '0', 'camera01_link', 'camera02_link']
|
||||
)
|
||||
|
||||
# Launch description
|
||||
ld = LaunchDescription([
|
||||
camera_name,
|
||||
d_sensor,
|
||||
camera1_prefix,
|
||||
camera2_prefix,
|
||||
camera1_usb_port,
|
||||
camera2_usb_port,
|
||||
device_num,
|
||||
cleanup_node,
|
||||
GroupAction([launch1_include]),
|
||||
GroupAction([launch2_include]),
|
||||
tf_publisher
|
||||
])
|
||||
|
||||
return ld
|
||||
Reference in New Issue
Block a user