From c3982efb7673494b59b34fef55b5fb0088fe8a91 Mon Sep 17 00:00:00 2001 From: kalman Date: Fri, 29 Mar 2019 20:01:43 +0800 Subject: [PATCH] feat(*): add iic address setting sample --- include/mynteye/types.h | 2 +- samples/tutorials/CMakeLists.txt | 1 + samples/tutorials/control/iic_address.cc | 65 +++++++++++++++++++ .../java/com/slightech/mynteye/Option.java | 2 +- .../config/device/standard2.yaml | 4 +- .../src/wrapper_nodelet.cc | 2 +- 6 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 samples/tutorials/control/iic_address.cc diff --git a/include/mynteye/types.h b/include/mynteye/types.h index 8663710..f4448a4 100644 --- a/include/mynteye/types.h +++ b/include/mynteye/types.h @@ -263,7 +263,7 @@ enum class Option : std::uint8_t { /** * The setting of IIC address *

- * range: [0,65535], default: 0 + * range: [0,127], default: 0 *

*/ IIC_ADDRESS_SETTING, diff --git a/samples/tutorials/CMakeLists.txt b/samples/tutorials/CMakeLists.txt index 60b01d2..ac47fa5 100644 --- a/samples/tutorials/CMakeLists.txt +++ b/samples/tutorials/CMakeLists.txt @@ -122,6 +122,7 @@ make_executable2(ctrl_framerate SRCS control/framerate.cc WITH_OPENCV) make_executable2(ctrl_imu_low_pass_filter SRCS control/imu_low_pass_filter.cc WITH_OPENCV) make_executable2(ctrl_imu_range SRCS control/imu_range.cc WITH_OPENCV) make_executable2(ctrl_infrared SRCS control/infrared.cc WITH_OPENCV) +make_executable2(ctrl_iic_adress SRCS control/iic_address.cc WITH_OPENCV) make_executable2(ctrl_auto_exposure SRCS control/auto_exposure.cc util/cv_painter.cc WITH_OPENCV diff --git a/samples/tutorials/control/iic_address.cc b/samples/tutorials/control/iic_address.cc new file mode 100644 index 0000000..67d69bc --- /dev/null +++ b/samples/tutorials/control/iic_address.cc @@ -0,0 +1,65 @@ +// 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 + +#include "mynteye/logger.h" +#include "mynteye/api/api.h" + +MYNTEYE_USE_NAMESPACE + +int main(int argc, char *argv[]) { + auto &&api = API::Create(argc, argv); + if (!api) return 1; + + bool ok; + auto &&request = api->SelectStreamRequest(&ok); + if (!ok) return 1; + api->ConfigStreamRequest(request); + + Model model = api->GetModel(); + if (model == Model::STANDARD210A) { + api->SetOptionValue(Option::IIC_ADDRESS_SETTING, 0x31); + LOG(INFO) << "Set iic address to " << std::hex << "0x" + << api->GetOptionValue(Option::IIC_ADDRESS_SETTING); + } + + // MYNTEYE-S1030/S2100 don't support this option + if (model == Model::STANDARD2 || model == Model::STANDARD) { + LOG(INFO) << "Sorry,MYNTEYE-S1030 don't support iic address setting"; + return 0; + } + + api->Start(Source::VIDEO_STREAMING); + + cv::namedWindow("frame"); + + while (true) { + api->WaitForStreams(); + + auto &&left_data = api->GetStreamData(Stream::LEFT); + auto &&right_data = api->GetStreamData(Stream::RIGHT); + + cv::Mat img; + cv::hconcat(left_data.frame, right_data.frame, img); + cv::imshow("frame", img); + + char key = static_cast(cv::waitKey(1)); + if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q + break; + } + } + + api->Stop(Source::VIDEO_STREAMING); + return 0; +} diff --git a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Option.java b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Option.java index b3333d8..f4886cf 100644 --- a/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Option.java +++ b/wrappers/android/mynteye/libmynteye/src/main/java/com/slightech/mynteye/Option.java @@ -97,7 +97,7 @@ public enum Option { GYROSCOPE_LOW_PASS_FILTER, /** * The setting of IIC address - * range: [0,65535], default: 0 + * range: [0,127], default: 0 */ IIC_ADDRESS_SETTING, /** Zero drift calibration */ diff --git a/wrappers/ros/src/mynt_eye_ros_wrapper/config/device/standard2.yaml b/wrappers/ros/src/mynt_eye_ros_wrapper/config/device/standard2.yaml index 343039d..d7938c7 100644 --- a/wrappers/ros/src/mynt_eye_ros_wrapper/config/device/standard2.yaml +++ b/wrappers/ros/src/mynt_eye_ros_wrapper/config/device/standard2.yaml @@ -111,6 +111,6 @@ standard210a/accel_low_filter: -1 standard210a/gyro_low_filter: -1 # standard210a/gyro_low_filter: 64 -# standard210a/iic_address_setting range: [0,65535] +# standard210a/iic_address_setting range: [0,127] standard210a/iic_address_setting: -1 -# standard210a/iic_address_setting: 0 +# standard210a/iic_address_setting: 0x01 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 4f319ab..a0869fa 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 @@ -251,7 +251,7 @@ class ROSWrapperNodelet : public nodelet::Nodelet { {Option::ACCELEROMETER_LOW_PASS_FILTER, "standard210a/accel_low_filter"}, {Option::GYROSCOPE_LOW_PASS_FILTER, "standard210a/gyro_low_filter"}, - {Option::IIC_ADDRESS_SETTING, "standard2/iic_address_setting"}}; + {Option::IIC_ADDRESS_SETTING, "standard210a/iic_address_setting"}}; } // device options of standard2