Skip to content

Commit

Permalink
Merge pull request #6006 from daversintel/emitter_always_on_with_warp…
Browse files Browse the repository at this point in the history
…pers

Added emmitter always on option and the missing warpper part for free…
  • Loading branch information
dorodnic authored Mar 10, 2020
2 parents 5014b46 + 51db1d5 commit c7c9813
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/librealsense2/h/rs_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
5 changes: 5 additions & 0 deletions src/ds5/ds5-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,11 @@ namespace librealsense
depth_sensor.register_option(RS2_OPTION_EMITTER_ON_OFF, std::make_shared<emitter_on_and_off_option>(*_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<emitter_always_on_option>(*_hw_monitor, &depth_sensor));
}

if (_fw_version >= firmware_version("5.9.15.1"))
{
depth_sensor.register_option(RS2_OPTION_INTER_CAM_SYNC_MODE,
Expand Down
35 changes: 35 additions & 0 deletions src/ds5/ds5-options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,4 +473,39 @@ namespace librealsense
static std::vector<uint8_t> 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<int>(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;
}
}
22 changes: 22 additions & 0 deletions src/ds5/ds5-options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<void(const option &)> record_action) override { _record_action = record_action; }

private:
std::function<void(const option &)> _record_action = [](const option&) {};
lazy<option_range> _range;
hw_monitor& _hwm;
sensor_base* _sensor;
};
}
1 change: 1 addition & 0 deletions src/ds5/ds5-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
1 change: 1 addition & 0 deletions src/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 6 additions & 0 deletions wrappers/csharp/Intel.RealSense/Types/Enums/Option.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,11 @@ public enum Option

/// <summary>Preserve previous map when starting</summary>
EnableMapPreservation = 62,

/// <summary>Enable/disable sensor shutdown when a free-fall is detected (on by default)</summary>
FreeFallDetectionEnabled = 63,

/// <summary>Enable Laser On constantly (GS SKU Only)</summary>
EmitterAlwaysOn = 64,
}
}
4 changes: 3 additions & 1 deletion wrappers/matlab/option.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
led_power (60)
zero_order_enabled (61)
enable_map_preservation (62)
count (63)
freefall_detection_enabled (63)
emitter_always_on (64)
count (65)
end
end
11 changes: 11 additions & 0 deletions wrappers/nodejs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
* <br>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}
Expand Down Expand Up @@ -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');
Expand Down
1 change: 1 addition & 0 deletions wrappers/nodejs/src/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4690,6 +4690,7 @@ void InitModule(v8::Local<v8::Object> 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
Expand Down
1 change: 1 addition & 0 deletions wrappers/python/pybackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_<platform::power_state> power_state(m, "power_state");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c7c9813

Please sign in to comment.