File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -421,5 +421,6 @@ class OBCameraNode {
421421 std::shared_ptr<JPEGDecoder> jpeg_decoder_ = nullptr ;
422422 uint8_t * rgb_buffer_ = nullptr ;
423423 bool is_color_frame_decoded_ = false ;
424+ std::mutex device_lock_;
424425};
425426} // namespace orbbec_camera
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ void OBCameraNode::setAndGetNodeParameter(
8585OBCameraNode::~OBCameraNode () { clean (); }
8686
8787void OBCameraNode::clean () {
88+ std::lock_guard<decltype (device_lock_)> lock (device_lock_);
8889 RCLCPP_WARN_STREAM (logger_, " Do destroy ~OBCameraNode" );
8990 is_running_.store (false );
9091 if (tf_thread_ && tf_thread_->joinable ()) {
@@ -750,6 +751,10 @@ void OBCameraNode::publishColoredPointCloud(const std::shared_ptr<ob::FrameSet>
750751}
751752
752753void OBCameraNode::onNewFrameSetCallback (const std::shared_ptr<ob::FrameSet> &frame_set) {
754+ if (!is_running_.load ()) {
755+ return ;
756+ }
757+ std::lock_guard<decltype (device_lock_)> lock (device_lock_);
753758 if (frame_set == nullptr ) {
754759 return ;
755760 }
@@ -805,6 +810,9 @@ bool OBCameraNode::decodeColorFrameToBuffer(const std::shared_ptr<ob::Frame> &fr
805810 if (frame == nullptr ) {
806811 return false ;
807812 }
813+ if (!rgb_buffer_) {
814+ return false ;
815+ }
808816 bool has_subscriber = image_publishers_[COLOR].getNumSubscribers () > 0 ;
809817 if (enable_colored_point_cloud_ && depth_registration_cloud_pub_->get_subscription_count () > 0 ) {
810818 has_subscriber = true ;
You can’t perform that action at this time.
0 commit comments