mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-09-15 04:20:20 +08:00
fix multi camera
This commit is contained in:
@@ -3,20 +3,20 @@
|
||||
color_width: 640
|
||||
color_height: 480
|
||||
color_fps: 30
|
||||
color_frame_id: "color_frame"
|
||||
color_optical_frame_id: "color_optical_frame"
|
||||
color_frame_id: "color_frame1"
|
||||
color_optical_frame_id: "color_optical_frame1"
|
||||
enable_color: true
|
||||
ir_width: 640
|
||||
ir_height: 480
|
||||
ir_fps: 30
|
||||
ir_frame_id: "ir_frame"
|
||||
ir_optical_frame_id: "ir_optical_frame"
|
||||
ir_frame_id: "ir_frame1"
|
||||
ir_optical_frame_id: "ir_optical_frame1"
|
||||
enable_ir: false
|
||||
depth_width: 640
|
||||
depth_height: 480
|
||||
depth_fps: 25
|
||||
depth_frame_id: "depth_frame"
|
||||
depth_optical_frame_id: "depth_optical_frame"
|
||||
depth_frame_id: "depth_frame1"
|
||||
depth_optical_frame_id: "depth_optical_frame1"
|
||||
enable_depth: true
|
||||
publish_tf: true
|
||||
tf_publish_rate: 10.0
|
||||
@@ -24,6 +24,6 @@
|
||||
wait_for_device_timeout: 120.0
|
||||
reconnect_timeout: 6.0
|
||||
d2c_mode: "hw"
|
||||
serial_number: ""
|
||||
serial_number: "BY19810004G"
|
||||
camera_link_frame_id: "camera1_link"
|
||||
ob_log_level: "none"
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
color_width: 640
|
||||
color_height: 480
|
||||
color_fps: 30
|
||||
color_frame_id: "color_frame"
|
||||
color_optical_frame_id: "color_optical_frame"
|
||||
color_frame_id: "color_frame2"
|
||||
color_optical_frame_id: "color_optical_frame2"
|
||||
enable_color: true
|
||||
ir_width: 640
|
||||
ir_height: 480
|
||||
ir_fps: 30
|
||||
ir_frame_id: "ir_frame"
|
||||
ir_optical_frame_id: "ir_optical_frame"
|
||||
ir_frame_id: "ir_frame2"
|
||||
ir_optical_frame_id: "ir_optical_frame2"
|
||||
enable_ir: false
|
||||
depth_width: 640
|
||||
depth_height: 480
|
||||
depth_fps: 25
|
||||
depth_frame_id: "depth_frame"
|
||||
depth_optical_frame_id: "depth_optical_frame"
|
||||
depth_frame_id: "depth_frame2"
|
||||
depth_optical_frame_id: "depth_optical_frame2"
|
||||
enable_depth: true
|
||||
publish_tf: true
|
||||
tf_publish_rate: 10.0
|
||||
@@ -24,6 +24,6 @@
|
||||
wait_for_device_timeout: 120.0
|
||||
reconnect_timeout: 6.0
|
||||
d2c_mode: "hw"
|
||||
serial_number: ""
|
||||
serial_number: "BX2H611003M"
|
||||
camera_link_frame_id: "camera2_link"
|
||||
ob_log_level: "none"
|
||||
|
||||
@@ -18,7 +18,6 @@ OBCameraNodeFactory::OBCameraNodeFactory(const rclcpp::NodeOptions &node_options
|
||||
logger_(this->get_logger()) {
|
||||
init();
|
||||
}
|
||||
|
||||
OBCameraNodeFactory::OBCameraNodeFactory(const std::string &node_name, const std::string &ns,
|
||||
const rclcpp::NodeOptions &node_options)
|
||||
: Node(node_name, ns, node_options),
|
||||
@@ -33,10 +32,8 @@ OBCameraNodeFactory::~OBCameraNodeFactory() {
|
||||
query_thread_.join();
|
||||
}
|
||||
}
|
||||
|
||||
void OBCameraNodeFactory::init() {
|
||||
ob_log_level_ = declare_parameter<std::string>("ob_log_level", "none");
|
||||
ctx_->setLoggerSeverity(obLogSeverityFromString(ob_log_level_));
|
||||
ctx_->setLoggerSeverity(OB_LOG_SEVERITY_NONE);
|
||||
is_alive_.store(true);
|
||||
parameters_ = std::make_shared<Parameters>(this);
|
||||
serial_number_ = declare_parameter<std::string>("serial_number", "");
|
||||
@@ -126,21 +123,6 @@ void OBCameraNodeFactory::printDeviceInfo(const std::shared_ptr<ob::DeviceInfo>
|
||||
RCLCPP_INFO_STREAM(logger_, "hardware version " << device_info->hardwareVersion());
|
||||
}
|
||||
|
||||
OBLogSeverity OBCameraNodeFactory::obLogSeverityFromString(const std::string &log_level) {
|
||||
if (log_level == "debug") {
|
||||
return OB_LOG_SEVERITY_DEBUG;
|
||||
} else if (log_level == "info") {
|
||||
return OB_LOG_SEVERITY_INFO;
|
||||
} else if (log_level == "warn" || log_level == "warning") {
|
||||
return OB_LOG_SEVERITY_WARN;
|
||||
} else if (log_level == "fatal" || log_level == "error") {
|
||||
return OB_LOG_SEVERITY_FATAL;
|
||||
} else {
|
||||
// Default None
|
||||
return OB_LOG_SEVERITY_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
void OBCameraNodeFactory::getDevice(const std::shared_ptr<ob::DeviceList> &list) {
|
||||
if (device_) {
|
||||
return;
|
||||
@@ -161,6 +143,18 @@ void OBCameraNodeFactory::getDevice(const std::shared_ptr<ob::DeviceList> &list)
|
||||
} else {
|
||||
device_ = list->getDeviceBySN(serial_number_.c_str());
|
||||
if (device_ == nullptr) {
|
||||
std::string lower_sn;
|
||||
std::transform(serial_number_.begin(), serial_number_.end(), std::back_inserter(lower_sn),
|
||||
[](auto ch) {
|
||||
return isalpha(ch) ? tolower(ch) : static_cast<int>(ch);
|
||||
});
|
||||
device_ = list->getDeviceBySN(lower_sn.c_str());
|
||||
}
|
||||
if (device_ == nullptr) {
|
||||
for (size_t i = 0; i < list->deviceCount(); i++) {
|
||||
auto sn = list->serialNumber(i);
|
||||
RCLCPP_ERROR_STREAM(logger_, "found device with SN " << sn);
|
||||
}
|
||||
RCLCPP_ERROR_STREAM(logger_, "can not found device with SN " << serial_number_);
|
||||
} else {
|
||||
printDeviceInfo(device_->getDeviceInfo());
|
||||
|
||||
Reference in New Issue
Block a user