feat(*): add iic address setting sample
This commit is contained in:
		
							parent
							
								
									b2f6120fa5
								
							
						
					
					
						commit
						c3982efb76
					
				@ -263,7 +263,7 @@ enum class Option : std::uint8_t {
 | 
			
		||||
  /**
 | 
			
		||||
   * The setting of IIC address
 | 
			
		||||
   * <p>
 | 
			
		||||
   *   range: [0,65535], default: 0
 | 
			
		||||
   *   range: [0,127], default: 0
 | 
			
		||||
   * </p>
 | 
			
		||||
   */
 | 
			
		||||
  IIC_ADDRESS_SETTING,
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										65
									
								
								samples/tutorials/control/iic_address.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								samples/tutorials/control/iic_address.cc
									
									
									
									
									
										Normal file
									
								
							@ -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 <opencv2/highgui/highgui.hpp>
 | 
			
		||||
 | 
			
		||||
#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<char>(cv::waitKey(1));
 | 
			
		||||
    if (key == 27 || key == 'q' || key == 'Q') {  // ESC/Q
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  api->Stop(Source::VIDEO_STREAMING);
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
@ -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 */
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user