refactor: simplify image qos logging

This commit is contained in:
slz
2026-08-20 14:54:02 +08:00
parent e80760c934
commit 760634fdab
4 changed files with 29 additions and 9 deletions
@@ -188,6 +188,8 @@ std::string ObDeviceTypeToString(const OBDeviceType& type);
rmw_qos_profile_t getRMWQosProfileFromString(const std::string& str_qos);
std::string getRMWQosProfileDescription(const rmw_qos_profile_t& qos_profile);
bool isOpenNIDevice(int pid);
OB_DEPTH_PRECISION_LEVEL depthPrecisionLevelFromString(
+2 -8
View File
@@ -5446,14 +5446,8 @@ void OBCameraNode::setupImagePublisher(const stream_index_pair &stream_index) {
image_publishers_[stream_index] =
std::make_shared<image_transport_publisher>(*node_, topic, image_qos_profile);
}
std::string depth;
if (image_qos_profile.history == RMW_QOS_POLICY_HISTORY_KEEP_LAST) {
depth = ", depth=" + std::to_string(image_qos_profile.depth);
}
RCLCPP_INFO_STREAM(
logger_, topic << " QoS: reliability=" << magic_enum::enum_name(image_qos_profile.reliability)
<< ", durability=" << magic_enum::enum_name(image_qos_profile.durability)
<< ", history=" << magic_enum::enum_name(image_qos_profile.history) << depth);
RCLCPP_INFO_STREAM(logger_,
topic << " QoS: " << getRMWQosProfileDescription(image_qos_profile));
if (is_mjpg_color_stream) {
compressed_image_publishers_[stream_index] =
+1 -1
View File
@@ -478,7 +478,7 @@ void OBCameraNode::getColorQueueStatsCallback(
};
};
nlohmann::json queues;
nlohmann::json queues = nlohmann::json::object();
uint64_t overflow_count = 0;
const bool reset = request->data;
if (enable_stream_[COLOR] || reset) {
+24
View File
@@ -23,6 +23,7 @@
#include <regex>
#include <sstream>
#include <vector>
#include <magic_enum/magic_enum.hpp>
#include "orbbec_camera/utils.h"
#include <sensor_msgs/point_cloud2_iterator.hpp>
#include "orbbec_camera/constants.h"
@@ -566,6 +567,29 @@ rmw_qos_profile_t getRMWQosProfileFromString(const std::string &str_qos) {
}
}
std::string getRMWQosProfileDescription(const rmw_qos_profile_t &qos_profile) {
const auto short_qos_name = [](auto policy) {
auto name = magic_enum::enum_name(policy);
constexpr size_t prefix_size = sizeof("RMW_QOS_POLICY_") - 1;
if (name.size() <= prefix_size) {
return name;
}
name.remove_prefix(prefix_size);
const auto separator = name.find('_');
if (separator < name.size()) {
name.remove_prefix(separator + 1);
}
return name;
};
std::string history(short_qos_name(qos_profile.history));
if (qos_profile.history == RMW_QOS_POLICY_HISTORY_KEEP_LAST) {
history += "(" + std::to_string(qos_profile.depth) + ")";
}
return std::string(short_qos_name(qos_profile.reliability)) + "/" +
std::string(short_qos_name(qos_profile.durability)) + "/" + history;
}
bool isOpenNIDevice(int pid) {
static const std::vector<int> OPENNI_DEVICE_PIDS = {
0x0300, 0x0301, 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0407, 0x0601, 0x060b, 0x060e,