diff --git a/CMakeLists.txt b/CMakeLists.txt index de270c0..5c0623a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.0) -project(mynteye VERSION 2.3.0 LANGUAGES C CXX) +project(mynteye VERSION 2.3.1 LANGUAGES C CXX) include(cmake/Common.cmake) @@ -220,6 +220,7 @@ if(WITH_API) src/mynteye/api/processor/rectify_processor_ocv.cc src/mynteye/api/config.cc src/mynteye/api/correspondence.cc + src/mynteye/api/version_checker.cc ) if(WITH_CAM_MODELS) list(APPEND MYNTEYE_SRCS diff --git a/include/mynteye/types.h b/include/mynteye/types.h index b95d228..627f5d1 100644 --- a/include/mynteye/types.h +++ b/include/mynteye/types.h @@ -122,6 +122,8 @@ enum class Info : std::uint8_t { IMU_TYPE, /** Nominal baseline */ NOMINAL_BASELINE, + /** SDK version*/ + SDK_VERSION, /** Last guard */ LAST }; diff --git a/src/mynteye/api/api.cc b/src/mynteye/api/api.cc index b04a373..5b440a7 100644 --- a/src/mynteye/api/api.cc +++ b/src/mynteye/api/api.cc @@ -26,6 +26,7 @@ #include "mynteye/api/dl.h" #include "mynteye/api/plugin.h" #include "mynteye/api/synthetic.h" +#include "mynteye/api/version_checker.h" #include "mynteye/device/device.h" #include "mynteye/device/utils.h" @@ -222,7 +223,10 @@ API::~API() { std::shared_ptr API::Create(int argc, char *argv[]) { auto &&device = device::select(); if (!device) return nullptr; - return Create(argc, argv, device); + auto api = Create(argc, argv, device); + if (api && checkFirmwareVersion(api)) + return api; + return nullptr; } std::shared_ptr API::Create( @@ -261,7 +265,7 @@ std::shared_ptr API::Create(const std::shared_ptr &device) { } } else { LOG(ERROR) <<"no device!"; - api = std::make_shared(device, CalibrationModel::UNKNOW); + return nullptr; } return api; } @@ -324,6 +328,22 @@ std::shared_ptr API::GetInfo() const { } std::string API::GetInfo(const Info &info) const { + if (info == Info::SDK_VERSION) { + std::string info_path = + utils::get_sdk_install_dir(); + info_path.append(MYNTEYE_OS_SEP "share" \ + MYNTEYE_OS_SEP "mynteye" MYNTEYE_OS_SEP "build.info"); + + cv::FileStorage fs(info_path, cv::FileStorage::READ); + if (!fs.isOpened()) { + LOG(WARNING) << "build.info not found: " << info_path; + return "null"; + } + std::string vs_main = fs["MYNTEYE_VERSION"]; + int vs_tweak = fs["MYNTEYE_VERSION_TWEAK"]; + return vs_main + std::string(".") + std::to_string(vs_tweak); + } + return device_->GetInfo(info); } diff --git a/src/mynteye/api/version_checker.cc b/src/mynteye/api/version_checker.cc new file mode 100644 index 0000000..363deaf --- /dev/null +++ b/src/mynteye/api/version_checker.cc @@ -0,0 +1,48 @@ +// Copyright 2018 Slightech Co., Ltd. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#include "mynteye/api/version_checker.h" +#include "mynteye/device/utils.h" +#include "mynteye/logger.h" +#include "mynteye/types.h" + +MYNTEYE_BEGIN_NAMESPACE + +typedef struct { + const std::string device_type; + const std::string sdk_version; + const std::string firmware_version; +}firmware_version_match_table_unit; + +/** firmware/sdk version matched table */ +static const firmware_version_match_table_unit FSVM_TABLE[] ={ + {"MYNT-EYE-S1030", "2.3.1.0", "2.0.0"}, + {"MYNT-EYE-S1030", "2.3.1.0", "2.0.0"}, + {} +}; + +bool checkFirmwareVersion(const std::shared_ptr api) { + LOG(INFO) << "SDK version: " << api->GetInfo(Info::SDK_VERSION); + LOG(INFO) << "Device name: " << api->GetInfo(Info::DEVICE_NAME); + LOG(INFO) << "Serial number: " << api->GetInfo(Info::SERIAL_NUMBER); + LOG(INFO) << "Firmware version: " << api->GetInfo(Info::FIRMWARE_VERSION); + LOG(INFO) << "Hardware version: " << api->GetInfo(Info::HARDWARE_VERSION); + LOG(INFO) << "Spec version: " << api->GetInfo(Info::SPEC_VERSION); + LOG(INFO) << "Lens type: " << api->GetInfo(Info::LENS_TYPE); + LOG(INFO) << "IMU type: " << api->GetInfo(Info::IMU_TYPE); + LOG(INFO) << "Nominal baseline: " << api->GetInfo(Info::NOMINAL_BASELINE); + return true; +} + +MYNTEYE_END_NAMESPACE + diff --git a/src/mynteye/api/version_checker.h b/src/mynteye/api/version_checker.h new file mode 100644 index 0000000..6921975 --- /dev/null +++ b/src/mynteye/api/version_checker.h @@ -0,0 +1,25 @@ +// Copyright 2018 Slightech Co., Ltd. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef MYNTEYE_API_VERSION_CHECKER_H_ +#define MYNTEYE_API_VERSION_CHECKER_H_ +#pragma once + +#include +#include "mynteye/api/api.h" + +MYNTEYE_BEGIN_NAMESPACE +bool checkFirmwareVersion(const std::shared_ptr api); +MYNTEYE_END_NAMESPACE + +#endif // MYNTEYE_API_VERSION_CHECKER_H_ 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 434e194..c1da91b 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 @@ -644,7 +644,7 @@ class ROSWrapperNodelet : public nodelet::Nodelet { is_published_[stream] = false; } api_->Start(Source::VIDEO_STREAMING); - } else if (sum_c > sum) { + } else { if ((camera_publishers_[Stream::LEFT].getNumSubscribers() > 0 || mono_publishers_[Stream::LEFT].getNumSubscribers() > 0) && !is_published_[Stream::LEFT]) {