// 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/device/channel/channels.h" #include #include #include #include #include #include #include #include #include "mynteye/logger.h" #include "mynteye/util/times.h" #define IMU_TRACK_PERIOD 25 // ms MYNTEYE_BEGIN_NAMESPACE namespace { const uvc::xu mynteye_xu = {3, 2, { 0x947a6d9f, 0x8a2f, 0x418d, {0x85, 0x9e, 0x6c, 0x9a, 0xa0, 0x38, 0x10, 0x14} } }; int XuCamCtrlId(Option option) { switch (option) { case Option::EXPOSURE_MODE: return 0; break; case Option::MAX_GAIN: return 1; break; case Option::MAX_EXPOSURE_TIME: return 2; break; case Option::DESIRED_BRIGHTNESS: return 3; break; case Option::IMU_FREQUENCY: return 4; break; case Option::IR_CONTROL: return 5; break; case Option::HDR_MODE: return 6; break; case Option::FRAME_RATE: return 7; break; case Option::MIN_EXPOSURE_TIME: return 8; break; case Option::ACCELEROMETER_RANGE: return 9; break; case Option::GYROSCOPE_RANGE: return 10; break; case Option::ACCELEROMETER_LOW_PASS_FILTER: return 11; break; case Option::GYROSCOPE_LOW_PASS_FILTER: return 12; break; default: LOG(FATAL) << "No cam ctrl id for " << option; } } int XuHalfDuplexId(Option option) { switch (option) { case Option::ZERO_DRIFT_CALIBRATION: return 0; break; case Option::ERASE_CHIP: return 1; break; default: LOG(FATAL) << "No half duplex id for " << option; } } } // namespace Channels::Channels(const std::shared_ptr &device, const std::shared_ptr &adapter) : device_(device), adapter_(adapter), is_imu_tracking_(false), imu_track_stop_(false), imu_sn_(0), imu_callback_(nullptr) { VLOG(2) << __func__; UpdateControlInfos(); } Channels::~Channels() { VLOG(2) << __func__; StopImuTracking(); } std::int32_t Channels::GetAccelRangeDefault() { return adapter_->GetAccelRangeDefault(); } std::int32_t Channels::GetGyroRangeDefault() { return adapter_->GetGyroRangeDefault(); } void Channels::LogControlInfos() const { for (auto &&it = control_infos_.begin(); it != control_infos_.end(); it++) { LOG(INFO) << it->first << ": min=" << it->second.min << ", max=" << it->second.max << ", def=" << it->second.def << ", cur=" << GetControlValue(it->first); } } void Channels::UpdateControlInfos() { auto &&supports = adapter_->GetOptionSupports(); for (auto &&option : std::vector