From 10afeaa8174497fd6ddc1cd6e70cd4fdb27e9f84 Mon Sep 17 00:00:00 2001 From: Dave Tong Date: Mon, 9 Mar 2020 15:48:16 -0700 Subject: [PATCH 1/5] Added emmitter always on option and the missing warpper part for freefall detection enabled option --- include/librealsense2/h/rs_option.h | 1 + src/ds5/ds5-device.cpp | 5 +++ src/ds5/ds5-options.cpp | 35 +++++++++++++++++++ src/ds5/ds5-options.h | 22 ++++++++++++ src/ds5/ds5-private.h | 1 + src/types.cpp | 1 + .../intel/realsense/librealsense/Option.java | 1 + .../Intel.RealSense/Types/Enums/Option.cs | 6 ++++ wrappers/matlab/option.m | 4 ++- wrappers/nodejs/index.js | 11 ++++++ wrappers/nodejs/src/addon.cpp | 1 + wrappers/python/pybackend.cpp | 1 + .../Source/RealSense/Public/RealSenseTypes.h | 1 + 13 files changed, 89 insertions(+), 1 deletion(-) diff --git a/include/librealsense2/h/rs_option.h b/include/librealsense2/h/rs_option.h index ac911fc552..99d3600cfb 100644 --- a/include/librealsense2/h/rs_option.h +++ b/include/librealsense2/h/rs_option.h @@ -85,6 +85,7 @@ extern "C" { RS2_OPTION_ZERO_ORDER_ENABLED, /**< Toggle Zero-Order mode */ RS2_OPTION_ENABLE_MAP_PRESERVATION, /**< Preserve previous map when starting */ RS2_OPTION_FREEFALL_DETECTION_ENABLED, /**< Enable/disable sensor shutdown when a free-fall is detected (on by default) */ + RS2_OPTION_EMITTER_ALWAYS_ON, /**< Enable Laser On constantly (GS SKU Only) */ RS2_OPTION_AVALANCHE_PHOTO_DIODE, /**< Changes the exposure time of Avalanche Photo Diode in the receiver */ RS2_OPTION_POST_PROCESSING_SHARPENING, /**< Changes the amount of sharpening in the post-processed image */ RS2_OPTION_PRE_PROCESSING_SHARPENING, /**< Changes the amount of sharpening in the pre-processed image */ diff --git a/src/ds5/ds5-device.cpp b/src/ds5/ds5-device.cpp index 0988cd92b0..be588acb3c 100644 --- a/src/ds5/ds5-device.cpp +++ b/src/ds5/ds5-device.cpp @@ -757,6 +757,11 @@ namespace librealsense depth_sensor.register_option(RS2_OPTION_EMITTER_ON_OFF, std::make_shared(*_hw_monitor, &raw_depth_sensor)); } + if ((_fw_version >= firmware_version("5.12.1.0")) && ((_device_capabilities & d400_caps::CAP_GLOBAL_SHUTTER) == d400_caps::CAP_GLOBAL_SHUTTER)) + { + depth_sensor.register_option(RS2_OPTION_EMITTER_ALWAYS_ON, std::make_shared(*_hw_monitor, &depth_sensor)); + } + if (_fw_version >= firmware_version("5.9.15.1")) { depth_sensor.register_option(RS2_OPTION_INTER_CAM_SYNC_MODE, diff --git a/src/ds5/ds5-options.cpp b/src/ds5/ds5-options.cpp index d38cab17ac..5ee97107be 100644 --- a/src/ds5/ds5-options.cpp +++ b/src/ds5/ds5-options.cpp @@ -473,4 +473,39 @@ namespace librealsense static std::vector alt_emitter_name(ds::alternating_emitter_pattern.begin()+2,ds::alternating_emitter_pattern.begin()+22); return (alt_emitter_name == res); } + + emitter_always_on_option::emitter_always_on_option(hw_monitor& hwm, sensor_base* ep) + : _hwm(hwm), _sensor(ep) + { + _range = [this]() + { + return option_range{ 0, 1, 1, 0 }; + }; + } + + void emitter_always_on_option::set(float value) + { + command cmd(ds::LASERONCONST); + cmd.param1 = static_cast(value); + + _hwm.send(cmd); + _record_action(*this); + } + + float emitter_always_on_option::query() const + { + command cmd(ds::LASERONCONST); + cmd.param1 = 2; + + auto res = _hwm.send(cmd); + if (res.empty()) + throw invalid_value_exception("emitter_always_on_option::query result is empty!"); + + return (res.front()); + } + + option_range emitter_always_on_option::get_range() const + { + return *_range; + } } diff --git a/src/ds5/ds5-options.h b/src/ds5/ds5-options.h index babe719193..bce90af905 100644 --- a/src/ds5/ds5-options.h +++ b/src/ds5/ds5-options.h @@ -272,4 +272,26 @@ namespace librealsense hw_monitor& _hwm; sensor_base* _sensor; }; + + class emitter_always_on_option : public option + { + public: + emitter_always_on_option(hw_monitor& hwm, sensor_base* depth_ep); + virtual ~emitter_always_on_option() = default; + virtual void set(float value) override; + virtual float query() const override; + virtual option_range get_range() const override; + virtual bool is_enabled() const override { return true; } + virtual const char* get_description() const override + { + return "Emitter always on mode: 0:disabled(default), 1:enabled."; + } + virtual void enable_recording(std::function record_action) override { _record_action = record_action; } + + private: + std::function _record_action = [](const option&) {}; + lazy _range; + hw_monitor& _hwm; + sensor_base* _sensor; + }; } diff --git a/src/ds5/ds5-private.h b/src/ds5/ds5-private.h index 6774051d45..5a9d412467 100644 --- a/src/ds5/ds5-private.h +++ b/src/ds5/ds5-private.h @@ -206,6 +206,7 @@ namespace librealsense GETSUBPRESET = 0x7C, // Upload the current sub-preset GETSUBPRESETNAME= 0x7D, // Retrieve sub-preset's name RECPARAMSGET = 0x7E, // Retrieve depth calibration table in new format (fw >= 5.11.12.100) + LASERONCONST = 0x7F, // Enable Laser On constantly (GS SKU Only) AUTO_CALIB = 0x80 // auto calibration commands }; diff --git a/src/types.cpp b/src/types.cpp index 8396d536ee..bb1efba043 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -327,6 +327,7 @@ namespace librealsense CASE(INVALIDATION_BYPASS) CASE(AMBIENT_LIGHT) CASE(SENSOR_MODE) + CASE(EMITTER_ALWAYS_ON) default: assert(!is_valid(value)); return UNKNOWN_VALUE; } #undef CASE diff --git a/wrappers/android/librealsense/src/main/java/com/intel/realsense/librealsense/Option.java b/wrappers/android/librealsense/src/main/java/com/intel/realsense/librealsense/Option.java index 0aea6d1396..7d9ce7f053 100644 --- a/wrappers/android/librealsense/src/main/java/com/intel/realsense/librealsense/Option.java +++ b/wrappers/android/librealsense/src/main/java/com/intel/realsense/librealsense/Option.java @@ -65,6 +65,7 @@ public enum Option { ZERO_ORDER_ENABLED(61), ENABLE_MAP_PRESERVATION(62), FREEFALL_DETECTION_ENABLED(63); + EMITTER_ALWAYS_ON(64); private final int mValue; diff --git a/wrappers/csharp/Intel.RealSense/Types/Enums/Option.cs b/wrappers/csharp/Intel.RealSense/Types/Enums/Option.cs index bfb788a41f..eee215a8c8 100644 --- a/wrappers/csharp/Intel.RealSense/Types/Enums/Option.cs +++ b/wrappers/csharp/Intel.RealSense/Types/Enums/Option.cs @@ -199,5 +199,11 @@ public enum Option /// Preserve previous map when starting EnableMapPreservation = 62, + + /// Enable/disable sensor shutdown when a free-fall is detected (on by default) + FreeFallDetectionEnabled = 63, + + /// Enable Laser On constantly (GS SKU Only) + EmitterAlwaysOn = 64, } } diff --git a/wrappers/matlab/option.m b/wrappers/matlab/option.m index f36c63e14f..463754d186 100644 --- a/wrappers/matlab/option.m +++ b/wrappers/matlab/option.m @@ -63,6 +63,8 @@ led_power (60) zero_order_enabled (61) enable_map_preservation (62) - count (63) + FreeFallDetectionEnabled (63) + emitter_always_on (64) + count (65) end end diff --git a/wrappers/nodejs/index.js b/wrappers/nodejs/index.js index 564dcca675..304af00a73 100644 --- a/wrappers/nodejs/index.js +++ b/wrappers/nodejs/index.js @@ -4925,6 +4925,13 @@ const option = { OPTION_LED_POWER: RS2.RS2_OPTION_LED_POWER, OPTION_ZERO_ORDER_ENABLED: RS2.RS2_OPTION_ZERO_ORDER_ENABLED, OPTION_ENABLE_MAP_PRESERVATION: RS2.RS2_OPTION_ENABLE_MAP_PRESERVATION, + OPTION_FREEFALL_DETECTION_ENABLED: RS2.RS2_OPTION_FREEFALL_DETECTION_ENABLED, + /** + * Enable Laser On constantly (GS SKU Only) + *
Equivalent to its lowercase counterpart + * @type {Integer} + */ + OPTION_EMITTER_ALWAYS_ON: RS2.RS2_OPTION_EMITTER_ALWAYS_ON, /** * Number of enumeration values. Not a valid input: intended to be used in for-loops. * @type {Integer} @@ -5067,6 +5074,10 @@ const option = { return this.option_zero_order_enabled; case this.OPTION_ENABLE_MAP_PRESERVATION: return this.option_enable_map_preservation; + case this.OPTION_FREEFALL_DETECTION_ENABLED: + return this.option_freefall_detection_enabled; + case this.OPTION_EMITTER_ALWAYS_ON: + return this.option_emitter_always_on; default: throw new TypeError( 'option.optionToString(option) expects a valid value as the 1st argument'); diff --git a/wrappers/nodejs/src/addon.cpp b/wrappers/nodejs/src/addon.cpp index 09509bba92..a0c393c9d9 100644 --- a/wrappers/nodejs/src/addon.cpp +++ b/wrappers/nodejs/src/addon.cpp @@ -4690,6 +4690,7 @@ void InitModule(v8::Local exports) { _FORCE_SET_ENUM(RS2_OPTION_ZERO_ORDER_ENABLED); _FORCE_SET_ENUM(RS2_OPTION_ENABLE_MAP_PRESERVATION); _FORCE_SET_ENUM(RS2_OPTION_FREEFALL_DETECTION_ENABLED); + _FORCE_SET_ENUM(RS2_OPTION_EMITTER_ALWAYS_ON); _FORCE_SET_ENUM(RS2_OPTION_COUNT); // rs2_camera_info diff --git a/wrappers/python/pybackend.cpp b/wrappers/python/pybackend.cpp index aa0e88d65e..b3ad4da060 100644 --- a/wrappers/python/pybackend.cpp +++ b/wrappers/python/pybackend.cpp @@ -163,6 +163,7 @@ PYBIND11_MODULE(NAME, m) { .value("zero_order_enabled", RS2_OPTION_ZERO_ORDER_ENABLED) .value("enable_map_preservation", RS2_OPTION_ENABLE_MAP_PRESERVATION) .value("enable_freefall_detection", RS2_OPTION_FREEFALL_DETECTION_ENABLED) + .value("emiiter_always_on", RS2_OPTION_EMITTER_ALWAYS_ON) .value("count", RS2_OPTION_COUNT); py::enum_ power_state(m, "power_state"); diff --git a/wrappers/unrealengine4/Plugins/RealSense/Source/RealSense/Public/RealSenseTypes.h b/wrappers/unrealengine4/Plugins/RealSense/Source/RealSense/Public/RealSenseTypes.h index f3af363a07..f51f91160b 100755 --- a/wrappers/unrealengine4/Plugins/RealSense/Source/RealSense/Public/RealSenseTypes.h +++ b/wrappers/unrealengine4/Plugins/RealSense/Source/RealSense/Public/RealSenseTypes.h @@ -117,6 +117,7 @@ enum class ERealSenseOptionType : uint8 ZERO_ORDER_ENABLED , /**< Zero-order mode */ ENABLE_MAP_PRESERVATION , /**< Preserve map from the previous run */ FREEFALL_DETECTION_ENABLED , /**< Enable/disable sensor shutdown when a free-fall is detected (on by default) */ + EMITTER_ALWAYS_ON , /**< Enable Laser On constantly (GS SKU Only) */ }; UENUM(Blueprintable) From 7f9e1819dfcca6fa2a6411d77d5c948b436959c9 Mon Sep 17 00:00:00 2001 From: Dave Tong Date: Mon, 9 Mar 2020 16:30:21 -0700 Subject: [PATCH 2/5] Fixed line endings. --- src/ds5/ds5-device.cpp | 8 ++--- src/ds5/ds5-options.cpp | 66 ++++++++++++++++++++--------------------- src/ds5/ds5-options.h | 40 ++++++++++++------------- 3 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/ds5/ds5-device.cpp b/src/ds5/ds5-device.cpp index be588acb3c..f2c80d3f9c 100644 --- a/src/ds5/ds5-device.cpp +++ b/src/ds5/ds5-device.cpp @@ -757,10 +757,10 @@ namespace librealsense depth_sensor.register_option(RS2_OPTION_EMITTER_ON_OFF, std::make_shared(*_hw_monitor, &raw_depth_sensor)); } - if ((_fw_version >= firmware_version("5.12.1.0")) && ((_device_capabilities & d400_caps::CAP_GLOBAL_SHUTTER) == d400_caps::CAP_GLOBAL_SHUTTER)) - { - depth_sensor.register_option(RS2_OPTION_EMITTER_ALWAYS_ON, std::make_shared(*_hw_monitor, &depth_sensor)); - } + if ((_fw_version >= firmware_version("5.12.1.0")) && ((_device_capabilities & d400_caps::CAP_GLOBAL_SHUTTER) == d400_caps::CAP_GLOBAL_SHUTTER)) + { + depth_sensor.register_option(RS2_OPTION_EMITTER_ALWAYS_ON, std::make_shared(*_hw_monitor, &depth_sensor)); + } if (_fw_version >= firmware_version("5.9.15.1")) { diff --git a/src/ds5/ds5-options.cpp b/src/ds5/ds5-options.cpp index 5ee97107be..75adf46b1f 100644 --- a/src/ds5/ds5-options.cpp +++ b/src/ds5/ds5-options.cpp @@ -474,38 +474,38 @@ namespace librealsense return (alt_emitter_name == res); } - emitter_always_on_option::emitter_always_on_option(hw_monitor& hwm, sensor_base* ep) - : _hwm(hwm), _sensor(ep) - { - _range = [this]() - { - return option_range{ 0, 1, 1, 0 }; - }; - } - - void emitter_always_on_option::set(float value) - { - command cmd(ds::LASERONCONST); - cmd.param1 = static_cast(value); - - _hwm.send(cmd); - _record_action(*this); - } - - float emitter_always_on_option::query() const - { - command cmd(ds::LASERONCONST); - cmd.param1 = 2; - - auto res = _hwm.send(cmd); - if (res.empty()) - throw invalid_value_exception("emitter_always_on_option::query result is empty!"); - - return (res.front()); - } - - option_range emitter_always_on_option::get_range() const - { - return *_range; + emitter_always_on_option::emitter_always_on_option(hw_monitor& hwm, sensor_base* ep) + : _hwm(hwm), _sensor(ep) + { + _range = [this]() + { + return option_range{ 0, 1, 1, 0 }; + }; + } + + void emitter_always_on_option::set(float value) + { + command cmd(ds::LASERONCONST); + cmd.param1 = static_cast(value); + + _hwm.send(cmd); + _record_action(*this); + } + + float emitter_always_on_option::query() const + { + command cmd(ds::LASERONCONST); + cmd.param1 = 2; + + auto res = _hwm.send(cmd); + if (res.empty()) + throw invalid_value_exception("emitter_always_on_option::query result is empty!"); + + return (res.front()); + } + + option_range emitter_always_on_option::get_range() const + { + return *_range; } } diff --git a/src/ds5/ds5-options.h b/src/ds5/ds5-options.h index bce90af905..a393449765 100644 --- a/src/ds5/ds5-options.h +++ b/src/ds5/ds5-options.h @@ -273,25 +273,25 @@ namespace librealsense sensor_base* _sensor; }; - class emitter_always_on_option : public option - { - public: - emitter_always_on_option(hw_monitor& hwm, sensor_base* depth_ep); - virtual ~emitter_always_on_option() = default; - virtual void set(float value) override; - virtual float query() const override; - virtual option_range get_range() const override; - virtual bool is_enabled() const override { return true; } - virtual const char* get_description() const override - { - return "Emitter always on mode: 0:disabled(default), 1:enabled."; - } - virtual void enable_recording(std::function record_action) override { _record_action = record_action; } - - private: - std::function _record_action = [](const option&) {}; - lazy _range; - hw_monitor& _hwm; - sensor_base* _sensor; + class emitter_always_on_option : public option + { + public: + emitter_always_on_option(hw_monitor& hwm, sensor_base* depth_ep); + virtual ~emitter_always_on_option() = default; + virtual void set(float value) override; + virtual float query() const override; + virtual option_range get_range() const override; + virtual bool is_enabled() const override { return true; } + virtual const char* get_description() const override + { + return "Emitter always on mode: 0:disabled(default), 1:enabled."; + } + virtual void enable_recording(std::function record_action) override { _record_action = record_action; } + + private: + std::function _record_action = [](const option&) {}; + lazy _range; + hw_monitor& _hwm; + sensor_base* _sensor; }; } From 56b29905bacdc57ddf15610b2654625e12ff9cad Mon Sep 17 00:00:00 2001 From: Dave Tong Date: Mon, 9 Mar 2020 16:45:37 -0700 Subject: [PATCH 3/5] Fixed order. --- src/types.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types.cpp b/src/types.cpp index bb1efba043..f80dac6aa8 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -320,6 +320,7 @@ namespace librealsense CASE(ZERO_ORDER_ENABLED) CASE(ENABLE_MAP_PRESERVATION) CASE(FREEFALL_DETECTION_ENABLED) + CASE(EMITTER_ALWAYS_ON) CASE(AVALANCHE_PHOTO_DIODE) CASE(POST_PROCESSING_SHARPENING) CASE(PRE_PROCESSING_SHARPENING) @@ -327,7 +328,6 @@ namespace librealsense CASE(INVALIDATION_BYPASS) CASE(AMBIENT_LIGHT) CASE(SENSOR_MODE) - CASE(EMITTER_ALWAYS_ON) default: assert(!is_valid(value)); return UNKNOWN_VALUE; } #undef CASE From f9985dde3f00e3a416f143de32d4ee0399219f3b Mon Sep 17 00:00:00 2001 From: Sergey Dorodnicov Date: Tue, 10 Mar 2020 11:21:10 +0200 Subject: [PATCH 4/5] Update Option.java --- .../src/main/java/com/intel/realsense/librealsense/Option.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/android/librealsense/src/main/java/com/intel/realsense/librealsense/Option.java b/wrappers/android/librealsense/src/main/java/com/intel/realsense/librealsense/Option.java index 7d9ce7f053..4837651bc9 100644 --- a/wrappers/android/librealsense/src/main/java/com/intel/realsense/librealsense/Option.java +++ b/wrappers/android/librealsense/src/main/java/com/intel/realsense/librealsense/Option.java @@ -65,7 +65,7 @@ public enum Option { ZERO_ORDER_ENABLED(61), ENABLE_MAP_PRESERVATION(62), FREEFALL_DETECTION_ENABLED(63); - EMITTER_ALWAYS_ON(64); + EMITTER_ALWAYS_ON(64); private final int mValue; From 51db1d53e81b2fe9ae4ad5bb4c7053b14c85cd64 Mon Sep 17 00:00:00 2001 From: Sergey Dorodnicov Date: Tue, 10 Mar 2020 11:21:56 +0200 Subject: [PATCH 5/5] Update option.m --- wrappers/matlab/option.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrappers/matlab/option.m b/wrappers/matlab/option.m index 463754d186..4349458406 100644 --- a/wrappers/matlab/option.m +++ b/wrappers/matlab/option.m @@ -63,8 +63,8 @@ led_power (60) zero_order_enabled (61) enable_map_preservation (62) - FreeFallDetectionEnabled (63) - emitter_always_on (64) + freefall_detection_enabled (63) + emitter_always_on (64) count (65) end end