fix intra-process QoS crash in device status publisher

This commit is contained in:
ob-yalian
2025-11-18 11:43:40 +08:00
parent 2906aff06e
commit d4fddf37c9
4 changed files with 16 additions and 10 deletions
+7 -2
View File
@@ -27,7 +27,7 @@
namespace orbbec_camera {
D2CViewer::D2CViewer(rclcpp::Node* const node, rmw_qos_profile_t rgb_qos,
rmw_qos_profile_t depth_qos)
rmw_qos_profile_t depth_qos, bool use_intra_process)
: node_(node), logger_(rclcpp::get_logger("d2c_viewer")), is_active_(true) {
rgb_sub_ = std::make_shared<message_filters::Subscriber<sensor_msgs::msg::Image>>(
node_, "color/image_raw", rgb_qos);
@@ -40,8 +40,13 @@ D2CViewer::D2CViewer(rclcpp::Node* const node, rmw_qos_profile_t rgb_qos,
using std::placeholders::_1;
using std::placeholders::_2;
sync_->registerCallback(std::bind(&D2CViewer::messageCallback, this, _1, _2));
auto qos = rclcpp::QoS(1).transient_local();
if (use_intra_process) {
qos = rclcpp::QoS(1);
}
d2c_viewer_pub_ =
node_->create_publisher<sensor_msgs::msg::Image>("depth_to_color/image_raw", rclcpp::QoS(1));
node_->create_publisher<sensor_msgs::msg::Image>("depth_to_color/image_raw", qos);
}
D2CViewer::~D2CViewer() {
+1 -1
View File
@@ -67,7 +67,7 @@ OBCameraNode::OBCameraNode(rclcpp::Node *node, std::shared_ptr<ob::Device> devic
if (enable_d2c_viewer_) {
auto rgb_qos = getRMWQosProfileFromString(image_qos_[COLOR]);
auto depth_qos = getRMWQosProfileFromString(image_qos_[DEPTH]);
d2c_viewer_ = std::make_unique<D2CViewer>(node_, rgb_qos, depth_qos);
d2c_viewer_ = std::make_unique<D2CViewer>(node_, rgb_qos, depth_qos, use_intra_process_);
}
if (enable_stream_[COLOR]) {
rgb_buffer_ = new uint8_t[width_[COLOR] * height_[COLOR] * 4];
+7 -6
View File
@@ -258,16 +258,17 @@ void OBCameraNodeDriver::init() {
check_connect_timer_ =
this->create_wall_timer(std::chrono::milliseconds(1000), [this]() { checkConnectTimer(); });
CHECK_NOTNULL(check_connect_timer_);
query_thread_ = std::make_shared<std::thread>([this]() { queryDevice(); });
reset_device_thread_ = std::make_shared<std::thread>([this]() { resetDevice(); });
device_status_timer_ =
this->create_wall_timer(std::chrono::milliseconds(1000 / device_status_interval_hz),
[this]() { deviceStatusTimer(); });
// Initialize device status publisher
auto qos = rclcpp::QoS(1).transient_local();
if (node_options_.use_intra_process_comms()) {
qos = rclcpp::QoS(1);
}
device_status_pub_ = this->create_publisher<orbbec_camera_msgs::msg::DeviceStatus>(
"device_status", rclcpp::QoS(1).transient_local());
"device_status", qos);
query_thread_ = std::make_shared<std::thread>([this]() { queryDevice(); });
reset_device_thread_ = std::make_shared<std::thread>([this]() { resetDevice(); });
}
void OBCameraNodeDriver::onDeviceConnected(const std::shared_ptr<ob::DeviceList> &device_list) {