mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-10-04 20:17:47 +08:00
use shared container to launch 4 camera node
This commit is contained in:
@@ -636,6 +636,8 @@ class OBCameraNode {
|
|||||||
int interleave_skip_index_ = 1;
|
int interleave_skip_index_ = 1;
|
||||||
int interleave_skip_depth_index_ = 1;
|
int interleave_skip_depth_index_ = 1;
|
||||||
|
|
||||||
|
double delta_duration_ = 5000.0;
|
||||||
|
int delta_fps_ = 2;
|
||||||
VideoStreamInfo color_stream_info_ = {OB_FRAME_COLOR, std::chrono::steady_clock::now()};
|
VideoStreamInfo color_stream_info_ = {OB_FRAME_COLOR, std::chrono::steady_clock::now()};
|
||||||
VideoStreamInfo depth_stream_info_ = {OB_FRAME_DEPTH, std::chrono::steady_clock::now()};
|
VideoStreamInfo depth_stream_info_ = {OB_FRAME_DEPTH, std::chrono::steady_clock::now()};
|
||||||
VideoStreamInfo left_ir_stream_info_ = {OB_FRAME_IR_LEFT, std::chrono::steady_clock::now()};
|
VideoStreamInfo left_ir_stream_info_ = {OB_FRAME_IR_LEFT, std::chrono::steady_clock::now()};
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ from launch.actions import DeclareLaunchArgument, OpaqueFunction, GroupAction
|
|||||||
from launch.substitutions import LaunchConfiguration
|
from launch.substitutions import LaunchConfiguration
|
||||||
from launch_ros.actions import PushRosNamespace, ComposableNodeContainer, Node
|
from launch_ros.actions import PushRosNamespace, ComposableNodeContainer, Node
|
||||||
from launch_ros.descriptions import ComposableNode
|
from launch_ros.descriptions import ComposableNode
|
||||||
|
from launch.conditions import UnlessCondition
|
||||||
|
from launch_ros.actions import LoadComposableNodes
|
||||||
|
|
||||||
def load_yaml(file_path):
|
def load_yaml(file_path):
|
||||||
with open(file_path, 'r') as f:
|
with open(file_path, 'r') as f:
|
||||||
@@ -185,6 +186,11 @@ def generate_launch_description():
|
|||||||
DeclareLaunchArgument('interleave_frame_enable', default_value='true'),
|
DeclareLaunchArgument('interleave_frame_enable', default_value='true'),
|
||||||
DeclareLaunchArgument('interleave_skip_enable', default_value='true'),
|
DeclareLaunchArgument('interleave_skip_enable', default_value='true'),
|
||||||
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('attach_to_shared_component_container', default_value='false'),
|
||||||
|
DeclareLaunchArgument('component_container_name', default_value='orbbec_container'),
|
||||||
|
DeclareLaunchArgument('delta_duration', default_value='5000.0'),
|
||||||
|
DeclareLaunchArgument('delta_fps', default_value='2'),
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_params(context, args):
|
def get_params(context, args):
|
||||||
@@ -205,25 +211,31 @@ def generate_launch_description():
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
|
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')
|
||||||
|
|
||||||
|
orbbec_container = Node(
|
||||||
|
name=component_container_name_arg,
|
||||||
|
package='rclcpp_components',
|
||||||
|
executable='component_container_mt',
|
||||||
|
output='screen',
|
||||||
|
condition=UnlessCondition(attach_to_shared_component_container_arg)
|
||||||
|
)
|
||||||
return [
|
return [
|
||||||
GroupAction([
|
orbbec_container,
|
||||||
PushRosNamespace(LaunchConfiguration("camera_name")),
|
LoadComposableNodes(
|
||||||
ComposableNodeContainer(
|
target_container=component_container_name_arg,
|
||||||
name="camera_container",
|
composable_node_descriptions=[
|
||||||
namespace="",
|
ComposableNode(
|
||||||
package="rclcpp_components",
|
namespace=LaunchConfiguration("camera_name"),
|
||||||
executable="component_container",
|
name=LaunchConfiguration("camera_name"),
|
||||||
composable_node_descriptions=[
|
package='orbbec_camera',
|
||||||
ComposableNode(
|
plugin='orbbec_camera::OBCameraNodeDriver',
|
||||||
package="orbbec_camera",
|
parameters=params,
|
||||||
plugin="orbbec_camera::OBCameraNodeDriver",
|
extra_arguments=[{'use_intra_process_comms': LaunchConfiguration("use_intra_process_comms")}],
|
||||||
name=LaunchConfiguration("camera_name"),
|
|
||||||
parameters=params,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
output="screen",
|
|
||||||
)
|
)
|
||||||
])
|
]
|
||||||
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
return LaunchDescription(
|
return LaunchDescription(
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ from launch import LaunchDescription
|
|||||||
from launch_ros.actions import Node
|
from launch_ros.actions import Node
|
||||||
from launch.actions import IncludeLaunchDescription, GroupAction, TimerAction
|
from launch.actions import IncludeLaunchDescription, GroupAction, TimerAction
|
||||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
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():
|
def generate_launch_description():
|
||||||
# Include launch files
|
# Include launch files
|
||||||
@@ -12,6 +15,22 @@ 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', 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(
|
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")
|
||||||
@@ -22,6 +41,9 @@ def generate_launch_description():
|
|||||||
"device_num": "4",
|
"device_num": "4",
|
||||||
"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"),
|
||||||
|
'attach_to_shared_component_container': LaunchConfiguration("attach_to_shared_component_container"),
|
||||||
|
'component_container_name': shared_container_name,
|
||||||
}.items(),
|
}.items(),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -35,6 +57,9 @@ def generate_launch_description():
|
|||||||
"device_num": "4",
|
"device_num": "4",
|
||||||
"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"),
|
||||||
|
'attach_to_shared_component_container': LaunchConfiguration("attach_to_shared_component_container"),
|
||||||
|
'component_container_name': shared_container_name,
|
||||||
}.items(),
|
}.items(),
|
||||||
)
|
)
|
||||||
right_camera = IncludeLaunchDescription(
|
right_camera = IncludeLaunchDescription(
|
||||||
@@ -47,6 +72,9 @@ def generate_launch_description():
|
|||||||
"device_num": "4",
|
"device_num": "4",
|
||||||
"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"),
|
||||||
|
'attach_to_shared_component_container': LaunchConfiguration("attach_to_shared_component_container"),
|
||||||
|
'component_container_name': shared_container_name,
|
||||||
}.items(),
|
}.items(),
|
||||||
)
|
)
|
||||||
rear_camera = IncludeLaunchDescription(
|
rear_camera = IncludeLaunchDescription(
|
||||||
@@ -59,16 +87,46 @@ def generate_launch_description():
|
|||||||
"device_num": "4",
|
"device_num": "4",
|
||||||
"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"),
|
||||||
|
'attach_to_shared_component_container': LaunchConfiguration("attach_to_shared_component_container"),
|
||||||
|
'component_container_name': shared_container_name,
|
||||||
}.items(),
|
}.items(),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Launch description
|
# 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(
|
ld = LaunchDescription(
|
||||||
[
|
[
|
||||||
TimerAction(period=0.5, actions=[GroupAction([left_camera])]),
|
use_intra_process_comms_arg,
|
||||||
TimerAction(period=0.5, actions=[GroupAction([right_camera])]),
|
attach_to_shared_component_container_arg,
|
||||||
TimerAction(period=0.5, actions=[GroupAction([rear_camera])]),
|
shared_container,
|
||||||
TimerAction(period=0.5, actions=[GroupAction([front_camera])]),
|
delayed_left_camera,
|
||||||
|
delayed_right_camera,
|
||||||
|
delayed_rear_camera,
|
||||||
|
delayed_front_camera,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1287,6 +1287,9 @@ void OBCameraNode::getParameters() {
|
|||||||
setAndGetNodeParameter<bool>(interleave_frame_enable_, "interleave_frame_enable", false);
|
setAndGetNodeParameter<bool>(interleave_frame_enable_, "interleave_frame_enable", false);
|
||||||
setAndGetNodeParameter<bool>(interleave_skip_enable_, "interleave_skip_enable", false);
|
setAndGetNodeParameter<bool>(interleave_skip_enable_, "interleave_skip_enable", false);
|
||||||
setAndGetNodeParameter<int>(interleave_skip_index_, "interleave_skip_index", 1);
|
setAndGetNodeParameter<int>(interleave_skip_index_, "interleave_skip_index", 1);
|
||||||
|
|
||||||
|
setAndGetNodeParameter<double>(delta_duration_, "delta_duration", 5000.0);
|
||||||
|
setAndGetNodeParameter<int>(delta_fps_, "delta_fps", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBCameraNode::setupTopics() {
|
void OBCameraNode::setupTopics() {
|
||||||
@@ -2034,8 +2037,8 @@ void OBCameraNode::updateStreamInfo(VideoStreamInfo& stream_info) {
|
|||||||
double dst_duration = duration;
|
double dst_duration = duration;
|
||||||
int dst_fps = 0;
|
int dst_fps = 0;
|
||||||
stream_index_pair dst_frame_type;
|
stream_index_pair dst_frame_type;
|
||||||
double delta_duration = 2000.0;
|
double delta_duration = delta_duration_;
|
||||||
int delta_fps = 2;
|
int delta_fps = delta_fps_;
|
||||||
|
|
||||||
switch (stream_info.frame_type) {
|
switch (stream_info.frame_type) {
|
||||||
case OB_FRAME_COLOR:
|
case OB_FRAME_COLOR:
|
||||||
|
|||||||
Reference in New Issue
Block a user