Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Proper Resource Cleanup in ob_camera_node_driver.cpp and Simplify Multi-Camera Configuration in multi_femto.launch.py #11

Merged
merged 7 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions orbbec_camera/launch/multi_femto.launch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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

Expand All @@ -17,7 +16,6 @@ def generate_launch_description():
launch_arguments={
'camera_name': 'front_camera',
'usb_port': '2-2',
# 'serial_number': 'CL8K14100WH',
'device_num': '2',
'sync_mode': 'standalone',
'enable_colored_point_cloud': 'true'
Expand All @@ -31,7 +29,6 @@ def generate_launch_description():
launch_arguments={
'camera_name': 'top_camera',
'usb_port': '2-3',
# 'serial_number': 'CL8K14101DW',
'device_num': '2',
'sync_mode': 'standalone',
'enable_colored_point_cloud': 'true'
Expand Down
48 changes: 40 additions & 8 deletions orbbec_camera/src/ob_camera_node_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ OBCameraNodeDriver::~OBCameraNodeDriver() {
reset_device_cond_.notify_all();
reset_device_thread_->join();
}
if (orb_device_lock_shm_fd_ >= 0) {
close(orb_device_lock_shm_fd_);
shm_unlink(ORB_DEFAULT_LOCK_NAME.c_str());
}
}

void OBCameraNodeDriver::init() {
Expand Down Expand Up @@ -276,23 +280,51 @@ void OBCameraNodeDriver::rebootDeviceCallback(
std::shared_ptr<ob::Device> OBCameraNodeDriver::selectDevice(
const std::shared_ptr<ob::DeviceList> &list) {
if (device_num_ == 1) {
RCLCPP_INFO_STREAM(logger_, "Connecting to the default device");
return list->getDevice(0);
std::shared_ptr<ob::Device> device = nullptr;
if (!serial_number_.empty()) {
RCLCPP_INFO_STREAM(logger_, "Connecting to device with serial number: " << serial_number_);
device = selectDeviceBySerialNumber(list, serial_number_);
if (device == nullptr) {
RCLCPP_WARN_THROTTLE(logger_, *get_clock(), 1000, "Device with serial number %s not found",
serial_number_.c_str());
device_connected_ = false;
return nullptr;
}
} else if (!usb_port_.empty()) {
RCLCPP_INFO_STREAM(logger_, "Connecting to device with usb port: " << usb_port_);
device = selectDeviceByUSBPort(list, usb_port_);
if (device == nullptr) {
RCLCPP_WARN_THROTTLE(logger_, *get_clock(), 1000, "Device with usb port: %s not found",
usb_port_.c_str());
device_connected_ = false;
return nullptr;
}
} else {
RCLCPP_INFO_STREAM(logger_, "Connecting to the default device");
return list->getDevice(0);
}
return device;
}

std::shared_ptr<ob::Device> device = nullptr;
if (!serial_number_.empty()) {
RCLCPP_INFO_STREAM(logger_, "Connecting to device with serial number: " << serial_number_);
device = selectDeviceBySerialNumber(list, serial_number_);
if (device == nullptr) {
RCLCPP_WARN_THROTTLE(logger_, *get_clock(), 1000, "Device with serial number %s not found",
serial_number_.c_str());
device_connected_ = false;
return nullptr;
}
} else if (!usb_port_.empty()) {
RCLCPP_INFO_STREAM(logger_, "Connecting to device with usb port: " << usb_port_);
device = selectDeviceByUSBPort(list, usb_port_);
}
if (device == nullptr) {
RCLCPP_WARN_THROTTLE(logger_, *get_clock(), 1000, "Device with serial number %s not found",
serial_number_.c_str());
device_connected_ = false;
return nullptr;
if (device == nullptr) {
RCLCPP_WARN_THROTTLE(logger_, *get_clock(), 1000, "Device with usb port: %s not found",
usb_port_.c_str());
device_connected_ = false;
return nullptr;
}
}
return device;
}
Expand Down
106 changes: 106 additions & 0 deletions orbbec_description/meshes/femto_bolt.dae

Large diffs are not rendered by default.