fix(timestamp):add onProcess sync lock to make sure imgData be unique; issue[EYES-26]

This commit is contained in:
TinyOh 2019-03-05 13:45:42 +08:00
parent 764ccba041
commit 3c687d43ca
3 changed files with 13 additions and 0 deletions

View File

@ -209,6 +209,7 @@ void Processor::Run() {
}
bool ok = false;
try {
std::unique_lock<std::mutex> lk(mtx_data_process_unique_);
if (callback_) {
if (callback_(input_.get(), output_.get(), parent_)) {
ok = true;

View File

@ -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_;

View File

@ -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 << "&" <<stamp << std::endl;
}
last = stamp;
last_img = data.img->timestamp;
}
static std::size_t count = 0;
++count;
publishData(stream, data, count, stamp);