14 _is_config_in_process(false),
15 _has_config_changed(false),
16 _current_hdr_sequence_index(DEFAULT_CURRENT_HDR_SEQUENCE_INDEX),
17 _auto_exposure_to_be_restored(false),
18 _emitter_on_off_to_be_restored(false),
20 _sequence_size(DEFAULT_HDR_SEQUENCE_SIZE),
21 _exposure_range(exposure_range),
22 _gain_range(gain_range),
23 _use_workaround(true),
24 _pre_hdr_exposure(0.
f)
30 bool existing_subpreset_restored =
false;
31 std::vector<byte>
res;
35 if (!existing_subpreset_restored)
40 hdr_params params_0(0, exposure_default_value, gain_default_value);
45 hdr_params params_1(1, exposure_low_value, gain_min_value);
53 bool hdr_enabled_in_device =
false;
58 catch (std::exception ex) {
59 LOG_WARNING(
"In hdr_config::hdr_config() - hw command failed: " << ex.what());
61 return hdr_enabled_in_device;
67 if (current_subpreset.size() > 0)
69 int current_subpreset_id = current_subpreset[1];
77 return id >= 0 &&
id <= 3;
86 const int size_of_subpreset_header = 5;
87 const int size_of_subpreset_item_header = 4;
88 const int size_of_control_id = 1;
89 const int size_of_control_value = 4;
91 int subpreset_size = size_of_subpreset_header + 2 * (size_of_subpreset_item_header +
92 2 * (size_of_control_id + size_of_control_value));
94 if (current_subpreset.size() != subpreset_size)
98 offset += size_of_subpreset_header;
99 offset += size_of_subpreset_item_header;
103 offset += size_of_control_id;
105 = (float)*reinterpret_cast< const uint32_t * >( &( current_subpreset[offset] ) );
106 offset += size_of_control_value;
110 offset += size_of_control_id;
112 = (float)*reinterpret_cast< const uint32_t * >( &( current_subpreset[offset] ) );
113 offset += size_of_control_value;
115 offset += size_of_subpreset_item_header;
119 offset += size_of_control_id;
121 = (float)*reinterpret_cast< const uint32_t * >( &( current_subpreset[offset] ) );
122 offset += size_of_control_value;
126 offset += size_of_control_id;
128 = (float)*reinterpret_cast< const uint32_t * >( &( current_subpreset[offset] ) );
129 offset += size_of_control_value;
145 rv =
static_cast<float>(
_id);
161 catch (std::out_of_range)
171 catch (std::out_of_range)
186 " is out of the option range: [" << range.
min <<
", " << range.
max <<
"].");
255 std::vector<byte>
res;
292 std::this_thread::sleep_for(std::chrono::milliseconds(70));
302 LOG_WARNING(
"HDR failed to restore manual exposure");
363 catch (std::exception ex) {
364 LOG_WARNING(
"In hdr_config::send_sub_preset_to_fw() - hw command failed: " << ex.what());
372 std::vector<uint8_t>
pattern{};
380 catch (std::exception ex) {
381 LOG_WARNING(
"In hdr_config::disable() - hw command failed: " << ex.what());
390 std::vector<uint8_t>
pattern{};
391 if (subpreset_frames_config.size() > 0)
393 pattern.insert(
pattern.end(), &subpreset_header[0], &subpreset_header[0] + subpreset_header.size());
394 pattern.insert(
pattern.end(), &subpreset_frames_config[0], &subpreset_frames_config[0] + subpreset_frames_config.size());
412 std::vector<uint8_t>
header;
413 header.insert(header.end(), &header_size, &header_size + 1);
414 header.insert(header.end(), &
_id, &
_id + 1);
415 header.insert(header.end(), (
uint8_t*)&iterations, (
uint8_t*)&iterations + 2);
416 header.insert(header.end(), &num_of_items, &num_of_items + 1);
430 std::vector<uint8_t> frame_header;
431 frame_header.insert(frame_header.end(), &frame_header_size, &frame_header_size + 1);
432 frame_header.insert(frame_header.end(), (
uint8_t*)&iterations, (
uint8_t*)&iterations + 2);
433 frame_header.insert(frame_header.end(), &num_of_controls, &num_of_controls + 1);
435 std::vector<uint8_t> frames_config;
438 frames_config.insert(frames_config.end(), &frame_header[0], &frame_header[0] + frame_header.size());
442 frames_config.insert(frames_config.end(), (
uint8_t*)&exposure_value, (
uint8_t*)&exposure_value + 4);
446 frames_config.insert(frames_config.end(), (
uint8_t*)&gain_value, (
uint8_t*)&gain_value + 4);
449 return frames_config;
460 int new_id =
static_cast<int>(
value);
470 size_t new_size =
static_cast<size_t>(
value);
471 if (new_size > 3 || new_size < 2)
483 size_t new_index =
static_cast<size_t>(
value);
bool validate_config() const
bool send_sub_preset_to_fw()
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
void restore_options_after_disable()
bool configure_hdr_as_in_fw(const std::vector< byte > ¤t_subpreset)
const char * rs2_option_to_string(rs2_option option)
bool is_current_subpreset_hdr(const std::vector< byte > ¤t_subpreset) const
void set_exposure(float value)
void set_sequence_size(float value)
float get(rs2_option option) const
std_msgs::Header * header(M &m)
returns Header<M>::pointer(m);
void set_sequence_index(float value)
const uint8_t CONTROL_ID_EXPOSURE
std::vector< hdr_params > _hdr_sequence_params
void set_options_to_be_restored_after_disable()
command prepare_hdr_sub_preset_command() const
std::vector< uint8_t > send(std::vector< uint8_t > const &data) const
int _current_hdr_sequence_index
std::vector< uint8_t > prepare_sub_preset_frames_config() const
std::vector< uint8_t > prepare_sub_preset_header() const
std::vector< uint8_t > data
bool _emitter_on_off_to_be_restored
hdr_params & operator=(const hdr_params &other)
bool is_config_in_process() const
std::weak_ptr< sensor_base > _sensor
const int DEFAULT_HDR_SEQUENCE_SIZE
bool _auto_exposure_to_be_restored
void set(rs2_option option, float value, option_range range)
void set_gain(float value)
bool is_hdr_enabled_in_device(std::vector< byte > &result) const
const float PRE_ENABLE_HDR_EXPOSURE
option_range _exposure_range
hdr_config(hw_monitor &hwm, std::shared_ptr< sensor_base > depth_ep, const option_range &exposure_range, const option_range &gain_range)
bool _is_config_in_process
const uint8_t CONTROL_ID_GAIN
void set_enable_status(float value)
bool is_hdr_id(int id) const
std::string to_string(T value)