mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-10-04 12:07:46 +08:00
check rgb buffer avoid crash
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user