mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-10-04 20:17:47 +08:00
Add multi network camera sample, see #61
This commit is contained in:
@@ -16,6 +16,8 @@ def generate_launch_description():
|
||||
DeclareLaunchArgument('depth_registration', default_value='false'),
|
||||
DeclareLaunchArgument('serial_number', default_value=''),
|
||||
DeclareLaunchArgument('usb_port', default_value=''),
|
||||
DeclareLaunchArgument('net_device_ip', default_value=''),
|
||||
DeclareLaunchArgument('net_device_port', default_value='0'),
|
||||
DeclareLaunchArgument('device_num', default_value='1'),
|
||||
DeclareLaunchArgument('vendor_id', default_value='0x2bc5'),
|
||||
DeclareLaunchArgument('product_id', default_value=''),
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription, GroupAction, ExecuteProcess
|
||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||
from launch_ros.actions import Node
|
||||
from ament_index_python.packages import get_package_share_directory
|
||||
import os
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
# Include launch files
|
||||
package_dir = get_package_share_directory('orbbec_camera')
|
||||
launch_file_dir = os.path.join(package_dir, 'launch')
|
||||
launch1_include = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
os.path.join(launch_file_dir, 'femto_mega.launch.py')
|
||||
),
|
||||
launch_arguments={
|
||||
'camera_name': 'camera_01',
|
||||
'net_device_ip': '192.168.2.10',
|
||||
'net_device_port': '8090',
|
||||
'sync_mode': 'standalone'
|
||||
}.items()
|
||||
)
|
||||
|
||||
launch2_include = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
os.path.join(launch_file_dir, 'femto_mega.launch.py')
|
||||
),
|
||||
launch_arguments={
|
||||
'camera_name': 'camera_02',
|
||||
'net_device_ip': '192.168.1.11',
|
||||
'net_device_port': '8090',
|
||||
'sync_mode': 'standalone'
|
||||
}.items()
|
||||
)
|
||||
|
||||
# If you need more cameras, just add more launch_include here, and change the usb_port and device_num
|
||||
|
||||
# Launch description
|
||||
ld = LaunchDescription([
|
||||
GroupAction([launch1_include]),
|
||||
GroupAction([launch2_include]),
|
||||
])
|
||||
|
||||
return ld
|
||||
@@ -435,6 +435,8 @@ void OBCameraNodeDriver::connectNetDevice(const std::string &net_device_ip, int
|
||||
RCLCPP_ERROR_STREAM(logger_, "Invalid net device ip or port");
|
||||
return;
|
||||
}
|
||||
RCLCPP_INFO_STREAM(logger_, "Connecting to net device ip: " << net_device_ip
|
||||
<< " port: " << net_device_port);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(connection_delay_));
|
||||
auto device = ctx_->createNetDevice(net_device_ip.c_str(), net_device_port);
|
||||
if (device == nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user