refactor: improve logging messages for clarity and consistency in camera node

This commit is contained in:
slz
2026-04-10 17:20:34 +08:00
parent 0035c0b18c
commit 8ec0632b4d
3 changed files with 19 additions and 22 deletions
+8 -7
View File
@@ -938,7 +938,7 @@ void OBCameraNode::setupDevices() {
device_->setIntProperty(OB_PROP_DEPTH_MAX_DIFF_INT, noise_removal_filter_min_diff_);
auto new_noise_removal_filter_min_diff =
device_->getIntProperty(OB_PROP_DEPTH_MAX_DIFF_INT);
RCLCPP_INFO_STREAM(logger_, "after set noise removal filter min diff: "
RCLCPP_INFO_STREAM(logger_, "Updated noise removal filter min diff: "
<< new_noise_removal_filter_min_diff);
}
}
@@ -963,7 +963,7 @@ void OBCameraNode::setupDevices() {
device_->setIntProperty(OB_PROP_DEPTH_MAX_SPECKLE_SIZE_INT, noise_removal_filter_max_size_);
auto new_noise_removal_filter_max_size =
device_->getIntProperty(OB_PROP_DEPTH_MAX_SPECKLE_SIZE_INT);
RCLCPP_INFO_STREAM(logger_, "after set noise removal filter max size: "
RCLCPP_INFO_STREAM(logger_, "Updated noise removal filter max size: "
<< new_noise_removal_filter_max_size);
}
}
@@ -3194,7 +3194,7 @@ void OBCameraNode::setDisparitySearchOffset() {
if (device_->isPropertySupported(OB_PROP_DISP_SEARCH_OFFSET_INT, OB_PERMISSION_WRITE)) {
if (disparity_search_offset_ >= 0 && disparity_search_offset_ <= 127) {
device_->setIntProperty(OB_PROP_DISP_SEARCH_OFFSET_INT, disparity_search_offset_);
RCLCPP_INFO_STREAM(logger_, "disparity_search_offset: " << disparity_search_offset_);
RCLCPP_INFO_STREAM(logger_, "Set disparity search offset to " << disparity_search_offset_);
}
if (offset_index0_ >= 0 && offset_index0_ <= 127 && offset_index1_ >= 0 &&
offset_index1_ <= 127) {
@@ -4586,8 +4586,9 @@ void OBCameraNode::setFilterCallback(const std::shared_ptr<SetFilter ::Request>
return;
}
RCLCPP_INFO_STREAM(logger_, "filter_name: " << request->filter_name << " filter_enable: "
<< (request->filter_enable ? "true" : "false"));
RCLCPP_INFO_STREAM(logger_, "Filter update request: name="
<< request->filter_name
<< ", enabled=" << (request->filter_enable ? "true" : "false"));
auto it = std::remove_if(depth_filter_list_.begin(), depth_filter_list_.end(),
[&request](const std::shared_ptr<ob::Filter> &filter) {
return filter->getName() == request->filter_name;
@@ -4683,7 +4684,7 @@ void OBCameraNode::setFilterCallback(const std::shared_ptr<SetFilter ::Request>
device_->setIntProperty(OB_PROP_DEPTH_MAX_DIFF_INT, request->filter_param[0]);
auto new_noise_removal_filter_min_diff =
device_->getIntProperty(OB_PROP_DEPTH_MAX_DIFF_INT);
RCLCPP_INFO_STREAM(logger_, "after set noise removal filter min diff: "
RCLCPP_INFO_STREAM(logger_, "Updated noise removal filter min diff: "
<< new_noise_removal_filter_min_diff);
}
if (device_->isPropertySupported(OB_PROP_DEPTH_MAX_SPECKLE_SIZE_INT, OB_PERMISSION_WRITE)) {
@@ -4694,7 +4695,7 @@ void OBCameraNode::setFilterCallback(const std::shared_ptr<SetFilter ::Request>
device_->setIntProperty(OB_PROP_DEPTH_MAX_SPECKLE_SIZE_INT, request->filter_param[1]);
auto new_noise_removal_filter_max_size =
device_->getIntProperty(OB_PROP_DEPTH_MAX_SPECKLE_SIZE_INT);
RCLCPP_INFO_STREAM(logger_, "after set noise removal filter max size: "
RCLCPP_INFO_STREAM(logger_, "Updated noise removal filter max size: "
<< new_noise_removal_filter_max_size);
}
} else {
+3 -7
View File
@@ -880,10 +880,8 @@ std::shared_ptr<ob::Device> OBCameraNodeDriver::selectDeviceByUSBPort(
const std::shared_ptr<ob::DeviceList> &list, const std::string &usb_port) {
try {
RCLCPP_INFO_STREAM_THROTTLE(logger_, *get_clock(), 5000,
"Before lock: Select device usb port: " << usb_port);
"Selecting device by USB port: " << usb_port);
std::lock_guard<decltype(device_lock_)> lock(device_lock_);
RCLCPP_INFO_STREAM_THROTTLE(logger_, *get_clock(), 5000,
"After lock: Select device usb port: " << usb_port);
auto device = list->getDeviceByUid(usb_port.c_str(), device_access_mode_);
if (device) {
RCLCPP_INFO_STREAM_THROTTLE(logger_, *get_clock(), 5000,
@@ -913,10 +911,8 @@ std::shared_ptr<ob::Device> OBCameraNodeDriver::selectDeviceByUSBPort(
std::shared_ptr<ob::Device> OBCameraNodeDriver::selectDeviceByNetIP(
const std::shared_ptr<ob::DeviceList> &list, const std::string &net_ip) {
RCLCPP_DEBUG_STREAM_THROTTLE(logger_, *get_clock(), 5000,
"Before lock: Select device net ip: " << net_ip);
"Selecting device by network IP: " << net_ip);
std::lock_guard<decltype(device_lock_)> lock(device_lock_);
RCLCPP_DEBUG_STREAM_THROTTLE(logger_, *get_clock(), 5000,
"After lock: Select device net ip: " << net_ip);
std::shared_ptr<ob::Device> device = nullptr;
for (size_t i = 0; i < list->getCount(); i++) {
try {
@@ -1152,7 +1148,7 @@ void OBCameraNodeDriver::initializeDevice(const std::shared_ptr<ob::Device> &dev
ob_lidar_node_->startStreams();
ob_lidar_node_->startIMU();
} else {
RCLCPP_INFO_STREAM(logger_, "ob_camera_node_ is nullptr");
RCLCPP_WARN_STREAM(logger_, "Camera or LiDAR node is null after device initialization");
}
} // namespace orbbec_camera
+8 -8
View File
@@ -643,7 +643,7 @@ void OBCameraNode::setGainCallback(const std::shared_ptr<SetInt32 ::Request>& re
auto range = device_->getIntPropertyRange(prop_id);
if (request->data < range.min || request->data > range.max) {
response->success = false;
RCLCPP_INFO_STREAM(logger_, "Set gain value out of range");
RCLCPP_WARN_STREAM(logger_, "Gain value is out of range");
response->message = "value out of range";
return;
}
@@ -715,9 +715,9 @@ void OBCameraNode::setAeRoiCallback(const std::shared_ptr<SetArrays ::Request>&
device_->getStructuredData(OB_STRUCT_DEPTH_AE_ROI, reinterpret_cast<uint8_t*>(&config),
&data_size);
RCLCPP_INFO_STREAM(
logger_, "set depth AE ROI : "
logger_, "Set depth AE ROI to "
<< "[Left: " << config.x0_left << ", Right: " << config.x1_right
<< ", Top: " << config.y0_top << ", Bottom: " << config.y1_bottom << " ]");
<< ", Top: " << config.y0_top << ", Bottom: " << config.y1_bottom << "]");
break;
case OB_STREAM_COLOR:
case OB_STREAM_COLOR_LEFT:
@@ -751,7 +751,7 @@ void OBCameraNode::setAeRoiCallback(const std::shared_ptr<SetArrays ::Request>&
device_->getStructuredData(OB_STRUCT_COLOR_AE_ROI, reinterpret_cast<uint8_t*>(&config),
&data_size);
RCLCPP_INFO_STREAM(
logger_, "Set color AE ROI : "
logger_, "Set color AE ROI to "
<< "[Left: " << config.x0_left << ", Right: " << config.x1_right
<< ", Top: " << config.y0_top << ", Bottom: " << config.y1_bottom << "]");
break;
@@ -798,13 +798,13 @@ void OBCameraNode::setWhiteBalanceCallback(const std::shared_ptr<SetInt32 ::Requ
auto range = device_->getIntPropertyRange(OB_PROP_COLOR_WHITE_BALANCE_INT);
if (request->data < range.min || request->data > range.max) {
response->success = false;
RCLCPP_INFO_STREAM(logger_, "set white balance value out of range");
RCLCPP_WARN_STREAM(logger_, "White balance value is out of range");
response->message = "value out of range";
return;
}
bool auto_white_balance = device_->getBoolProperty(OB_PROP_COLOR_AUTO_WHITE_BALANCE_BOOL);
if (auto_white_balance) {
RCLCPP_WARN(logger_, "auto white balance is enabled, set white balance will be ignored");
RCLCPP_WARN(logger_, "Auto white balance is enabled, set white balance will be ignored");
response->success = false;
response->message = "auto white balance is enabled";
return;
@@ -885,7 +885,7 @@ void OBCameraNode::setAutoExposureCallback(
auto range = device_->getIntPropertyRange(prop_id);
if (request->data < range.min || request->data > range.max) {
response->success = false;
RCLCPP_INFO_STREAM(logger_, "set auto exposure value out of range");
RCLCPP_WARN_STREAM(logger_, "Auto exposure value is out of range");
response->message = "value out of range";
return;
}
@@ -1272,7 +1272,7 @@ void OBCameraNode::setPtpConfigCallback(
if (!device_->isPropertySupported(OB_DEVICE_PTP_CLOCK_SYNC_ENABLE_BOOL,
OB_PERMISSION_READ_WRITE)) {
response->success = false;
RCLCPP_ERROR(logger_, "OB_DEVICE_PTP_CLOCK_SYNC_ENABLE_BOOL not supported or not writable");
RCLCPP_ERROR(logger_, "PTP clock sync property is not supported or not writable");
return;
}
device_->setBoolProperty(OB_DEVICE_PTP_CLOCK_SYNC_ENABLE_BOOL, request->data);