13 using namespace ivcam2;
28 auto &
ds = _l500_dev->get_depth_sensor();
34 "Alternate IR cannot be enabled with IR Reflectivity" );
50 return query_new_fw_default( success );
54 return query_old_fw_default();
64 std::shared_ptr< digital_gain_option > digital_gain )
65 : _l500_dev( l500_dev )
66 , _hw_monitor( hw_monitor )
68 , _resolution( resolution )
69 , _description( description )
70 , _fw_version( fw_version )
71 , _digital_gain( digital_gain )
72 , _is_read_only(false)
73 , _was_set_manually( false )
82 || step.size() <
sizeof(
int32_t ) )
85 s <<
"Size of data returned is not valid min size = " <<
min.size()
86 <<
", max size = " << max.size() <<
", step size = " << step.size();
87 throw std::runtime_error( s.str() );
90 auto max_value = float( *( reinterpret_cast< int32_t * >( max.data() ) ) );
91 auto min_value = float( *( reinterpret_cast< int32_t * >(
min.data() ) ) );
104 float( *( reinterpret_cast< int32_t * >( step.data() ) ) ),
151 s <<
"hw_monitor AMCGET of " <<
_type <<
" return error " << response;
152 throw std::runtime_error( s.str() );
157 s <<
"Size of data returned from query(get_default) of " <<
_type <<
" is " 158 <<
res.size() <<
" while min size = " <<
sizeof(
int32_t );
159 throw std::runtime_error( s.str() );
180 std::this_thread::sleep_for( std::chrono::milliseconds( 50 ) );
197 s <<
"Size of data returned from query(get_current) of " <<
_type <<
" is " <<
res.size()
198 <<
" while min size = " <<
sizeof(
int32_t );
199 throw std::runtime_error( s.str() );
222 "Change the depth digital gain to: 1 for high gain and 2 for low gain",
223 std::map< float, std::string >{
233 auto default_sensor_mode
236 auto resolution_option = std::make_shared< sensor_mode_option >(
241 default_sensor_mode },
242 "Notify the sensor about the intended streaming mode. Required for preset " );
245 resolution_option->add_observer( [&](
float ) {
263 "Change the depth digital gain to: 1 for high gain and 2 for low gain",
264 std::map< float, std::string >{
274 _alt_ir = std::make_shared< l500_hw_options >(
this,
277 resolution_option.get(),
278 "Enable/Disable alternate IR",
296 resolution_option.get(),
297 "Changes the amount of sharpening in the post-processed image",
312 resolution_option.get(),
313 "Changes the amount of sharpening in the pre-processed image",
327 resolution_option.get(),
328 "Control edges and background noise",
342 resolution_option.get(),
343 "Changes the exposure time of Avalanche Photo Diode in the receiver",
357 resolution_option.get(),
358 "The confidence level threshold to use to mark a " 359 "pixel as valid by the depth algorithm",
373 resolution_option.get(),
374 "Power of the laser emitter, with 0 meaning projector off",
388 resolution_option.get(),
389 "Minimal distance to the target (in mm)",
403 resolution_option.get(),
404 "Enable/disable pixel invalidation",
410 _preset = std::make_shared< l500_preset_option >(
415 "Preset to calibrate the camera to environment ambient, no ambient or low " 419 _preset->set_value( (
float)preset );
430 std::vector<rs2_option>
res;
434 res.push_back(o.first);
452 auto curr = control.second->query();
453 auto def = control.second->get_range().def;
464 if (laser == _hw_options.end())
466 LOG_ERROR(
"RS2_OPTION_LASER_POWER didnt found on hw_options list ");
469 auto max_laser = laser->second->get_range().max;
470 auto def_laser = laser->second->get_range().def;
473 gain_and_laser_to_preset = {
481 auto laser_val = laser->second->query();
483 auto it = gain_and_laser_to_preset.find( { gain, laser_val } );
485 if(
it != gain_and_laser_to_preset.end() )
494 LOG_ERROR(
"Exception caught in calc_preset_from_controls" );
506 if( static_cast< rs2_l500_visual_preset >(
int( value ) )
509 <<
"RS2_L500_VISUAL_PRESET_DEFAULT was deprecated!" );
535 <<
"Visual Preset cannot be changed while Max Usable Range is enabled" );
541 auto advanced_controls = get_advanced_controls();
542 if(
std::find( advanced_controls.begin(), advanced_controls.end(), opt )
543 != advanced_controls.end() )
552 _hw_options[opt]->set_manually(
true );
556 to_string() <<
"on_set_option support advanced controls only " << opt
621 change_gain( preset );
622 change_alt_ir( preset );
625 set_preset_controls_to_defaults();
627 change_laser_power( preset );
633 _preset->set_value( (
float)preset );
638 for(
auto & o : _hw_options )
640 if( ! o.second->is_read_only() )
642 auto val = o.second->get_range().def;
643 o.second->set_with_no_signal(
val );
644 o.second->set_manually(
false );
658 for (
auto& o : _hw_options)
659 if (!o.second->is_read_only())
661 o.second->set_with_no_signal(-1);
681 std::map< rs2_option, float > defaults;
684 for (
auto opt : _hw_options)
687 defaults[opt.first] = opt.second->query_new_fw_default(success);
691 defaults[opt.first] = -1;
692 opt.second->set_read_only(
true);
695 opt.second->set_read_only(
false);
706 std::map< rs2_option, float > currents;
707 for (
auto opt : _hw_options)
712 if (get_depth_sensor().is_streaming())
713 std::this_thread::sleep_for(std::chrono::milliseconds(50));
715 for (
auto opt : _hw_options)
717 opt.second->set_with_no_signal(-1);
721 for (
auto opt : currents)
723 _hw_options[opt.first]->set_with_no_signal(opt.second);
727 for (
auto opt : _hw_options)
729 opt.second->set_default(defaults[opt.first]);
737 auto&
ds = _l500_depth_dev->get_depth_sensor();
744 bool visual_preset_is_max_range =
ds.is_max_range_preset();
746 if (
ds.is_streaming())
748 if (!sensor_mode_is_vga || !visual_preset_is_max_range)
753 if (!visual_preset_is_max_range)
760 if (!sensor_mode_is_vga)
772 LOG_INFO(
"IR Reflectivity was on - turning it off");
781 if (
_value == value)
return;
784 auto &
ds = _l500_depth_dev->get_depth_sensor();
791 LOG_INFO(
"IR Reflectivity was on - turning it off" );
799 LOG_INFO(
"Max Usable Range was on - turning it off" );
811 return "Max Usable Range calculates the maximum range of the camera given the amount of " 812 "ambient light in the scene.\n" 813 "For example, if Max Usable Range returns 5m, this means that the ambient light in " 814 "the scene is reducing the maximum range from 9m down to 5m.\n" 815 "Values are between 1.5 and 9 meters, in 1.5m increments. " 816 "Max range refers to the center 10% of the frame.";
822 auto &
ds = _l500_depth_dev->get_depth_sensor();
836 bool visual_preset_is_max_range =
ds.is_max_range_preset();
838 if(
ds.is_streaming() )
843 auto active_streams =
ds.get_active_streams();
844 auto dp = std::find_if( active_streams.begin(),
845 active_streams.end(),
846 []( std::shared_ptr< stream_profile_interface > sp ) {
850 bool vga_sensor_mode =
false;
851 if(
dp != active_streams.end() )
859 if( ( ! vga_sensor_mode ) || ! visual_preset_is_max_range )
861 "Please set 'VGA' resolution, 'Max Range' preset and 20% ROI before enabling IR Reflectivity" );
865 if (!visual_preset_is_max_range)
872 if (!sensor_mode_is_vga)
880 if (max_usable_range_option.query() != 1.0f)
882 max_usable_range_option.set(1.0
f);
883 _max_usable_range_forced_on =
true;
884 LOG_INFO(
"Max Usable Range was off - turning it on");
889 if (_max_usable_range_forced_on)
891 _max_usable_range_forced_on =
false;
896 LOG_INFO(
"Max Usable Range was on - turning it off");
907 return "IR Reflectivity Tool calculates the percentage of IR light reflected by the " 908 "object and returns to the camera for processing.\nFor example, a value of 60% means " 909 "that 60% of the IR light projected by the camera is reflected by the object and returns " 911 "Note: only active on 2D view, Visual Preset:Max Range, Resolution:VGA, ROI:20%";
931 work_around_for_old_fw();
rs2_sensor_mode get_resolution_from_width_height(int width, int height)
std::shared_ptr< hw_monitor > _hw_monitor
void set(float value) override
const char * get_value_description(float val) const override
const std::string MIN_GET_DEFAULT_FW_VERSION("1.5.4.0")
void set(float value) override
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
option_range get_range() const override
rs2_l500_visual_preset calc_preset_from_controls() const
void set_default(float def)
float query_current(rs2_sensor_mode mode) const
l500_options(std::shared_ptr< context > ctx, const platform::backend_device_group &group)
l500_hw_options(l500_device *l500_dev, hw_monitor *hw_monitor, l500_control type, option *resolution, const std::string &description, firmware_version fw_version, std::shared_ptr< digital_gain_option > digital_gain)
void set(float value) override
option_range get_range() const override
void change_gain(rs2_l500_visual_preset preset)
void set_preset_value(rs2_l500_visual_preset preset)
const uint8_t L500_DIGITAL_GAIN
void change_preset(rs2_l500_visual_preset preset)
l500_preset_option(option_range range, std::string description, l500_options *owner)
void change_alt_ir(rs2_l500_visual_preset preset)
std::vector< rs2_option > _advanced_options
bool supports_option(rs2_option id) const override
GLsizei const GLchar *const * string
void set_preset_controls_to_defaults()
platform::usb_spec _usb_mode
option & get_option(rs2_option id) override
virtual float query() const =0
std::vector< rs2_option > get_advanced_controls()
void set(float value) override
firmware_version _fw_version
void set(float value) override
void set(float value) override
const std::string MIN_CONTROLS_FW_VERSION("1.3.9.0")
void work_around_for_old_fw()
void verify_max_usable_range_restrictions(rs2_option opt, float value)
std::vector< uint8_t > send(std::vector< uint8_t > const &data) const
float query() const override
void set(float value) override
rs2_sensor_mode query_sensor_mode(option &resolution)
l500_depth_sensor & get_depth_sensor()
void set_by_preset(float value)
float query_new_fw_default(bool &success) const
std::shared_ptr< cascade_option< T > > register_option(rs2_option opt, Args...args)
void set_manually(bool set)
float query_default(bool &success) const
uvc_sensor & get_raw_depth_sensor()
float query() const override
void reset_hw_controls(rs2::device &dev)
bool is_streaming() const override
void set_read_only(bool read_only)
rs2_sensor_mode
For setting the camera_mode option.
std::shared_ptr< l500_hw_options > _alt_ir
LOG_INFO("Log message using LOG_INFO()")
std::shared_ptr< digital_gain_option > _digital_gain
void set(float value) override
void on_set_option(rs2_option opt, float value)
std::map< rs2_option, std::shared_ptr< cascade_option< l500_hw_options > > > _hw_options
rs2_digital_gain
digital gain for RS2_OPTION_DIGITAL_GAIN option.
const char * get_description() const override
auto group_multiple_fw_calls(synthetic_sensor &s, T action) -> decltype(action())
float query_old_fw_default() const
void set_value(float value)
const char * get_description() const override
void enable_recording(std::function< void(const option &)> recording_action) override
const platform::extension_unit depth_xu
std::shared_ptr< l500_preset_option > _preset
option_range get_range() const override
void change_laser_power(rs2_l500_visual_preset preset)
std::string to_string(T value)
rs2_l500_visual_preset
For L500 devices: provides optimized settings (presets) for specific types of usage.