diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c6e956..d0dbc40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,8 +172,10 @@ set(MYNTEYE_SRCS src/mynteye/device/context.cc src/mynteye/device/device.cc src/mynteye/device/motions.cc + src/mynteye/device/standard/channels_adapter_s.cc src/mynteye/device/standard/device_s.cc src/mynteye/device/standard/streams_adapter_s.cc + src/mynteye/device/standard2/channels_adapter_s2.cc src/mynteye/device/standard2/device_s2.cc src/mynteye/device/standard2/streams_adapter_s2.cc src/mynteye/device/streams.cc diff --git a/include/mynteye/device/device.h b/include/mynteye/device/device.h index e03ff5b..617aaf1 100644 --- a/include/mynteye/device/device.h +++ b/include/mynteye/device/device.h @@ -43,6 +43,7 @@ struct DeviceInfo; class API; class Channels; +class ChannelsAdapter; class Motions; class Streams; class StreamsAdapter; @@ -70,7 +71,13 @@ class MYNTEYE_API Device { using img_params_t = device::img_params_t; using imu_params_t = device::imu_params_t; - Device(const Model &model, std::shared_ptr device); + protected: + Device(const Model &model, + const std::shared_ptr &device, + const std::shared_ptr &streams_adapter, + const std::shared_ptr &channels_adapter); + + public: virtual ~Device(); /** @@ -301,7 +308,6 @@ class MYNTEYE_API Device { virtual void OnStereoStreamUpdate(); virtual Capabilities GetKeyStreamCapability() const = 0; - virtual std::shared_ptr CreateStreamsAdapter() const = 0; std::map GetImgParams() const { return all_img_params_; diff --git a/include/mynteye/types.h b/include/mynteye/types.h index facadeb..3c8b2f9 100644 --- a/include/mynteye/types.h +++ b/include/mynteye/types.h @@ -212,7 +212,7 @@ enum class Option : std::uint8_t { * The range of accelerometer * * value of standard 1: {4,8,16,32}, default: 8 - * value of standard 2: {6,12,24,48}, default: 6 + * value of standard 2: {6,12,24,48}, default: 12 */ ACCELEROMETER_RANGE, /** @@ -357,7 +357,7 @@ struct MYNTEYE_API StreamRequest { std::uint16_t height; /** Stream pixel format */ Format format; - /** Stream frames per second (unused) */ + /** Stream frames per second */ std::uint16_t fps; StreamRequest() {} @@ -522,7 +522,13 @@ struct MYNTEYE_API ImgData { struct MYNTEYE_API ImuData { /** IMU frame id */ std::uint32_t frame_id; - /** IMU accel or gyro flag: 1 for accel, 2 for gyro, 3 for both */ + /** + * IMU accel or gyro flag + * + * 0: accel and gyro are both valid + * 1: accel is valid + * 2: gyro is valid + */ std::uint8_t flag; /** IMU timestamp in 1us */ std::uint64_t timestamp; diff --git a/src/mynteye/device/channels.cc b/src/mynteye/device/channels.cc index 47cf224..ffbaede 100644 --- a/src/mynteye/device/channels.cc +++ b/src/mynteye/device/channels.cc @@ -21,25 +21,22 @@ #include #include -#include "mynteye/device/config.h" #include "mynteye/logger.h" #include "mynteye/util/strings.h" #include "mynteye/util/times.h" -#include "mynteye/logger.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}}}; +const uvc::xu mynteye_xu = {3, 2, + { + 0x947a6d9f, 0x8a2f, 0x418d, + {0x85, 0x9e, 0x6c, 0x9a, 0xa0, 0x38, 0x10, 0x14} + } +}; int XuCamCtrlId(Option option) { switch (option) { @@ -122,15 +119,15 @@ void CheckSpecVersion(const Version *spec_version) { } // namespace -Channels::Channels(const Model &model, std::shared_ptr device) - : device_(device), - model_(model), - is_imu_tracking_(false), - imu_track_stop_(false), - imu_sn_(0), - imu_callback_(nullptr) { +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__; - imu_res_version_ = (model == Model::STANDARD) ? 1 : 2; UpdateControlInfos(); } @@ -139,6 +136,14 @@ Channels::~Channels() { 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 @@ -148,34 +153,32 @@ void Channels::LogControlInfos() const { } void Channels::UpdateControlInfos() { - auto &&supports = option_supports_map.at(model_); + auto &&supports = adapter_->GetOptionSupports(); for (auto &&option : std::vector