2023-09-13 18:51:12 +08:00
|
|
|
|
from launch import LaunchDescription
|
2026-01-14 17:53:52 +08:00
|
|
|
|
from launch.actions import DeclareLaunchArgument, OpaqueFunction
|
2023-09-13 18:51:12 +08:00
|
|
|
|
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
|
2023-11-07 09:31:51 +08:00
|
|
|
|
from launch_ros.actions import Node
|
|
|
|
|
|
import os
|
2026-01-14 17:53:52 +08:00
|
|
|
|
import yaml
|
2023-09-13 18:51:12 +08:00
|
|
|
|
|
2026-01-14 17:53:52 +08:00
|
|
|
|
def convert_value(value):
|
|
|
|
|
|
if isinstance(value, str):
|
|
|
|
|
|
try:
|
|
|
|
|
|
return int(value)
|
|
|
|
|
|
except ValueError:
|
|
|
|
|
|
pass
|
|
|
|
|
|
try:
|
|
|
|
|
|
return float(value)
|
|
|
|
|
|
except ValueError:
|
|
|
|
|
|
pass
|
|
|
|
|
|
if value.lower() == 'true':
|
|
|
|
|
|
return True
|
|
|
|
|
|
elif value.lower() == 'false':
|
|
|
|
|
|
return False
|
|
|
|
|
|
return value
|
|
|
|
|
|
|
|
|
|
|
|
def load_parameters(context, args):
|
|
|
|
|
|
default_params = {arg.name: LaunchConfiguration(arg.name).perform(context) for arg in args}
|
|
|
|
|
|
skip_convert = {'config_file_path', 'usb_port', 'serial_number'}
|
|
|
|
|
|
result = {}
|
|
|
|
|
|
for key, value in default_params.items():
|
|
|
|
|
|
if key in skip_convert:
|
|
|
|
|
|
result[key] = value
|
|
|
|
|
|
elif 'enable_pub_plugins' in key:
|
|
|
|
|
|
if isinstance(value, str):
|
|
|
|
|
|
if value.startswith('[') and value.endswith(']'):
|
|
|
|
|
|
try:
|
|
|
|
|
|
result[key] = yaml.safe_load(value)
|
|
|
|
|
|
except:
|
|
|
|
|
|
result[key] = [value]
|
|
|
|
|
|
else:
|
|
|
|
|
|
result[key] = [value]
|
|
|
|
|
|
elif isinstance(value, list):
|
|
|
|
|
|
result[key] = value
|
|
|
|
|
|
else:
|
|
|
|
|
|
result[key] = [str(value)]
|
|
|
|
|
|
else:
|
|
|
|
|
|
result[key] = convert_value(value)
|
|
|
|
|
|
|
|
|
|
|
|
return result
|
2023-09-13 18:51:12 +08:00
|
|
|
|
|
|
|
|
|
|
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'),
|
2024-09-13 10:18:09 +08:00
|
|
|
|
DeclareLaunchArgument('cloud_frame_id', default_value=''),
|
2023-09-13 18:51:12 +08:00
|
|
|
|
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='10'),
|
|
|
|
|
|
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'),
|
2025-10-21 14:41:10 +08:00
|
|
|
|
DeclareLaunchArgument('enable_color_auto_exposure_priority', default_value='false'),
|
2024-06-17 14:19:02 +08:00
|
|
|
|
DeclareLaunchArgument('color_exposure', default_value='-1'),
|
|
|
|
|
|
DeclareLaunchArgument('color_gain', default_value='-1'),
|
|
|
|
|
|
DeclareLaunchArgument('enable_color_auto_white_balance', default_value='true'),
|
|
|
|
|
|
DeclareLaunchArgument('color_white_balance', default_value='-1'),
|
2024-11-05 16:18:02 +08:00
|
|
|
|
DeclareLaunchArgument('color_ae_max_exposure', default_value='-1'),
|
|
|
|
|
|
DeclareLaunchArgument('color_brightness', default_value='-1'),
|
|
|
|
|
|
DeclareLaunchArgument('color_sharpness', default_value='-1'),
|
|
|
|
|
|
DeclareLaunchArgument('color_saturation', default_value='-1'),
|
|
|
|
|
|
DeclareLaunchArgument('color_contrast', default_value='-1'),
|
|
|
|
|
|
DeclareLaunchArgument('color_gamma', default_value='-1'),
|
|
|
|
|
|
DeclareLaunchArgument('color_hue', default_value='-1'),
|
2023-09-13 18:51:12 +08:00
|
|
|
|
DeclareLaunchArgument('depth_width', default_value='640'),
|
|
|
|
|
|
DeclareLaunchArgument('depth_height', default_value='400'),
|
|
|
|
|
|
DeclareLaunchArgument('depth_fps', default_value='10'),
|
|
|
|
|
|
DeclareLaunchArgument('depth_format', default_value='Y11'),
|
|
|
|
|
|
DeclareLaunchArgument('enable_depth', default_value='true'),
|
|
|
|
|
|
DeclareLaunchArgument('flip_depth', default_value='false'),
|
2026-01-29 14:57:29 +08:00
|
|
|
|
DeclareLaunchArgument('min_depth_limit', default_value='0'),
|
|
|
|
|
|
DeclareLaunchArgument('max_depth_limit', default_value='0'),
|
2023-09-13 18:51:12 +08:00
|
|
|
|
DeclareLaunchArgument('depth_qos', default_value='default'),
|
|
|
|
|
|
DeclareLaunchArgument('depth_camera_info_qos', default_value='default'),
|
2024-01-02 16:26:23 +08:00
|
|
|
|
# /config/depthfilter/Openni_device.json,need config path.
|
|
|
|
|
|
DeclareLaunchArgument('depth_filter_config', default_value=''),
|
2023-09-13 18:51:12 +08:00
|
|
|
|
DeclareLaunchArgument('ir_width', default_value='640'),
|
|
|
|
|
|
DeclareLaunchArgument('ir_height', default_value='400'),
|
|
|
|
|
|
DeclareLaunchArgument('ir_fps', default_value='10'),
|
|
|
|
|
|
DeclareLaunchArgument('ir_format', default_value='Y10'),
|
|
|
|
|
|
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'),
|
2024-06-17 14:19:02 +08:00
|
|
|
|
DeclareLaunchArgument('ir_exposure', default_value='-1'),
|
|
|
|
|
|
DeclareLaunchArgument('ir_gain', default_value='-1'),
|
2023-09-13 18:51:12 +08:00
|
|
|
|
DeclareLaunchArgument('publish_tf', default_value='true'),
|
2024-07-13 14:07:29 +08:00
|
|
|
|
DeclareLaunchArgument('tf_publish_rate', default_value='0.0'),
|
2023-09-13 18:51:12 +08:00
|
|
|
|
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_soft_filter', default_value='true'),
|
|
|
|
|
|
DeclareLaunchArgument('enable_ldp', default_value='true'),
|
|
|
|
|
|
DeclareLaunchArgument('soft_filter_max_diff', default_value='-1'),
|
2023-11-15 11:05:38 +08:00
|
|
|
|
DeclareLaunchArgument('soft_filter_speckle_size', default_value='-1'),
|
|
|
|
|
|
DeclareLaunchArgument('ordered_pc', default_value='false'),
|
2024-02-29 09:24:12 +08:00
|
|
|
|
DeclareLaunchArgument('enable_depth_scale', default_value='true'),
|
2024-04-07 16:28:02 +08:00
|
|
|
|
DeclareLaunchArgument('align_mode', default_value='HW'),
|
2024-06-13 11:08:20 +08:00
|
|
|
|
DeclareLaunchArgument('laser_energy_level', default_value='-1'),
|
2024-08-05 10:22:28 +08:00
|
|
|
|
DeclareLaunchArgument('enable_heartbeat', default_value='false'),
|
2025-04-22 17:51:40 +08:00
|
|
|
|
DeclareLaunchArgument('industry_mode', default_value=''),
|
2026-01-14 17:53:52 +08:00
|
|
|
|
|
|
|
|
|
|
#color image transport plugins
|
|
|
|
|
|
DeclareLaunchArgument('color.image_raw.enable_pub_plugins',default_value='["image_transport/compressed", "image_transport/raw", "image_transport/theora"]'),
|
|
|
|
|
|
#depth image transport plugins
|
|
|
|
|
|
DeclareLaunchArgument('depth.image_raw.enable_pub_plugins',default_value='["image_transport/compressedDepth", "image_transport/raw"]'),
|
|
|
|
|
|
#ir image transport plugins
|
|
|
|
|
|
DeclareLaunchArgument('ir.image_raw.enable_pub_plugins',default_value='["image_transport/compressed", "image_transport/raw", "image_transport/theora"]'),
|
2023-09-13 18:51:12 +08:00
|
|
|
|
]
|
|
|
|
|
|
|
2026-01-14 17:53:52 +08:00
|
|
|
|
def get_params(context, args):
|
|
|
|
|
|
return [load_parameters(context, args)]
|
|
|
|
|
|
|
|
|
|
|
|
def create_node_action(context, args):
|
|
|
|
|
|
params = get_params(context, args)
|
|
|
|
|
|
ros_distro = os.environ.get("ROS_DISTRO", "humble")
|
|
|
|
|
|
if ros_distro == "foxy":
|
|
|
|
|
|
return [
|
2023-11-07 09:31:51 +08:00
|
|
|
|
Node(
|
|
|
|
|
|
package="orbbec_camera",
|
|
|
|
|
|
executable="orbbec_camera_node",
|
|
|
|
|
|
name="ob_camera_node",
|
|
|
|
|
|
namespace=LaunchConfiguration("camera_name"),
|
2026-01-14 17:53:52 +08:00
|
|
|
|
parameters=params,
|
2023-11-07 09:31:51 +08:00
|
|
|
|
output="screen",
|
|
|
|
|
|
)
|
|
|
|
|
|
]
|
2026-01-14 17:53:52 +08:00
|
|
|
|
else:
|
|
|
|
|
|
return [
|
|
|
|
|
|
GroupAction([
|
|
|
|
|
|
PushRosNamespace(LaunchConfiguration("camera_name")),
|
|
|
|
|
|
ComposableNodeContainer(
|
|
|
|
|
|
name="camera_container",
|
|
|
|
|
|
namespace="",
|
|
|
|
|
|
package="rclcpp_components",
|
|
|
|
|
|
executable="component_container",
|
|
|
|
|
|
composable_node_descriptions=[
|
|
|
|
|
|
ComposableNode(
|
|
|
|
|
|
package="orbbec_camera",
|
|
|
|
|
|
plugin="orbbec_camera::OBCameraNodeDriver",
|
|
|
|
|
|
name=LaunchConfiguration("camera_name"),
|
|
|
|
|
|
parameters=params,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
output="screen",
|
|
|
|
|
|
)
|
|
|
|
|
|
])
|
2023-11-07 09:31:51 +08:00
|
|
|
|
]
|
2026-01-14 17:53:52 +08:00
|
|
|
|
|
|
|
|
|
|
return LaunchDescription(
|
|
|
|
|
|
args + [
|
|
|
|
|
|
OpaqueFunction(function=lambda context: create_node_action(context, args))
|
|
|
|
|
|
]
|
|
|
|
|
|
)
|