check rgb buffer avoid crash

This commit is contained in:
Joe Dong
2023-10-14 14:03:50 +08:00
parent 6d397e3e3a
commit 1829753f51
2 changed files with 9 additions and 0 deletions
+8
View File
@@ -85,6 +85,7 @@ void OBCameraNode::setAndGetNodeParameter(
OBCameraNode::~OBCameraNode() { clean(); }
void OBCameraNode::clean() {
std::lock_guard<decltype(device_lock_)> lock(device_lock_);
RCLCPP_WARN_STREAM(logger_, "Do destroy ~OBCameraNode");
is_running_.store(false);
if (tf_thread_ && tf_thread_->joinable()) {
@@ -750,6 +751,10 @@ void OBCameraNode::publishColoredPointCloud(const std::shared_ptr<ob::FrameSet>
}
void OBCameraNode::onNewFrameSetCallback(const std::shared_ptr<ob::FrameSet> &frame_set) {
if (!is_running_.load()) {
return;
}
std::lock_guard<decltype(device_lock_)> lock(device_lock_);
if (frame_set == nullptr) {
return;
}
@@ -805,6 +810,9 @@ bool OBCameraNode::decodeColorFrameToBuffer(const std::shared_ptr<ob::Frame> &fr
if (frame == nullptr) {
return false;
}
if (!rgb_buffer_) {
return false;
}
bool has_subscriber = image_publishers_[COLOR].getNumSubscribers() > 0;
if (enable_colored_point_cloud_ && depth_registration_cloud_pub_->get_subscription_count() > 0) {
has_subscriber = true;