mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-10-04 20:17:47 +08:00
Refactor device selection logic in OBCameraNodeDriver
This commit is contained in:
@@ -275,11 +275,6 @@ 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_);
|
||||
@@ -287,6 +282,9 @@ std::shared_ptr<ob::Device> OBCameraNodeDriver::selectDevice(
|
||||
} else if (!usb_port_.empty()) {
|
||||
RCLCPP_INFO_STREAM(logger_, "Connecting to device with usb port: " << usb_port_);
|
||||
device = selectDeviceByUSBPort(list, usb_port_);
|
||||
} else if (device_num_ == 1) {
|
||||
RCLCPP_INFO_STREAM(logger_, "Connecting to the default device");
|
||||
return list->getDevice(0);
|
||||
}
|
||||
if (device == nullptr) {
|
||||
RCLCPP_WARN_THROTTLE(logger_, *get_clock(), 1000, "Device with serial number %s not found",
|
||||
|
||||
Reference in New Issue
Block a user