From 107585b5f33e88a86f152c484d8a204169cba363 Mon Sep 17 00:00:00 2001 From: aseelegbaria Date: Mon, 9 Mar 2020 09:54:06 +0200 Subject: [PATCH 1/3] SR305 added --- src/ivcam/sr300.cpp | 48 ++++++++++++++++++++++++++++++++++----------- src/ivcam/sr300.h | 19 ++++++++++++++++-- src/sensor.cpp | 9 +-------- 3 files changed, 55 insertions(+), 21 deletions(-) diff --git a/src/ivcam/sr300.cpp b/src/ivcam/sr300.cpp index c515e90838..1cd0fe66d6 100644 --- a/src/ivcam/sr300.cpp +++ b/src/ivcam/sr300.cpp @@ -43,9 +43,22 @@ namespace librealsense std::shared_ptr sr300_info::create(std::shared_ptr ctx, bool register_device_notifications) const { - return std::make_shared(ctx, _color, _depth, _hwm, - this->get_device_data(), - register_device_notifications); + auto pid = _depth.pid; + switch (pid) + { + case SR300_PID: + return std::make_shared(ctx, _color, _depth, _hwm, + this->get_device_data(), + register_device_notifications); + case SR300v2_PID: + return std::make_shared(ctx, _color, _depth, _hwm, + this->get_device_data(), + register_device_notifications); + default: + throw std::runtime_error(to_string() << "Unsupported SR300 model! 0x" + << std::hex << std::setw(4) << std::setfill('0') << (int)pid); + } + } std::vector> sr300_info::pick_sr300_devices( @@ -57,7 +70,8 @@ namespace librealsense std::vector> results; auto correct_pid = filter_by_product(uvc, { SR300_PID, SR300v2_PID }); - auto group_devices = group_devices_by_unique_id(correct_pid); + + auto group_devices = group_devices_by_unique_id(correct_pid); for (auto& group : group_devices) { if (group.size() == 2 && @@ -468,14 +482,26 @@ namespace librealsense return (c.Rmax / 1000 / 0xFFFF); }))); - if (firmware_version(fw_version) >= firmware_version("3.26.2.0")) - { - roi_sensor_interface* roi_sensor; - if ((roi_sensor = dynamic_cast(&get_sensor(_color_device_idx)))) - roi_sensor->set_roi_method(std::make_shared(*_hw_monitor, - (ds::fw_cmd)ivcam::fw_cmd::SetRgbAeRoi)); - } } + + sr305_camera::sr305_camera(std::shared_ptr ctx, const platform::uvc_device_info &color, + const platform::uvc_device_info &depth, + const platform::usb_device_info &hwm_device, + const platform::backend_device_group& group, + bool register_device_notifications) + : sr300_camera (ctx, color, depth, hwm_device, group, register_device_notifications) { + + static auto device_name = "Intel RealSense SR305"; + register_info(RS2_CAMERA_INFO_NAME, device_name); + + roi_sensor_interface* roi_sensor; + if ((roi_sensor = dynamic_cast(&get_sensor(_color_device_idx)))) + roi_sensor->set_roi_method(std::make_shared(*_hw_monitor, + (ds::fw_cmd)ivcam::fw_cmd::SetRgbAeRoi)); + + } + + void sr300_camera::create_snapshot(std::shared_ptr& snapshot) const { //TODO: implement diff --git a/src/ivcam/sr300.h b/src/ivcam/sr300.h index fb5f98b87e..b72bbd998c 100644 --- a/src/ivcam/sr300.h +++ b/src/ivcam/sr300.h @@ -185,7 +185,7 @@ namespace librealsense platform::usb_device_info _hwm; }; - class sr300_camera final : public virtual device, public debug_interface, public updatable + class sr300_camera : public device, public debug_interface, public updatable { public: std::vector get_profiles_tags() const override @@ -394,7 +394,8 @@ namespace librealsense return dynamic_cast(*depth_sensor.get_raw_sensor()); } - sr300_camera(std::shared_ptr ctx, + + sr300_camera(std::shared_ptr ctx, const platform::uvc_device_info& color, const platform::uvc_device_info& depth, const platform::usb_device_info& hwm_device, @@ -476,6 +477,7 @@ namespace librealsense virtual std::shared_ptr create_matcher(const frame_holder& frame) const override; + private: const uint8_t _depth_device_idx; const uint8_t _color_device_idx; @@ -528,5 +530,18 @@ namespace librealsense std::shared_ptr> _depth_to_color_extrinsics; lazy _camer_calib_params; + + friend class sr305_camera; }; + + class sr305_camera final : public sr300_camera { + public: + sr305_camera(std::shared_ptr ctx, + const platform::uvc_device_info& color, + const platform::uvc_device_info& depth, + const platform::usb_device_info& hwm_device, + const platform::backend_device_group& group, + bool register_device_notifications); + }; + } diff --git a/src/sensor.cpp b/src/sensor.cpp index abe5357a08..caffdecb50 100644 --- a/src/sensor.cpp +++ b/src/sensor.cpp @@ -559,14 +559,7 @@ namespace librealsense void info_container::register_info(rs2_camera_info info, const std::string& val) { - if (info_container::supports_info(info) && (info_container::get_info(info) != val)) // Append existing infos - { - _camera_info[info] += "\n" + val; - } - else - { - _camera_info[info] = val; - } + _camera_info[info] = val; } void info_container::update_info(rs2_camera_info info, const std::string& val) From 6126074f4d682256f9a20ddcc4f039e265b1f9e7 Mon Sep 17 00:00:00 2001 From: aseelegbaria Date: Mon, 9 Mar 2020 14:02:48 +0200 Subject: [PATCH 2/3] sr305 added --- src/ivcam/sr300.cpp | 47 ++++++++++++++++++++++----------------------- src/ivcam/sr300.h | 18 ++++++++--------- src/sensor.cpp | 9 ++++++++- 3 files changed, 39 insertions(+), 35 deletions(-) diff --git a/src/ivcam/sr300.cpp b/src/ivcam/sr300.cpp index 1cd0fe66d6..40f64a5fb3 100644 --- a/src/ivcam/sr300.cpp +++ b/src/ivcam/sr300.cpp @@ -43,19 +43,19 @@ namespace librealsense std::shared_ptr sr300_info::create(std::shared_ptr ctx, bool register_device_notifications) const { - auto pid = _depth.pid; - switch (pid) - { - case SR300_PID: - return std::make_shared(ctx, _color, _depth, _hwm, - this->get_device_data(), - register_device_notifications); - case SR300v2_PID: - return std::make_shared(ctx, _color, _depth, _hwm, - this->get_device_data(), - register_device_notifications); - default: - throw std::runtime_error(to_string() << "Unsupported SR300 model! 0x" + auto pid = _depth.pid; + switch (pid) + { + case SR300_PID: + return std::make_shared(ctx, _color, _depth, _hwm, + this->get_device_data(), + register_device_notifications); + case SR300v2_PID: + return std::make_shared(ctx, _color, _depth, _hwm, + this->get_device_data(), + register_device_notifications); + default: + throw std::runtime_error(to_string() << "Unsupported SR300 model! 0x" << std::hex << std::setw(4) << std::setfill('0') << (int)pid); } @@ -70,8 +70,7 @@ namespace librealsense std::vector> results; auto correct_pid = filter_by_product(uvc, { SR300_PID, SR300v2_PID }); - - auto group_devices = group_devices_by_unique_id(correct_pid); + auto group_devices = group_devices_by_unique_id(correct_pid); for (auto& group : group_devices) { if (group.size() == 2 && @@ -485,17 +484,17 @@ namespace librealsense } sr305_camera::sr305_camera(std::shared_ptr ctx, const platform::uvc_device_info &color, - const platform::uvc_device_info &depth, - const platform::usb_device_info &hwm_device, - const platform::backend_device_group& group, - bool register_device_notifications) - : sr300_camera (ctx, color, depth, hwm_device, group, register_device_notifications) { + const platform::uvc_device_info &depth, + const platform::usb_device_info &hwm_device, + const platform::backend_device_group& group, + bool register_device_notifications) + : sr300_camera (ctx, color, depth, hwm_device, group, register_device_notifications) { - static auto device_name = "Intel RealSense SR305"; - register_info(RS2_CAMERA_INFO_NAME, device_name); + static auto device_name = "Intel RealSense SR305"; + register_info(RS2_CAMERA_INFO_NAME, device_name); - roi_sensor_interface* roi_sensor; - if ((roi_sensor = dynamic_cast(&get_sensor(_color_device_idx)))) + roi_sensor_interface* roi_sensor; + if ((roi_sensor = dynamic_cast(&get_sensor(_color_device_idx)))) roi_sensor->set_roi_method(std::make_shared(*_hw_monitor, (ds::fw_cmd)ivcam::fw_cmd::SetRgbAeRoi)); diff --git a/src/ivcam/sr300.h b/src/ivcam/sr300.h index b72bbd998c..c13c7d6c35 100644 --- a/src/ivcam/sr300.h +++ b/src/ivcam/sr300.h @@ -393,7 +393,6 @@ namespace librealsense synthetic_sensor& depth_sensor = get_depth_sensor(); return dynamic_cast(*depth_sensor.get_raw_sensor()); } - sr300_camera(std::shared_ptr ctx, const platform::uvc_device_info& color, @@ -477,7 +476,6 @@ namespace librealsense virtual std::shared_ptr create_matcher(const frame_holder& frame) const override; - private: const uint8_t _depth_device_idx; const uint8_t _color_device_idx; @@ -531,17 +529,17 @@ namespace librealsense lazy _camer_calib_params; - friend class sr305_camera; + friend class sr305_camera; }; class sr305_camera final : public sr300_camera { public: - sr305_camera(std::shared_ptr ctx, - const platform::uvc_device_info& color, - const platform::uvc_device_info& depth, - const platform::usb_device_info& hwm_device, - const platform::backend_device_group& group, - bool register_device_notifications); - }; + sr305_camera(std::shared_ptr ctx, + const platform::uvc_device_info& color, + const platform::uvc_device_info& depth, + const platform::usb_device_info& hwm_device, + const platform::backend_device_group& group, + bool register_device_notifications); + }; } diff --git a/src/sensor.cpp b/src/sensor.cpp index caffdecb50..2946a412f2 100644 --- a/src/sensor.cpp +++ b/src/sensor.cpp @@ -559,7 +559,14 @@ namespace librealsense void info_container::register_info(rs2_camera_info info, const std::string& val) { - _camera_info[info] = val; + if (info_container::supports_info(info) && (info_container::get_info(info) != val)) // Append existing infos + { + _camera_info[info] += "\n" + val; + } + else + { + _camera_info[info] = val; + } } void info_container::update_info(rs2_camera_info info, const std::string& val) From 20fff11f61ba18eea80cac98c0352255aa2f21b8 Mon Sep 17 00:00:00 2001 From: aseelegbaria Date: Mon, 9 Mar 2020 16:16:39 +0200 Subject: [PATCH 3/3] sr305 added --- src/ivcam/sr300.cpp | 106 ++++++++++++++++++++-------------------- src/ivcam/sr300.h | 70 +++++++++++++------------- src/sensor.cpp | 116 ++++++++++++++++++++++---------------------- 3 files changed, 147 insertions(+), 145 deletions(-) diff --git a/src/ivcam/sr300.cpp b/src/ivcam/sr300.cpp index 40f64a5fb3..2614d82ae0 100644 --- a/src/ivcam/sr300.cpp +++ b/src/ivcam/sr300.cpp @@ -41,24 +41,24 @@ namespace librealsense }; std::shared_ptr sr300_info::create(std::shared_ptr ctx, - bool register_device_notifications) const + bool register_device_notifications) const { auto pid = _depth.pid; switch (pid) { case SR300_PID: return std::make_shared(ctx, _color, _depth, _hwm, - this->get_device_data(), - register_device_notifications); - case SR300v2_PID: + this->get_device_data(), + register_device_notifications); + case SR300v2_PID: return std::make_shared(ctx, _color, _depth, _hwm, - this->get_device_data(), - register_device_notifications); + this->get_device_data(), + register_device_notifications); default: throw std::runtime_error(to_string() << "Unsupported SR300 model! 0x" - << std::hex << std::setw(4) << std::setfill('0') << (int)pid); - } - + << std::hex << std::setw(4) << std::setfill('0') << (int)pid); + } + } std::vector> sr300_info::pick_sr300_devices( @@ -413,17 +413,17 @@ namespace librealsense } sr300_camera::sr300_camera(std::shared_ptr ctx, const platform::uvc_device_info &color, - const platform::uvc_device_info &depth, - const platform::usb_device_info &hwm_device, - const platform::backend_device_group& group, - bool register_device_notifications) + const platform::uvc_device_info &depth, + const platform::usb_device_info &hwm_device, + const platform::backend_device_group& group, + bool register_device_notifications) : device(ctx, group, register_device_notifications), - _depth_device_idx(add_sensor(create_depth_device(ctx, depth))), - _color_device_idx(add_sensor(create_color_device(ctx, color))), - _hw_monitor(std::make_shared(std::make_shared(ctx->get_backend().create_usb_device(hwm_device), get_raw_depth_sensor()))), - _depth_stream(new stream(RS2_STREAM_DEPTH)), - _ir_stream(new stream(RS2_STREAM_INFRARED)), - _color_stream(new stream(RS2_STREAM_COLOR)) + _depth_device_idx(add_sensor(create_depth_device(ctx, depth))), + _depth_stream(new stream(RS2_STREAM_DEPTH)), + _ir_stream(new stream(RS2_STREAM_INFRARED)), + _color_stream(new stream(RS2_STREAM_COLOR)), + _color_device_idx(add_sensor(create_color_device(ctx, color))), + _hw_monitor(std::make_shared(std::make_shared(ctx->get_backend().create_usb_device(hwm_device), get_raw_depth_sensor()))) { using namespace ivcam; static auto device_name = "Intel RealSense SR300"; @@ -442,16 +442,16 @@ namespace librealsense auto pid_hex_str = hexify(color.pid); //auto recommended_fw_version = firmware_version(SR3XX_RECOMMENDED_FIRMWARE_VERSION); - register_info(RS2_CAMERA_INFO_NAME, device_name); - register_info(RS2_CAMERA_INFO_SERIAL_NUMBER, serial); + register_info(RS2_CAMERA_INFO_NAME, device_name); + register_info(RS2_CAMERA_INFO_SERIAL_NUMBER, serial); register_info(RS2_CAMERA_INFO_ASIC_SERIAL_NUMBER, serial); register_info(RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID, serial); register_info(RS2_CAMERA_INFO_FIRMWARE_VERSION, fw_version); - register_info(RS2_CAMERA_INFO_PHYSICAL_PORT, depth.device_path); - register_info(RS2_CAMERA_INFO_DEBUG_OP_CODE, std::to_string(static_cast(fw_cmd::GLD))); - register_info(RS2_CAMERA_INFO_PRODUCT_ID, pid_hex_str); - register_info(RS2_CAMERA_INFO_PRODUCT_LINE, "SR300"); - register_info(RS2_CAMERA_INFO_CAMERA_LOCKED, _is_locked ? "YES" : "NO"); + register_info(RS2_CAMERA_INFO_PHYSICAL_PORT, depth.device_path); + register_info(RS2_CAMERA_INFO_DEBUG_OP_CODE, std::to_string(static_cast(fw_cmd::GLD))); + register_info(RS2_CAMERA_INFO_PRODUCT_ID, pid_hex_str); + register_info(RS2_CAMERA_INFO_PRODUCT_LINE, "SR300"); + register_info(RS2_CAMERA_INFO_CAMERA_LOCKED, _is_locked ? "YES" : "NO"); //register_info(RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION, recommended_fw_version); register_autorange_options(); @@ -475,31 +475,31 @@ namespace librealsense register_stream_to_extrinsic_group(*_color_stream, 0); get_depth_sensor().register_option(RS2_OPTION_DEPTH_UNITS, - std::make_shared("Number of meters represented by a single depth unit", - lazy([this]() { - auto c = *_camer_calib_params; - return (c.Rmax / 1000 / 0xFFFF); - }))); + std::make_shared("Number of meters represented by a single depth unit", + lazy([this]() { + auto c = *_camer_calib_params; + return (c.Rmax / 1000 / 0xFFFF); + }))); + + } + + sr305_camera::sr305_camera(std::shared_ptr ctx, const platform::uvc_device_info &color, + const platform::uvc_device_info &depth, + const platform::usb_device_info &hwm_device, + const platform::backend_device_group& group, + bool register_device_notifications) + : sr300_camera(ctx, color, depth, hwm_device, group, register_device_notifications) { + + static auto device_name = "Intel RealSense SR305"; + update_info(RS2_CAMERA_INFO_NAME, device_name); + + roi_sensor_interface* roi_sensor; + if ((roi_sensor = dynamic_cast(&get_sensor(_color_device_idx)))) + roi_sensor->set_roi_method(std::make_shared(*_hw_monitor, + (ds::fw_cmd)ivcam::fw_cmd::SetRgbAeRoi)); } - sr305_camera::sr305_camera(std::shared_ptr ctx, const platform::uvc_device_info &color, - const platform::uvc_device_info &depth, - const platform::usb_device_info &hwm_device, - const platform::backend_device_group& group, - bool register_device_notifications) - : sr300_camera (ctx, color, depth, hwm_device, group, register_device_notifications) { - - static auto device_name = "Intel RealSense SR305"; - register_info(RS2_CAMERA_INFO_NAME, device_name); - - roi_sensor_interface* roi_sensor; - if ((roi_sensor = dynamic_cast(&get_sensor(_color_device_idx)))) - roi_sensor->set_roi_method(std::make_shared(*_hw_monitor, - (ds::fw_cmd)ivcam::fw_cmd::SetRgbAeRoi)); - - } - void sr300_camera::create_snapshot(std::shared_ptr& snapshot) const { @@ -515,7 +515,7 @@ namespace librealsense { std::lock_guard lock(_mtx); - if(has_metadata_ts(frame)) + if (has_metadata_ts(frame)) { auto f = std::dynamic_pointer_cast(frame); if (!f) @@ -576,18 +576,18 @@ namespace librealsense { std::lock_guard lock(_mtx); - return (has_metadata_ts(frame))? RS2_TIMESTAMP_DOMAIN_HARDWARE_CLOCK : _backup_timestamp_reader->get_frame_timestamp_domain(frame); + return (has_metadata_ts(frame)) ? RS2_TIMESTAMP_DOMAIN_HARDWARE_CLOCK : _backup_timestamp_reader->get_frame_timestamp_domain(frame); } std::shared_ptr sr300_camera::create_matcher(const frame_holder& frame) const { std::vector> depth_matchers; - std::vector streams = { _depth_stream.get(), _ir_stream.get()}; + std::vector streams = { _depth_stream.get(), _ir_stream.get() }; for (auto& s : streams) { - depth_matchers.push_back(std::make_shared( s->get_unique_id(), s->get_stream_type())); + depth_matchers.push_back(std::make_shared(s->get_unique_id(), s->get_stream_type())); } std::vector> matchers; if (!frame.frame->supports_frame_metadata(RS2_FRAME_METADATA_FRAME_COUNTER)) @@ -599,7 +599,7 @@ namespace librealsense matchers.push_back(std::make_shared(depth_matchers)); } - auto color_matcher = std::make_shared( _color_stream->get_unique_id(), _color_stream->get_stream_type()); + auto color_matcher = std::make_shared(_color_stream->get_unique_id(), _color_stream->get_stream_type()); matchers.push_back(color_matcher); return std::make_shared(matchers); diff --git a/src/ivcam/sr300.h b/src/ivcam/sr300.h index c13c7d6c35..18acb2461d 100644 --- a/src/ivcam/sr300.h +++ b/src/ivcam/sr300.h @@ -92,7 +92,7 @@ namespace librealsense LOG_ERROR("Frame is not valid. Failed to downcast to librealsense::frame."); return RS2_TIMESTAMP_DOMAIN_COUNT; } - if(f->additional_data.metadata_size >= platform::uvc_header_size ) + if (f->additional_data.metadata_size >= platform::uvc_header_size) return RS2_TIMESTAMP_DOMAIN_HARDWARE_CLOCK; else return RS2_TIMESTAMP_DOMAIN_SYSTEM_TIME; @@ -101,10 +101,10 @@ namespace librealsense class sr300_timestamp_reader_from_metadata : public frame_timestamp_reader { - std::unique_ptr _backup_timestamp_reader; - bool one_time_note; - mutable std::recursive_mutex _mtx; - arithmetic_wraparound ts_wrap; + std::unique_ptr _backup_timestamp_reader; + bool one_time_note; + mutable std::recursive_mutex _mtx; + arithmetic_wraparound ts_wrap; protected: @@ -117,8 +117,8 @@ namespace librealsense return false; } // Metadata support for a specific stream is immutable - const bool has_md_ts = [&]{ std::lock_guard lock(_mtx); - return ((f->additional_data.metadata_blob.data() != nullptr) && (f->additional_data.metadata_size >= platform::uvc_header_size) && ((byte*)f->additional_data.metadata_blob.data())[0] >= platform::uvc_header_size); + const bool has_md_ts = [&] { std::lock_guard lock(_mtx); + return ((f->additional_data.metadata_blob.data() != nullptr) && (f->additional_data.metadata_size >= platform::uvc_header_size) && ((byte*)f->additional_data.metadata_blob.data())[0] >= platform::uvc_header_size); }(); return has_md_ts; @@ -134,7 +134,7 @@ namespace librealsense } // Metadata support for a specific stream is immutable const bool has_md_frame_counter = [&] { std::lock_guard lock(_mtx); - return ((f->additional_data.metadata_blob.data() != nullptr) && (f->additional_data.metadata_size > platform::uvc_header_size) && ((byte*)f->additional_data.metadata_blob.data())[0] > platform::uvc_header_size); + return ((f->additional_data.metadata_blob.data() != nullptr) && (f->additional_data.metadata_size > platform::uvc_header_size) && ((byte*)f->additional_data.metadata_blob.data())[0] > platform::uvc_header_size); }(); return has_md_frame_counter; @@ -160,14 +160,14 @@ namespace librealsense { public: std::shared_ptr create(std::shared_ptr ctx, - bool register_device_notifications) const override; + bool register_device_notifications) const override; sr300_info(std::shared_ptr ctx, - platform::uvc_device_info color, - platform::uvc_device_info depth, - platform::usb_device_info hwm) + platform::uvc_device_info color, + platform::uvc_device_info depth, + platform::usb_device_info hwm) : device_info(ctx), _color(std::move(color)), - _depth(std::move(depth)), _hwm(std::move(hwm)) {} + _depth(std::move(depth)), _hwm(std::move(hwm)) {} static std::vector> pick_sr300_devices( std::shared_ptr ctx, @@ -185,7 +185,7 @@ namespace librealsense platform::usb_device_info _hwm; }; - class sr300_camera : public device, public debug_interface, public updatable + class sr300_camera : public device, public debug_interface, public updatable { public: std::vector get_profiles_tags() const override @@ -228,7 +228,7 @@ namespace librealsense explicit preset_option(sr300_camera& owner, const option_range& opt_range) : option_base(opt_range), - _owner(owner) + _owner(owner) {} private: @@ -387,19 +387,19 @@ namespace librealsense } synthetic_sensor& get_depth_sensor() { return dynamic_cast(get_sensor(_depth_device_idx)); } - + uvc_sensor& get_raw_depth_sensor() { synthetic_sensor& depth_sensor = get_depth_sensor(); return dynamic_cast(*depth_sensor.get_raw_sensor()); } - - sr300_camera(std::shared_ptr ctx, - const platform::uvc_device_info& color, - const platform::uvc_device_info& depth, - const platform::usb_device_info& hwm_device, - const platform::backend_device_group& group, - bool register_device_notifications); + + sr300_camera(std::shared_ptr ctx, + const platform::uvc_device_info& color, + const platform::uvc_device_info& depth, + const platform::usb_device_info& hwm_device, + const platform::backend_device_group& group, + bool register_device_notifications); void rs2_apply_ivcam_preset(int preset) { @@ -439,7 +439,7 @@ namespace librealsense { 1, 1, 6, 1, -1 }, /* GRCursor */ { 16, 1, 5, 3, 9 }, /* Default */ { 1, 1, 5, 1, -1 }, /* MidRange */ - { 1, -1, -1, -1, - 1 } /* IROnly */ + { 1, -1, -1, -1, -1 } /* IROnly */ }; // The Default preset is handled differently from all the rest, @@ -476,10 +476,10 @@ namespace librealsense virtual std::shared_ptr create_matcher(const frame_holder& frame) const override; + + private: const uint8_t _depth_device_idx; - const uint8_t _color_device_idx; - std::shared_ptr _hw_monitor; bool _is_locked = true; template @@ -529,17 +529,19 @@ namespace librealsense lazy _camer_calib_params; - friend class sr305_camera; + protected: + const uint8_t _color_device_idx; + std::shared_ptr _hw_monitor; }; - class sr305_camera final : public sr300_camera { - public: + class sr305_camera final : public sr300_camera { + public: sr305_camera(std::shared_ptr ctx, - const platform::uvc_device_info& color, - const platform::uvc_device_info& depth, - const platform::usb_device_info& hwm_device, - const platform::backend_device_group& group, - bool register_device_notifications); + const platform::uvc_device_info& color, + const platform::uvc_device_info& depth, + const platform::usb_device_info& hwm_device, + const platform::backend_device_group& group, + bool register_device_notifications); }; } diff --git a/src/sensor.cpp b/src/sensor.cpp index 2946a412f2..67e4bd807b 100644 --- a/src/sensor.cpp +++ b/src/sensor.cpp @@ -27,16 +27,16 @@ namespace librealsense recommended_proccesing_blocks_interface* owner) : recommended_proccesing_blocks_base(owner), _is_streaming(false), - _is_opened(false), - _notifications_processor(std::shared_ptr(new notifications_processor())), - _on_open(nullptr), - _metadata_parsers(std::make_shared()), - _owner(dev), - _profiles([this]() { - auto profiles = this->init_stream_profiles(); - _owner->tag_profiles(profiles); - return profiles; - }) + _is_opened(false), + _notifications_processor(std::shared_ptr(new notifications_processor())), + _on_open(nullptr), + _metadata_parsers(std::make_shared()), + _owner(dev), + _profiles([this]() { + auto profiles = this->init_stream_profiles(); + _owner->tag_profiles(profiles); + return profiles; + }) { register_option(RS2_OPTION_FRAMES_QUEUE_SIZE, _source.get_published_size_option()); @@ -131,7 +131,7 @@ namespace librealsense return _fourcc_to_rs2_format; } - std::shared_ptr>& sensor_base::get_fourcc_to_rs2_stream_map() + std::shared_ptr>& sensor_base::get_fourcc_to_rs2_stream_map() { return _fourcc_to_rs2_stream; } @@ -340,12 +340,12 @@ namespace librealsense LOG_DEBUG("FrameAccepted," << librealsense::get_string(req_profile_base->get_stream_type()) << ",Counter," << std::dec << fr->additional_data.frame_number - << ",Index," << req_profile_base->get_stream_index() - << ",BackEndTS," << std::fixed << f.backend_time - << ",SystemTime," << std::fixed << system_time - << " ,diff_ts[Sys-BE]," << system_time - f.backend_time - << ",TS," << std::fixed << timestamp << ",TS_Domain," << rs2_timestamp_domain_to_string(timestamp_domain) - << ",last_frame_number," << last_frame_number << ",last_timestamp," << last_timestamp); + << ",Index," << req_profile_base->get_stream_index() + << ",BackEndTS," << std::fixed << f.backend_time + << ",SystemTime," << std::fixed << system_time + << " ,diff_ts[Sys-BE]," << system_time - f.backend_time + << ",TS," << std::fixed << timestamp << ",TS_Domain," << rs2_timestamp_domain_to_string(timestamp_domain) + << ",last_frame_number," << last_frame_number << ",last_timestamp," << last_timestamp); last_frame_number = frame_counter; last_timestamp = timestamp; @@ -468,7 +468,7 @@ namespace librealsense std::lock_guard lock(_configure_lock); if (_is_streaming) throw wrong_api_call_sequence_exception("start_streaming(...) failed. UVC device is already streaming!"); - else if(!_is_opened) + else if (!_is_opened) throw wrong_api_call_sequence_exception("start_streaming(...) failed. UVC device was not opened!"); raise_on_before_streaming_changes(true); //Required to be just before actual start allow recording to work @@ -559,14 +559,14 @@ namespace librealsense void info_container::register_info(rs2_camera_info info, const std::string& val) { - if (info_container::supports_info(info) && (info_container::get_info(info) != val)) // Append existing infos - { - _camera_info[info] += "\n" + val; - } - else - { - _camera_info[info] = val; - } + if (info_container::supports_info(info) && (info_container::get_info(info) != val)) // Append existing infos + { + _camera_info[info] += "\n" + val; + } + else + { + _camera_info[info] = val; + } } void info_container::update_info(rs2_camera_info info, const std::string& val) @@ -590,7 +590,7 @@ namespace librealsense } void info_container::enable_recording(std::function record_action) { - //info container is a read only class, nothing to record + //info container is a read only class, nothing to record } void info_container::update(std::shared_ptr ext) @@ -642,12 +642,12 @@ namespace librealsense const std::map>& fps_and_sampling_frequency_per_rs2_stream, const std::vector>& sensor_name_and_hid_profiles, device* dev) - : sensor_base("Raw Motion Module", dev, (recommended_proccesing_blocks_interface*)this), _sensor_name_and_hid_profiles(sensor_name_and_hid_profiles), - _fps_and_sampling_frequency_per_rs2_stream(fps_and_sampling_frequency_per_rs2_stream), - _hid_device(hid_device), - _is_configured_stream(RS2_STREAM_COUNT), - _hid_iio_timestamp_reader(move(hid_iio_timestamp_reader)), - _custom_hid_timestamp_reader(move(custom_hid_timestamp_reader)) + : sensor_base("Raw Motion Module", dev, (recommended_proccesing_blocks_interface*)this), _sensor_name_and_hid_profiles(sensor_name_and_hid_profiles), + _fps_and_sampling_frequency_per_rs2_stream(fps_and_sampling_frequency_per_rs2_stream), + _hid_device(hid_device), + _is_configured_stream(RS2_STREAM_COUNT), + _hid_iio_timestamp_reader(move(hid_iio_timestamp_reader)), + _custom_hid_timestamp_reader(move(custom_hid_timestamp_reader)) { register_metadata(RS2_FRAME_METADATA_BACKEND_TIMESTAMP, make_additional_data_parser(&frame_additional_data::backend_timestamp)); @@ -657,7 +657,7 @@ namespace librealsense std::vector profiles_vector; for (auto&& elem : frequency_per_sensor) - profiles_vector.push_back(platform::hid_profile{elem.first, elem.second}); + profiles_vector.push_back(platform::hid_profile{ elem.first, elem.second }); _hid_device->register_profiles(profiles_vector); for (auto&& elem : _hid_device->get_sensors()) @@ -674,7 +674,7 @@ namespace librealsense if (_is_opened) close(); } - catch(...) + catch (...) { LOG_ERROR("An error has occurred while stop_streaming()!"); } @@ -764,7 +764,7 @@ namespace librealsense std::lock_guard lock(_configure_lock); if (_is_streaming) throw wrong_api_call_sequence_exception("start_streaming(...) failed. Hid device is already streaming!"); - else if(!_is_opened) + else if (!_is_opened) throw wrong_api_call_sequence_exception("start_streaming(...) failed. Hid device was not opened!"); _source.set_callback(callback); @@ -869,7 +869,7 @@ namespace librealsense for (auto&& it = _hid_sensors.rbegin(); it != _hid_sensors.rend(); ++it) { auto profiles = get_sensor_profiles(it->name); - stream_requests.insert(stream_requests.end(), profiles.begin() ,profiles.end()); + stream_requests.insert(stream_requests.end(), profiles.begin(), profiles.end()); } return stream_requests; @@ -888,10 +888,10 @@ namespace librealsense uint32_t hid_sensor::stream_to_fourcc(rs2_stream stream) const { uint32_t fourcc; - try{ + try { fourcc = stream_and_fourcc.at(stream); } - catch(std::out_of_range) + catch (std::out_of_range) { throw invalid_value_exception(to_string() << "fourcc of stream " << rs2_stream_to_string(stream) << " not found!"); } @@ -913,17 +913,17 @@ namespace librealsense return fps; } - uvc_sensor::uvc_sensor(std::string name, + uvc_sensor::uvc_sensor(std::string name, std::shared_ptr uvc_device, std::unique_ptr timestamp_reader, device* dev) - : sensor_base(name, dev, (recommended_proccesing_blocks_interface*)this), - _device(move(uvc_device)), - _user_count(0), - _timestamp_reader(std::move(timestamp_reader)) + : sensor_base(name, dev, (recommended_proccesing_blocks_interface*)this), + _device(move(uvc_device)), + _user_count(0), + _timestamp_reader(std::move(timestamp_reader)) { - register_metadata(RS2_FRAME_METADATA_BACKEND_TIMESTAMP, make_additional_data_parser(&frame_additional_data::backend_timestamp)); - register_metadata(RS2_FRAME_METADATA_RAW_FRAME_SIZE, make_additional_data_parser(&frame_additional_data::raw_size)); + register_metadata(RS2_FRAME_METADATA_BACKEND_TIMESTAMP, make_additional_data_parser(&frame_additional_data::backend_timestamp)); + register_metadata(RS2_FRAME_METADATA_RAW_FRAME_SIZE, make_additional_data_parser(&frame_additional_data::raw_size)); } iio_hid_timestamp_reader::iio_hid_timestamp_reader() @@ -960,7 +960,7 @@ namespace librealsense auto timestamp = *(reinterpret_cast(f->additional_data.metadata_blob.data())); if (f->additional_data.metadata_size >= platform::hid_header_size) timestamp = static_cast(reinterpret_cast(f->additional_data.metadata_blob.data())->timestamp); - + // HID timestamps are aligned to FW Default - usec units return static_cast(timestamp * TIMESTAMP_USEC_TO_MSEC); } @@ -1064,7 +1064,7 @@ namespace librealsense void synthetic_sensor::sort_profiles(stream_profiles* profiles) { std::sort(profiles->begin(), profiles->end(), [](const std::shared_ptr& ap, - const std::shared_ptr& bp) + const std::shared_ptr& bp) { const auto&& a = to_profile(ap.get()); const auto&& b = to_profile(bp.get()); @@ -1213,7 +1213,7 @@ namespace librealsense } std::pair, stream_profiles> synthetic_sensor::find_requests_best_pb_match(const stream_profiles& requests) - { + { // Find and retrieve best fitting processing block to the given requests, and the requests which were the best fit. // For video stream, the best fitting processing block is defined as the processing block which its sources @@ -1241,7 +1241,7 @@ namespace librealsense } } - return {best_match_processing_block_factory, best_match_requests}; + return { best_match_processing_block_factory, best_match_requests }; } void synthetic_sensor::add_source_profile_missing_data(std::shared_ptr& target) @@ -1292,13 +1292,13 @@ namespace librealsense std::unordered_set> resolved_req_set; stream_profiles resolved_req; stream_profiles unhandled_reqs(requests); - + // cache the requests for (auto&& req : requests) { _cached_requests[req->get_format()].push_back(req); } - + // while not finished handling all of the requests do while (!unhandled_reqs.empty()) { @@ -1306,7 +1306,7 @@ namespace librealsense const auto&& best_match = find_requests_best_pb_match(unhandled_reqs); auto&& best_pbf = best_match.first; auto&& best_reqs = best_match.second; - + // mark as handled resolved requests for (auto&& req : best_reqs) { @@ -1380,7 +1380,7 @@ namespace librealsense for (auto&& entry : _profiles_to_processing_block) { for (auto&& pb : entry.second) - unregister_processing_block_options(*pb); + unregister_processing_block_options(*pb); } _profiles_to_processing_block.erase(begin(_profiles_to_processing_block), end(_profiles_to_processing_block)); _cached_requests.erase(_cached_requests.begin(), _cached_requests.end()); @@ -1458,10 +1458,10 @@ namespace librealsense { auto&& pbs = pb_entry.second; for (auto&& pb : pbs) - if (pb) - { - pb->set_output_callback(output_cb); - } + if (pb) + { + pb->set_output_callback(output_cb); + } } // Invoke processing blocks callback