Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the option to enable laser always on and fixed a minor performanc… #5462

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion common/rendering.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ namespace rs2

float3 normalize() const
{
return (length() > 0)? float3{ x / length(), y / length(), z / length() }:*this;
float len = length();
return (len > 0)? float3{ x / len, y / len, z / len }:*this;
}
};

Expand Down
1 change: 1 addition & 0 deletions include/librealsense2/h/rs_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ extern "C" {
RS2_OPTION_LED_POWER, /**< Power of the LED (light emitting diode), with 0 meaning LED off*/
RS2_OPTION_ZERO_ORDER_ENABLED, /**< Toggle Zero-Order mode */
RS2_OPTION_ENABLE_MAP_PRESERVATION, /**< Preserve previous map when starting */
RS2_OPTION_EMITTER_ALWAYS_ON, /**< Enable Laser On constantly (GS SKU Only) */
RS2_OPTION_COUNT /**< Number of enumeration values. Not a valid input: intended to be used in for-loops. */
} rs2_option;

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 @@ -749,6 +749,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 @@ -474,4 +474,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 @@ -275,4 +275,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 @@ -194,6 +194,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 @@ -290,6 +290,7 @@ namespace librealsense
CASE(LED_POWER)
CASE(ZERO_ORDER_ENABLED)
CASE(ENABLE_MAP_PRESERVATION)
CASE(EMITTER_ALWAYS_ON)
default: assert(!is_valid(value)); return UNKNOWN_VALUE;
}
#undef CASE
Expand Down