From 3c687d43ca02f2ff6cae1a07befc757b8482fb08 Mon Sep 17 00:00:00 2001 From: TinyOh Date: Tue, 5 Mar 2019 13:45:42 +0800 Subject: [PATCH] fix(timestamp):add onProcess sync lock to make sure imgData be unique; issue[EYES-26] --- src/mynteye/api/processor.cc | 1 + src/mynteye/api/processor.h | 1 + .../src/mynt_eye_ros_wrapper/src/wrapper_nodelet.cc | 11 +++++++++++ 3 files changed, 13 insertions(+) diff --git a/src/mynteye/api/processor.cc b/src/mynteye/api/processor.cc index 175e0ba..ba06fa5 100644 --- a/src/mynteye/api/processor.cc +++ b/src/mynteye/api/processor.cc @@ -209,6 +209,7 @@ void Processor::Run() { } bool ok = false; try { + std::unique_lock lk(mtx_data_process_unique_); if (callback_) { if (callback_(input_.get(), output_.get(), parent_)) { ok = true; diff --git a/src/mynteye/api/processor.h b/src/mynteye/api/processor.h index 4cdaeac..9c3b4d2 100644 --- a/src/mynteye/api/processor.h +++ b/src/mynteye/api/processor.h @@ -103,6 +103,7 @@ class Processor : bool input_ready_; std::mutex mtx_input_ready_; + std::mutex mtx_data_process_unique_; std::condition_variable cond_input_ready_; bool idle_; diff --git a/wrappers/ros/src/mynt_eye_ros_wrapper/src/wrapper_nodelet.cc b/wrappers/ros/src/mynt_eye_ros_wrapper/src/wrapper_nodelet.cc index abaecf0..a46748c 100644 --- a/wrappers/ros/src/mynt_eye_ros_wrapper/src/wrapper_nodelet.cc +++ b/wrappers/ros/src/mynt_eye_ros_wrapper/src/wrapper_nodelet.cc @@ -589,6 +589,17 @@ class ROSWrapperNodelet : public nodelet::Nodelet { stream, [this, stream](const api::StreamData &data) { ros::Time stamp = checkUpTimeStamp( data.img->timestamp, stream); + if (stream == Stream::DEPTH) { + static long long last_img = 0; + static ros::Time last = ros::Time(0); + static int cont = 0; + cont++; + if (stamp <= last) { + std::cout << "di " << cont <<"ci: " << data.img->timestamp <<"&" << last_img << "|" << last << "&" <timestamp; + } static std::size_t count = 0; ++count; publishData(stream, data, count, stamp);