diff --git a/CMakeLists.txt b/CMakeLists.txt index 754fc12..fc4db7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.0) -project(mynteye VERSION 2.3.2 LANGUAGES C CXX) +project(mynteye VERSION 2.3.3 LANGUAGES C CXX) include(cmake/Common.cmake) diff --git a/doc/en/api.doxyfile b/doc/en/api.doxyfile index 9400c74..72e3fd4 100644 --- a/doc/en/api.doxyfile +++ b/doc/en/api.doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "MYNT EYE S SDK" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 2.3.2 +PROJECT_NUMBER = 2.3.3 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/doc/zh-Hans/api.doxyfile b/doc/zh-Hans/api.doxyfile index 31d9a19..2bcc573 100644 --- a/doc/zh-Hans/api.doxyfile +++ b/doc/zh-Hans/api.doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "MYNT EYE S SDK" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 2.3.2 +PROJECT_NUMBER = 2.3.3 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/samples/tutorials/data/get_imu_correspondence.cc b/samples/tutorials/data/get_imu_correspondence.cc index 7557cfb..26a5870 100644 --- a/samples/tutorials/data/get_imu_correspondence.cc +++ b/samples/tutorials/data/get_imu_correspondence.cc @@ -48,6 +48,7 @@ int main(int argc, char *argv[]) { std::uint8_t prev_imu_flag = 0; std::uint64_t imu_count = 0; std::uint64_t imu_disorder_count = 0; + bool exit = false; #endif while (true) { api->WaitForStreams(); @@ -98,6 +99,9 @@ int main(int argc, char *argv[]) { ss << (ok ? " ✓" : " x"); if (!ok) ++imu_disorder_count; prev_imu_flag = imu_flag; + if (!exit) { + if (!ok) exit = true; + } } #endif LOG(INFO) << ss.str(); @@ -107,6 +111,7 @@ int main(int argc, char *argv[]) { LOG(INFO); #ifdef CHECK_ACCEL_THEN_GYRO imu_count += motion_datas.size(); + if (exit) break; #endif /* @@ -130,6 +135,8 @@ int main(int argc, char *argv[]) { if (imu_disorder_count > 0) { LOG(INFO) << "accel_then_gyro, disorder_count: " << imu_disorder_count << "/" << imu_count; + } else { + LOG(INFO) << "accel_then_gyro, ok"; } #endif return 0; diff --git a/src/mynteye/api/correspondence.cc b/src/mynteye/api/correspondence.cc index 9b0ae85..b858535 100644 --- a/src/mynteye/api/correspondence.cc +++ b/src/mynteye/api/correspondence.cc @@ -152,6 +152,22 @@ std::vector Correspondence::GetStreamDatas( std::vector Correspondence::GetMotionDatas() { auto &&datas = GetReadyMotionDatas(); + /* + for (auto data : datas) { + auto imu_flag = data.imu->flag; + auto imu_stamp = data.imu->timestamp; + std::stringstream ss; + if (imu_flag == 0) { // accel + gyro + ss << "Imu"; + } else if (imu_flag == 1) { // accel + ss << "Accel"; + } else if (imu_flag == 2) { // gyro + ss << "Gyro"; + } + ss << " timestamp: " << imu_stamp; + LOG(INFO) << ss.str(); + } + */ if (keep_accel_then_gyro_ && device_->GetModel() != Model::STANDARD) { KeepAccelThenGyro(datas); // only s2 need do this } @@ -287,16 +303,30 @@ std::vector Correspondence::GetReadyMotionDatas() { } void Correspondence::KeepAccelThenGyro(std::vector &datas) { - auto n = datas.size(); - if (n == 0) return; + if (datas.size() == 0) return; static std::shared_ptr last_imu = nullptr; + // process last imu + if (datas[0].imu->flag == MYNTEYE_IMU_SEQ_SECOND) { + if (last_imu && last_imu->flag == MYNTEYE_IMU_SEQ_FIRST) { + datas.insert(datas.begin(), {last_imu}); + } + } + last_imu = nullptr; + + // if only one + if (datas.size() == 1) { + last_imu = datas[0].imu; + datas.clear(); + return; + } + std::uint8_t prev_flag = 0; for (auto it = datas.begin(); it != datas.end(); ) { auto flag = it->imu->flag; if (flag == 0) { - ++it; // unexpected + ++it; // unexpected, keep it continue; } @@ -312,20 +342,26 @@ void Correspondence::KeepAccelThenGyro(std::vector &datas) { ok = (prev_flag == MYNTEYE_IMU_SEQ_FIRST); } } - if (ok && is_last) { - ok = (flag == MYNTEYE_IMU_SEQ_SECOND); - } if (ok) { prev_flag = flag; - if (is_last) { - last_imu = nullptr; - } ++it; } else { + if (is_last) { + // if tail not ok, retain last imu + last_imu = it->imu; + } it = datas.erase(it); } } + + // if tail is not second + if (datas.size() > 0) { + auto it = datas.end() - 1; + if (it->imu->flag != MYNTEYE_IMU_SEQ_SECOND) { + datas.erase(it); + } + } } MYNTEYE_END_NAMESPACE