From 0d72af330224c431971a3280099fce249012d3ce Mon Sep 17 00:00:00 2001 From: ohadmeir Date: Thu, 29 Sep 2022 14:25:09 +0300 Subject: [PATCH 1/3] Fix DSO-18454 laser turned off after calibration --- common/on-chip-calib.cpp | 45 +++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/common/on-chip-calib.cpp b/common/on-chip-calib.cpp index 8e871b38f4..f2648e3ba3 100644 --- a/common/on-chip-calib.cpp +++ b/common/on-chip-calib.cpp @@ -400,17 +400,6 @@ namespace rs2 bool frame_arrived = false; try { - if (_sub->s->supports(RS2_OPTION_EMITTER_ENABLED)) - { - laser_status_prev = _sub->s->get_option(RS2_OPTION_EMITTER_ENABLED); - _sub->s->set_option(RS2_OPTION_EMITTER_ENABLED, 0.0f); - } - if (_sub->s->supports(RS2_OPTION_THERMAL_COMPENSATION)) - { - thermal_loop_prev = _sub->s->get_option(RS2_OPTION_THERMAL_COMPENSATION); - _sub->s->set_option(RS2_OPTION_THERMAL_COMPENSATION, 0.f); - } - bool run_fl_calib = ( (action == RS2_CALIB_ACTION_FL_CALIB) && (w == 1280) && (h == 720)); if (action == RS2_CALIB_ACTION_TARE_GROUND_TRUTH) { @@ -1139,6 +1128,18 @@ namespace rs2 { try { + //Save options that are going to change during the calibration + if (_sub->s->supports( RS2_OPTION_EMITTER_ENABLED )) + { + laser_status_prev = _sub->s->get_option( RS2_OPTION_EMITTER_ENABLED ); + _sub->s->set_option( RS2_OPTION_EMITTER_ENABLED, 0.0f ); + } + if (_sub->s->supports( RS2_OPTION_THERMAL_COMPENSATION )) + { + thermal_loop_prev = _sub->s->get_option( RS2_OPTION_THERMAL_COMPENSATION ); + _sub->s->set_option( RS2_OPTION_THERMAL_COMPENSATION, 0.f ); + } + if (action == RS2_CALIB_ACTION_FL_CALIB) calibrate_fl(); else if (action == RS2_CALIB_ACTION_UVMAPPING_CALIB) @@ -1160,8 +1161,21 @@ namespace rs2 _sub_color->ui = *_ui_color; _ui_color.reset(); } + + //Restore options that were changed during the calibration. + //When calibration is successful options are restored in autocalib_notification_model::draw_content() + if (_sub->s->supports( RS2_OPTION_EMITTER_ENABLED )) + { + _sub->s->set_option( RS2_OPTION_EMITTER_ENABLED, laser_status_prev ); + } + if (_sub->s->supports( RS2_OPTION_THERMAL_COMPENSATION )) + { + _sub->s->set_option( RS2_OPTION_THERMAL_COMPENSATION, thermal_loop_prev ); + } + if (_was_streaming) start_viewer(0, 0, 0, invoke); + throw; } } @@ -1985,12 +1999,19 @@ namespace rs2 } else if (update_state == RS2_CALIB_STATE_CALIB_COMPLETE) { + if (get_manager().action == on_chip_calib_manager::RS2_CALIB_ACTION_ON_CHIP_CALIB) + { + if (get_manager()._sub->s->supports( RS2_OPTION_EMITTER_ENABLED )) + get_manager()._sub->s->set_option( RS2_OPTION_EMITTER_ENABLED, get_manager().laser_status_prev ); + if (get_manager()._sub->s->supports( RS2_OPTION_THERMAL_COMPENSATION )) + get_manager()._sub->s->set_option( RS2_OPTION_THERMAL_COMPENSATION, get_manager().thermal_loop_prev ); + } if (get_manager().action == on_chip_calib_manager::RS2_CALIB_ACTION_UVMAPPING_CALIB) { if (get_manager()._sub->s->supports(RS2_OPTION_EMITTER_ENABLED)) get_manager()._sub->s->set_option(RS2_OPTION_EMITTER_ENABLED, get_manager().laser_status_prev); if (get_manager()._sub->s->supports(RS2_OPTION_THERMAL_COMPENSATION)) - get_manager()._sub->s->set_option(RS2_OPTION_THERMAL_COMPENSATION, get_manager().laser_status_prev); + get_manager()._sub->s->set_option(RS2_OPTION_THERMAL_COMPENSATION, get_manager().thermal_loop_prev); ImGui::SetCursorScreenPos({ float(x + 20), float(y + 33) }); ImGui::Text("%s", "Health-Check Number for PX: "); From e6977b96e206d200cdaa4ca5be2385f2a5315d25 Mon Sep 17 00:00:00 2001 From: ohadmeir Date: Tue, 18 Oct 2022 12:52:13 +0300 Subject: [PATCH 2/3] Updated according to DSO-18454 requirements --- common/on-chip-calib.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/common/on-chip-calib.cpp b/common/on-chip-calib.cpp index f2648e3ba3..7c19044f6b 100644 --- a/common/on-chip-calib.cpp +++ b/common/on-chip-calib.cpp @@ -412,7 +412,6 @@ namespace rs2 break; } } - } else if (action == RS2_CALIB_ACTION_UVMAPPING_CALIB) { @@ -1122,8 +1121,23 @@ namespace rs2 else try_start_viewer(256, 144, 90, invoke); - if (action == RS2_CALIB_ACTION_TARE_GROUND_TRUTH) + if ( action == RS2_CALIB_ACTION_TARE_GROUND_TRUTH ) + { + //Laser should be turned off during ground truth calculation + if ( _sub->s->supports( RS2_OPTION_EMITTER_ENABLED ) ) + { + laser_status_prev = _sub->s->get_option( RS2_OPTION_EMITTER_ENABLED ); + _sub->s->set_option( RS2_OPTION_EMITTER_ENABLED, 0.0f ); + } + get_ground_truth(); + + //Restore laser + if ( _sub->s->supports( RS2_OPTION_EMITTER_ENABLED ) ) + { + _sub->s->set_option( RS2_OPTION_EMITTER_ENABLED, laser_status_prev ); + } + } else { try @@ -1132,7 +1146,7 @@ namespace rs2 if (_sub->s->supports( RS2_OPTION_EMITTER_ENABLED )) { laser_status_prev = _sub->s->get_option( RS2_OPTION_EMITTER_ENABLED ); - _sub->s->set_option( RS2_OPTION_EMITTER_ENABLED, 0.0f ); + _sub->s->set_option( RS2_OPTION_EMITTER_ENABLED, 1.0f ); } if (_sub->s->supports( RS2_OPTION_THERMAL_COMPENSATION )) { @@ -1999,7 +2013,8 @@ namespace rs2 } else if (update_state == RS2_CALIB_STATE_CALIB_COMPLETE) { - if (get_manager().action == on_chip_calib_manager::RS2_CALIB_ACTION_ON_CHIP_CALIB) + if (get_manager().action == on_chip_calib_manager::RS2_CALIB_ACTION_ON_CHIP_CALIB || + get_manager().action == on_chip_calib_manager::RS2_CALIB_ACTION_TARE_CALIB ) { if (get_manager()._sub->s->supports( RS2_OPTION_EMITTER_ENABLED )) get_manager()._sub->s->set_option( RS2_OPTION_EMITTER_ENABLED, get_manager().laser_status_prev ); From 7f270f2146089f0ca7ea7abf8651336d2fb98a29 Mon Sep 17 00:00:00 2001 From: ohadmeir Date: Thu, 27 Oct 2022 10:24:08 +0300 Subject: [PATCH 3/3] Use options_model::set_option to update GUI during calibration --- common/on-chip-calib.cpp | 52 +++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/common/on-chip-calib.cpp b/common/on-chip-calib.cpp index 7c19044f6b..b1b40a786c 100644 --- a/common/on-chip-calib.cpp +++ b/common/on-chip-calib.cpp @@ -1124,18 +1124,21 @@ namespace rs2 if ( action == RS2_CALIB_ACTION_TARE_GROUND_TRUTH ) { //Laser should be turned off during ground truth calculation - if ( _sub->s->supports( RS2_OPTION_EMITTER_ENABLED ) ) + //Use options_model::set_option to update GUI after change + std::string ignored_error_message { "" }; + auto it = _sub->options_metadata.find( RS2_OPTION_EMITTER_ENABLED ); + if ( it != _sub->options_metadata.end() ) //Option supported { laser_status_prev = _sub->s->get_option( RS2_OPTION_EMITTER_ENABLED ); - _sub->s->set_option( RS2_OPTION_EMITTER_ENABLED, 0.0f ); + it->second.set_option( RS2_OPTION_EMITTER_ENABLED, 0.0f, ignored_error_message ); } get_ground_truth(); //Restore laser - if ( _sub->s->supports( RS2_OPTION_EMITTER_ENABLED ) ) + if ( it != _sub->options_metadata.end() ) //Option supported { - _sub->s->set_option( RS2_OPTION_EMITTER_ENABLED, laser_status_prev ); + it->second.set_option( RS2_OPTION_EMITTER_ENABLED, laser_status_prev, ignored_error_message ); } } else @@ -1143,15 +1146,19 @@ namespace rs2 try { //Save options that are going to change during the calibration - if (_sub->s->supports( RS2_OPTION_EMITTER_ENABLED )) + //Use options_model::set_option to update GUI after change + std::string ignored_error_message { "" }; + auto it = _sub->options_metadata.find( RS2_OPTION_EMITTER_ENABLED ); + if ( it != _sub->options_metadata.end() ) //Option supported { laser_status_prev = _sub->s->get_option( RS2_OPTION_EMITTER_ENABLED ); - _sub->s->set_option( RS2_OPTION_EMITTER_ENABLED, 1.0f ); + it->second.set_option( RS2_OPTION_EMITTER_ENABLED, 1.0f, ignored_error_message ); } - if (_sub->s->supports( RS2_OPTION_THERMAL_COMPENSATION )) + it = _sub->options_metadata.find( RS2_OPTION_THERMAL_COMPENSATION ); + if ( it != _sub->options_metadata.end() ) //Option supported { thermal_loop_prev = _sub->s->get_option( RS2_OPTION_THERMAL_COMPENSATION ); - _sub->s->set_option( RS2_OPTION_THERMAL_COMPENSATION, 0.f ); + it->second.set_option( RS2_OPTION_THERMAL_COMPENSATION, 0.0f, ignored_error_message ); } if (action == RS2_CALIB_ACTION_FL_CALIB) @@ -1178,13 +1185,17 @@ namespace rs2 //Restore options that were changed during the calibration. //When calibration is successful options are restored in autocalib_notification_model::draw_content() - if (_sub->s->supports( RS2_OPTION_EMITTER_ENABLED )) + //Use options_model::set_option to update GUI after change + std::string ignored_error_message { "" }; + auto it = _sub->options_metadata.find( RS2_OPTION_EMITTER_ENABLED ); + if ( it != _sub->options_metadata.end() ) //Option supported { - _sub->s->set_option( RS2_OPTION_EMITTER_ENABLED, laser_status_prev ); + it->second.set_option( RS2_OPTION_EMITTER_ENABLED, laser_status_prev, ignored_error_message ); } - if (_sub->s->supports( RS2_OPTION_THERMAL_COMPENSATION )) + it = _sub->options_metadata.find( RS2_OPTION_THERMAL_COMPENSATION ); + if ( it != _sub->options_metadata.end() ) //Option supported { - _sub->s->set_option( RS2_OPTION_THERMAL_COMPENSATION, thermal_loop_prev ); + it->second.set_option( RS2_OPTION_THERMAL_COMPENSATION, thermal_loop_prev, ignored_error_message ); } if (_was_streaming) @@ -2016,10 +2027,19 @@ namespace rs2 if (get_manager().action == on_chip_calib_manager::RS2_CALIB_ACTION_ON_CHIP_CALIB || get_manager().action == on_chip_calib_manager::RS2_CALIB_ACTION_TARE_CALIB ) { - if (get_manager()._sub->s->supports( RS2_OPTION_EMITTER_ENABLED )) - get_manager()._sub->s->set_option( RS2_OPTION_EMITTER_ENABLED, get_manager().laser_status_prev ); - if (get_manager()._sub->s->supports( RS2_OPTION_THERMAL_COMPENSATION )) - get_manager()._sub->s->set_option( RS2_OPTION_THERMAL_COMPENSATION, get_manager().thermal_loop_prev ); + //Restore options that were changed during the calibration. + //Use options_model::set_option to update GUI after change + std::string ignored_error_message { "" }; + auto it = get_manager()._sub->options_metadata.find( RS2_OPTION_EMITTER_ENABLED ); + if ( it != get_manager()._sub->options_metadata.end() ) //Option supported + { + it->second.set_option( RS2_OPTION_EMITTER_ENABLED, get_manager().laser_status_prev, ignored_error_message ); + } + it = get_manager()._sub->options_metadata.find( RS2_OPTION_THERMAL_COMPENSATION ); + if ( it != get_manager()._sub->options_metadata.end() ) //Option supported + { + it->second.set_option( RS2_OPTION_THERMAL_COMPENSATION, get_manager().thermal_loop_prev, ignored_error_message ); + } } if (get_manager().action == on_chip_calib_manager::RS2_CALIB_ACTION_UVMAPPING_CALIB) {