add exception handling for rebootDeviceCallback and downgrade expected errors to WARN

This commit is contained in:
obyalian
2025-09-28 10:11:32 +08:00
parent 1ab5000086
commit 820f1b999e
2 changed files with 13 additions and 5 deletions
+1 -1
View File
@@ -972,7 +972,7 @@ void OBCameraNode::stopStreams() {
try {
pipeline_->stop();
} catch (const ob::Error &e) {
RCLCPP_ERROR_STREAM(logger_, "Failed to stop pipeline: " << e.getMessage());
RCLCPP_WARN_STREAM(logger_, "Failed to stop pipeline: " << e.getMessage());
} catch (...) {
RCLCPP_ERROR_STREAM(logger_, "Failed to stop pipeline");
}
+12 -4
View File
@@ -275,9 +275,17 @@ void OBCameraNodeDriver::rebootDeviceCallback(
return;
}
RCLCPP_INFO(logger_, "Reboot device");
ob_camera_node_->rebootDevice();
device_connected_ = false;
device_ = nullptr;
try {
ob_camera_node_->rebootDevice();
device_connected_ = false;
device_ = nullptr;
} catch (const ob::Error &e) {
RCLCPP_WARN(logger_, "Failed to reboot device: %s", e.getMessage());
} catch (const std::exception &e) {
RCLCPP_ERROR(logger_, "Exception during reboot: %s", e.what());
} catch (...) {
RCLCPP_ERROR(logger_, "Unknown error occurred during reboot");
}
}
std::shared_ptr<ob::Device> OBCameraNodeDriver::selectDevice(
@@ -503,7 +511,7 @@ void OBCameraNodeDriver::startDevice(const std::shared_ptr<ob::DeviceList> &list
std::shared_ptr<int> lock_holder(nullptr,
[this](int *) { pthread_mutex_unlock(orb_device_lock_); });
//check device connected flag again after get lock
// check device connected flag again after get lock
if (device_connected_) {
return;
}