mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-10-04 20:17:47 +08:00
fixed catch error
This commit is contained in:
@@ -53,8 +53,8 @@ void OBCameraNodeFactory::init() {
|
|||||||
device_num_ = declare_parameter<int>("device_num", 1);
|
device_num_ = declare_parameter<int>("device_num", 1);
|
||||||
ctx_->setDeviceChangedCallback([this](std::shared_ptr<ob::DeviceList> removed_list,
|
ctx_->setDeviceChangedCallback([this](std::shared_ptr<ob::DeviceList> removed_list,
|
||||||
std::shared_ptr<ob::DeviceList> added_list) {
|
std::shared_ptr<ob::DeviceList> added_list) {
|
||||||
|
(void)added_list;
|
||||||
onDeviceDisconnected(removed_list);
|
onDeviceDisconnected(removed_list);
|
||||||
onDeviceConnected(added_list);
|
|
||||||
});
|
});
|
||||||
check_connect_timer_ =
|
check_connect_timer_ =
|
||||||
this->create_wall_timer(std::chrono::milliseconds(1000), [this]() { checkConnectTimer(); });
|
this->create_wall_timer(std::chrono::milliseconds(1000), [this]() { checkConnectTimer(); });
|
||||||
@@ -67,10 +67,12 @@ void OBCameraNodeFactory::onDeviceConnected(const std::shared_ptr<ob::DeviceList
|
|||||||
if (device_list->deviceCount() == 0) {
|
if (device_list->deviceCount() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RCLCPP_INFO_STREAM(logger_, "onDeviceConnected");
|
RCLCPP_INFO_STREAM_THROTTLE(logger_, *get_clock(), 1000, "onDeviceConnected");
|
||||||
if (!device_) {
|
if (!device_) {
|
||||||
try {
|
try {
|
||||||
startDevice(device_list);
|
startDevice(device_list);
|
||||||
|
} catch (ob::Error &e) {
|
||||||
|
RCLCPP_ERROR_STREAM(logger_, "startDevice failed: " << e.getMessage());
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
RCLCPP_ERROR_STREAM(logger_, "startDevice failed: " << e.what());
|
RCLCPP_ERROR_STREAM(logger_, "startDevice failed: " << e.what());
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
@@ -123,7 +125,7 @@ void OBCameraNodeFactory::checkConnectTimer() const {
|
|||||||
|
|
||||||
void OBCameraNodeFactory::queryDevice() {
|
void OBCameraNodeFactory::queryDevice() {
|
||||||
while (is_alive_ && rclcpp::ok()) {
|
while (is_alive_ && rclcpp::ok()) {
|
||||||
if (!device_connected_) {
|
if (!device_connected_.load()) {
|
||||||
RCLCPP_INFO_STREAM_THROTTLE(logger_, *get_clock(), 1000, "Waiting for device connection...");
|
RCLCPP_INFO_STREAM_THROTTLE(logger_, *get_clock(), 1000, "Waiting for device connection...");
|
||||||
auto device_list = ctx_->queryDeviceList();
|
auto device_list = ctx_->queryDeviceList();
|
||||||
if (device_list->deviceCount() == 0) {
|
if (device_list->deviceCount() == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user