Refactor code for improved readability and consistency

This commit is contained in:
slz
2026-06-10 15:17:15 +08:00
parent 77695a78c8
commit 14b62847eb
23 changed files with 271 additions and 275 deletions
+16 -16
View File
@@ -71,20 +71,21 @@ inline std::string formatObErrorWithStatus(const ob::Error& e) {
RCLCPP_ERROR(logger_, "Unknown exception in %s at line %d", __FUNCTION__, __LINE__); \
}
#define TRY_TO_SET_PROPERTY(func, property, value) \
try { \
device_->func(property, value); \
} catch (const ob::Error& e) { \
RCLCPP_ERROR_STREAM(logger_, "Failed to set " << property << " to " << value << " in " \
<< __FUNCTION__ << " at line " << __LINE__ \
<< ": " << orbbec_camera::formatObErrorWithStatus(e)); \
} catch (const std::exception& e) { \
RCLCPP_ERROR_STREAM(logger_, "Failed to set " << property << " to " << value << " in " \
<< __FUNCTION__ << " at line " << __LINE__ \
<< ": " << e.what()); \
} catch (...) { \
RCLCPP_ERROR_STREAM(logger_, "Failed to set " << property << " to " << value << " in " \
<< __FUNCTION__ << " at line " << __LINE__); \
#define TRY_TO_SET_PROPERTY(func, property, value) \
try { \
device_->func(property, value); \
} catch (const ob::Error& e) { \
RCLCPP_ERROR_STREAM(logger_, "Failed to set " << property << " to " << value << " in " \
<< __FUNCTION__ << " at line " << __LINE__ \
<< ": " \
<< orbbec_camera::formatObErrorWithStatus(e)); \
} catch (const std::exception& e) { \
RCLCPP_ERROR_STREAM(logger_, "Failed to set " << property << " to " << value << " in " \
<< __FUNCTION__ << " at line " << __LINE__ \
<< ": " << e.what()); \
} catch (...) { \
RCLCPP_ERROR_STREAM(logger_, "Failed to set " << property << " to " << value << " in " \
<< __FUNCTION__ << " at line " << __LINE__); \
}
// Macros for checking conditions and comparing values
@@ -168,8 +169,7 @@ OBLogSeverity obLogSeverityFromString(const std::string_view& log_level);
std::string getObSdkLogDirectory();
std::string configureObSdkLoggerForTool(const std::string& tool_name,
const std::string& log_level);
std::string configureObSdkLoggerForTool(const std::string& tool_name, const std::string& log_level);
OBFormat OBFormatFromString(const std::string& format);