From 9ce7fded26d9ce8a51887dc9d5c30f06f4e713a5 Mon Sep 17 00:00:00 2001 From: Eran Date: Thu, 27 Jul 2023 10:16:54 +0300 Subject: [PATCH 01/16] bump to 2.54.2 --- include/librealsense2/rs.h | 2 +- package.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/librealsense2/rs.h b/include/librealsense2/rs.h index 1066bd566c..3336f3a3d8 100644 --- a/include/librealsense2/rs.h +++ b/include/librealsense2/rs.h @@ -25,7 +25,7 @@ extern "C" { #define RS2_API_MAJOR_VERSION 2 #define RS2_API_MINOR_VERSION 54 -#define RS2_API_PATCH_VERSION 1 +#define RS2_API_PATCH_VERSION 2 #define RS2_API_BUILD_VERSION 0 #ifndef STRINGIFY diff --git a/package.xml b/package.xml index d3791f90d8..026e0aa5ab 100644 --- a/package.xml +++ b/package.xml @@ -7,7 +7,7 @@ librealsense2 - 2.54.1 + 2.54.2 Library for controlling and capturing data from the Intel(R) RealSense(TM) D400 devices. From 76819b876e76567fc44cfce40dc42be49242c869 Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Sun, 6 Aug 2023 15:27:54 +0300 Subject: [PATCH 02/16] Close laser emitter on Focal Length calibration --- common/on-chip-calib.cpp | 205 +++++++++++++++++---------------------- common/on-chip-calib.h | 16 ++- 2 files changed, 99 insertions(+), 122 deletions(-) diff --git a/common/on-chip-calib.cpp b/common/on-chip-calib.cpp index 6e852e1eae..d51c0c0539 100644 --- a/common/on-chip-calib.cpp +++ b/common/on-chip-calib.cpp @@ -16,16 +16,20 @@ #include "../src/algo.h" #include "../tools/depth-quality/depth-metrics.h" + +static constexpr float off_value = 0.0f; +static constexpr float on_value = 1.0f; + namespace rs2 { on_chip_calib_manager::on_chip_calib_manager(viewer_model& viewer, std::shared_ptr sub, device_model& model, device dev, std::shared_ptr sub_color, bool uvmapping_calib_full) : process_manager("On-Chip Calibration"), _model(model), _dev(dev), _sub(sub), _viewer(viewer), _sub_color(sub_color), py_px_only(!uvmapping_calib_full) { - device_id_string = "Unknown"; + device_name_string = "Unknown"; if (dev.supports(RS2_CAMERA_INFO_PRODUCT_ID)) { - device_id_string = _dev.get_info(RS2_CAMERA_INFO_PRODUCT_ID); - if (val_in_range(device_id_string, { std::string("0AD3") })) + device_name_string = _dev.get_info( RS2_CAMERA_INFO_NAME ); + if( val_in_range( device_name_string, { std::string( "Intel RealSense D415" ) } ) ) speed = 4; } if (dev.supports(RS2_CAMERA_INFO_FIRMWARE_VERSION)) @@ -69,6 +73,56 @@ namespace rs2 _sub_color->algo_roi = { 0, 0, 0, 0 }; } } + + void on_chip_calib_manager::save_laser_emitter_state() + { + 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 ); + } + } + + void on_chip_calib_manager::save_thermal_loop_state() + { + auto 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 ); + } + } + + void on_chip_calib_manager::restore_laser_emitter_state() + { + set_laser_emitter_state( laser_status_prev ); + } + + void on_chip_calib_manager::restore_thermal_loop_state() + { + set_thermal_loop_state( thermal_loop_prev ); + } + + void on_chip_calib_manager::set_laser_emitter_state( float value ) + { + // 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 + { + it->second.set_option( RS2_OPTION_EMITTER_ENABLED, value, ignored_error_message ); + } + } + + void on_chip_calib_manager::set_thermal_loop_state( float value ) + { + // Use options_model::set_option to update GUI after change + std::string ignored_error_message{ "" }; + auto it = _sub->options_metadata.find( RS2_OPTION_THERMAL_COMPENSATION ); + if( it != _sub->options_metadata.end() ) // Option supported + { + it->second.set_option( RS2_OPTION_THERMAL_COMPENSATION, value, ignored_error_message ); + } + } void on_chip_calib_manager::stop_viewer(invoker invoke) { @@ -406,12 +460,6 @@ namespace rs2 bool frame_arrived = false; try { - 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) { @@ -468,10 +516,9 @@ namespace rs2 break; } - if (_sub->s->supports(RS2_OPTION_EMITTER_ENABLED)) - _sub->s->set_option(RS2_OPTION_EMITTER_ENABLED, 0.0f); - if (_sub->s->supports(RS2_OPTION_THERMAL_COMPENSATION)) - _sub->s->set_option(RS2_OPTION_THERMAL_COMPENSATION, 0.f); + // TODO - When implementing UV mapping calibration - should remove from here and handle in process_flow() + set_laser_emitter_state( off_value ); + set_thermal_loop_state( off_value ); } else if (action == RS2_CALIB_ACTION_UVMAPPING_CALIB) { @@ -516,8 +563,8 @@ namespace rs2 break; } - if (_sub->s->supports(RS2_OPTION_EMITTER_ENABLED)) - _sub->s->set_option(RS2_OPTION_EMITTER_ENABLED, 0.0f); + // TODO - When implementing UV mapping calibration - should remove from here and handle in process_flow() + set_laser_emitter_state( off_value ); } else if (action == RS2_CALIB_ACTION_FL_PLUS_CALIB) { @@ -553,8 +600,8 @@ namespace rs2 break; } - if (_sub->s->supports(RS2_OPTION_EMITTER_ENABLED)) - _sub->s->set_option(RS2_OPTION_EMITTER_ENABLED, 0.0f); + // TODO - When implementing FL plus calibration - should remove from here and handle in process_flow() + set_laser_emitter_state( off_value ); } else if (run_fl_calib) { @@ -577,11 +624,6 @@ namespace rs2 } } } - - if (_sub->s->supports(RS2_OPTION_EMITTER_ENABLED)) - _sub->s->set_option(RS2_OPTION_EMITTER_ENABLED, 0.0f); - if (_sub->s->supports(RS2_OPTION_THERMAL_COMPENSATION)) - _sub->s->set_option(RS2_OPTION_THERMAL_COMPENSATION, 0.f); } else { @@ -1423,43 +1465,30 @@ namespace rs2 if ( action == RS2_CALIB_ACTION_TARE_GROUND_TRUTH ) { - //Laser should be turned off during ground truth calculation - //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 ); - it->second.set_option( RS2_OPTION_EMITTER_ENABLED, 0.0f, ignored_error_message ); - } + // Laser should be turned off during ground truth calculation + save_laser_emitter_state(); + set_laser_emitter_state( off_value ); get_ground_truth(); - //Restore laser - if ( it != _sub->options_metadata.end() ) //Option supported - { - it->second.set_option( RS2_OPTION_EMITTER_ENABLED, laser_status_prev, ignored_error_message ); - } + restore_laser_emitter_state(); } else { try { - //Save options that are going to change during the calibration - //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 ); - it->second.set_option( RS2_OPTION_EMITTER_ENABLED, 1.0f, ignored_error_message ); - } - 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 ); - it->second.set_option( RS2_OPTION_THERMAL_COMPENSATION, 0.0f, ignored_error_message ); - } + // Save options that are going to change during the calibration + save_laser_emitter_state(); + save_thermal_loop_state(); + + // Emitter on by default, off for FL calib and for D415 model + float emitter_value = on_value; + if( action == RS2_CALIB_ACTION_FL_CALIB || device_name_string == std::string( "Intel RealSense D415" ) ) + emitter_value = off_value; + set_laser_emitter_state( emitter_value ); + + // Thermal loop should be off during calibration as to not change calibration tables during calibration + set_thermal_loop_state( off_value ); if (action == RS2_CALIB_ACTION_FL_CALIB) calibrate_fl(); @@ -1467,6 +1496,9 @@ namespace rs2 calibrate_uv_mapping(); else calibrate(); + + restore_laser_emitter_state(); + restore_thermal_loop_state(); } catch (...) { @@ -1485,18 +1517,8 @@ namespace rs2 //Restore options that were changed during the calibration. //When calibration is successful options are restored in autocalib_notification_model::draw_content() - //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 - { - it->second.set_option( RS2_OPTION_EMITTER_ENABLED, laser_status_prev, ignored_error_message ); - } - it = _sub->options_metadata.find( RS2_OPTION_THERMAL_COMPENSATION ); - if ( it != _sub->options_metadata.end() ) //Option supported - { - it->second.set_option( RS2_OPTION_THERMAL_COMPENSATION, thermal_loop_prev, ignored_error_message ); - } + restore_laser_emitter_state(); + restore_thermal_loop_state(); if (_was_streaming) start_viewer(0, 0, 0, invoke); @@ -1851,10 +1873,6 @@ namespace rs2 { get_manager().action = on_chip_calib_manager::RS2_CALIB_ACTION_TARE_CALIB; update_state = update_state_prev; - 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); get_manager().stop_viewer(); } @@ -1891,10 +1909,6 @@ namespace rs2 { get_manager().action = on_chip_calib_manager::RS2_CALIB_ACTION_TARE_CALIB; update_state = update_state_prev; - 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); } else if (update_state == RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH_FAILED) { @@ -2061,11 +2075,6 @@ namespace rs2 if (ImGui::Button(get_button_name.c_str(), { 42.0f, 20.f })) { - if (get_manager()._sub->s->supports(RS2_OPTION_EMITTER_ENABLED)) - get_manager().laser_status_prev = get_manager()._sub->s->get_option(RS2_OPTION_EMITTER_ENABLED); - if (get_manager()._sub->s->supports(RS2_OPTION_THERMAL_COMPENSATION)) - get_manager().thermal_loop_prev = get_manager()._sub->s->get_option(RS2_OPTION_THERMAL_COMPENSATION); - update_state_prev = update_state; update_state = RS2_CALIB_STATE_GET_TARE_GROUND_TRUTH; get_manager().start_gt_viewer(); @@ -2074,7 +2083,7 @@ namespace rs2 ImGui::SetTooltip("%s", "Calculate ground truth for the specific target"); ImGui::SetCursorScreenPos({ float(x + 9), float(y + height - ImGui::GetTextLineHeightWithSpacing() - 30) }); - get_manager().host_assistance = (get_manager().device_id_string == std::string("ABCD") ); // To be used for MIPI SKU only + get_manager().host_assistance = (get_manager().device_name_string == std::string("Intel RealSense D457") ); // To be used for MIPI SKU only bool assistance = (get_manager().host_assistance != 0); if (ImGui::Checkbox("Host Assistance", &assistance)) get_manager().host_assistance = (assistance ? 1 : 0); @@ -2170,7 +2179,7 @@ namespace rs2 // ImGui::SetTooltip("%s", "On-Chip Calibration Extended"); ImGui::SetCursorScreenPos({ float(x + 9), float(y + height - ImGui::GetTextLineHeightWithSpacing() - 31) }); - get_manager().host_assistance = (get_manager().device_id_string == std::string("ABCD") ); // To be used for MIPI SKU only + get_manager().host_assistance = (get_manager().device_name_string == std::string("Intel RealSense D457") ); // To be used for MIPI SKU only bool assistance = (get_manager().host_assistance != 0); ImGui::Checkbox("Host Assistance", &assistance); if (ImGui::IsItemHovered()) @@ -2269,11 +2278,6 @@ namespace rs2 ImGui::SetCursorScreenPos({ float(x + 5), float(y + height - 25) }); if (ImGui::Button(button_name.c_str(), { float(bar_width), 20.f })) { - if (get_manager()._sub->s->supports(RS2_OPTION_EMITTER_ENABLED)) - get_manager().laser_status_prev = get_manager()._sub->s->get_option(RS2_OPTION_EMITTER_ENABLED); - if (get_manager()._sub->s->supports(RS2_OPTION_THERMAL_COMPENSATION)) - get_manager().thermal_loop_prev = get_manager()._sub->s->get_option(RS2_OPTION_THERMAL_COMPENSATION); - get_manager().restore_workspace([this](std::function a) { a(); }); get_manager().reset(); get_manager().retry_times = 0; @@ -2345,30 +2349,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 || - get_manager().action == on_chip_calib_manager::RS2_CALIB_ACTION_TARE_CALIB ) - { - //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) { - 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); - ImGui::SetCursorScreenPos({ float(x + 20), float(y + 33) }); ImGui::Text("%s", "Health-Check Number for PX: "); @@ -2453,14 +2435,6 @@ namespace rs2 } else { - if (get_manager().action == on_chip_calib_manager::RS2_CALIB_ACTION_FL_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); - } - auto health = get_manager().get_health(); auto recommend_keep = fabs(health) < 0.25f; @@ -2851,11 +2825,6 @@ namespace rs2 ImGui::SetCursorScreenPos({ float(x + 5), float(y + height - 25) }); if (ImGui::Button(button_name.c_str(), { scale * 3, 20.f })) { - if (get_manager()._sub->s->supports(RS2_OPTION_EMITTER_ENABLED)) - get_manager().laser_status_prev = get_manager()._sub->s->get_option(RS2_OPTION_EMITTER_ENABLED); - if (get_manager()._sub->s->supports(RS2_OPTION_THERMAL_COMPENSATION)) - get_manager().thermal_loop_prev = get_manager()._sub->s->get_option(RS2_OPTION_THERMAL_COMPENSATION); - get_manager().restore_workspace([this](std::function a) { a(); }); get_manager().reset(); get_manager().retry_times = 0; diff --git a/common/on-chip-calib.h b/common/on-chip-calib.h index 5f31f95ceb..efbda26c88 100644 --- a/common/on-chip-calib.h +++ b/common/on-chip-calib.h @@ -72,8 +72,6 @@ namespace rs2 auto_calib_action action = RS2_CALIB_ACTION_ON_CHIP_CALIB; int host_assistance = 0; int step_count_v3 = 256; - float laser_status_prev = 0.0f; - float thermal_loop_prev = 0.f; int fl_step_count = 51; int fy_scan_range = 40; @@ -103,8 +101,7 @@ namespace rs2 const std::string Y8_FORMAT = "Y8"; const std::string Z16_FORMAT = "Z16"; const std::string RGB8_FORMAT = "RGB8"; - std::string device_id_string; - + std::string device_name_string; void calibrate(); void calibrate_fl(); @@ -115,6 +112,13 @@ namespace rs2 void turn_roi_on(); void turn_roi_off(); + void save_laser_emitter_state(); + void save_thermal_loop_state(); + void restore_laser_emitter_state(); + void restore_thermal_loop_state(); + void set_laser_emitter_state( float value ); + void set_thermal_loop_state( float value ); + void start_gt_viewer(); void start_fl_viewer(); void start_uvmapping_viewer(bool b3D = false); @@ -137,6 +141,10 @@ namespace rs2 device _dev; + + float laser_status_prev = 0.0f; + float thermal_loop_prev = 0.0f; + bool _was_streaming = false; bool _synchronized = false; bool _post_processing = false; From 6088b0858b7c79a9ad5d61f56905181442e4b171 Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Sun, 6 Aug 2023 15:19:33 +0300 Subject: [PATCH 03/16] cherry pick PR #12034 & #12038 --- src/ds/d400/d400-private.h | 2 +- unit-tests/live/dfu/test-device-fw-compatibility.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ds/d400/d400-private.h b/src/ds/d400/d400-private.h index b295a0b725..fd77dc6aec 100644 --- a/src/ds/d400/d400-private.h +++ b/src/ds/d400/d400-private.h @@ -153,7 +153,7 @@ namespace librealsense {RS465_PID, "5.12.7.100" }, {RS416_RGB_PID, "5.8.15.0" }, {RS405_PID, "5.12.11.8" }, - {RS455_PID, "5.12.7.100" }, + {RS455_PID, "5.13.0.50" }, {RS457_PID, "5.13.1.1" } }; diff --git a/unit-tests/live/dfu/test-device-fw-compatibility.py b/unit-tests/live/dfu/test-device-fw-compatibility.py index e620eaab96..faea312fc4 100644 --- a/unit-tests/live/dfu/test-device-fw-compatibility.py +++ b/unit-tests/live/dfu/test-device-fw-compatibility.py @@ -5,6 +5,8 @@ # test:device D400* # test:device SR300* +# Note, this test depends on files deployed on LibCI machines (Windows + Linux)! + import pyrealsense2 as rs from rspy import test, libci import os @@ -13,9 +15,11 @@ d400_fw_min_version_1 = 'Signed_Image_UVC_5_8_15_0.bin' d400_fw_min_version_2 = 'Signed_Image_UVC_5_12_7_100.bin' d400_fw_min_version_3 = 'Signed_Image_UVC_5_12_12_100.bin' +d400_fw_min_version_4 = 'Signed_Image_UVC_5_13_0_50.bin' d400_fw_min_version_1_prev = 'Signed_Image_UVC_5_8_14_0.bin' d400_fw_min_version_2_prev = 'Signed_Image_UVC_5_12_6_0.bin' d400_fw_min_version_3_prev = 'Signed_Image_UVC_5_12_11_0.bin' +d400_fw_min_version_4_prev = 'Signed_Image_UVC_5_12_15_150.bin' l500_fw_min_version_valid = 'Signed_Image_UVC_1_5_1_3.bin' l500_fw_min_version_invalid = 'Signed_Image_UVC_1_4_1_0.bin' @@ -49,7 +53,7 @@ '0B4D': d400_fw_min_version_2, # D465 '0B52': d400_fw_min_version_1, # D416_RGB '0B5B': d400_fw_min_version_3, # D405 - '0B5C': d400_fw_min_version_2, # D455 + '0B5C': d400_fw_min_version_4, # D455 # L500 product line: '0B55': l500_fw_min_version_valid, # L500_RECOVERY '0ADC': l500_fw_min_version_valid, # L500_USB2_RECOVERY_OLD From 4d5988be5d0c1c93c9ba5daa8182940ab8b1712f Mon Sep 17 00:00:00 2001 From: Eran Date: Sun, 18 Jun 2023 09:38:30 +0300 Subject: [PATCH 04/16] PR #11915 from Eran: Linux collaterals in single build dir (cherry picked from commit 8a0f72d500efe85ac6da43eb0fa277945e18a2ea) --- .github/workflows/buildsCI.yaml | 42 ++++++++++++++----------------- CMake/unix_config.cmake | 11 +++++--- common/processing-block-model.cpp | 2 -- src/gl/align-gl.cpp | 3 +-- src/gl/colorizer-gl.cpp | 3 +-- src/gl/upload.cpp | 1 - src/gl/yuy2rgb-gl.cpp | 1 - unit-tests/run-unit-tests.py | 5 +--- 8 files changed, 29 insertions(+), 39 deletions(-) diff --git a/.github/workflows/buildsCI.yaml b/.github/workflows/buildsCI.yaml index 77c31d8095..e4dae2a54e 100644 --- a/.github/workflows/buildsCI.yaml +++ b/.github/workflows/buildsCI.yaml @@ -141,8 +141,6 @@ jobs: mkdir ${{env.WIN_BUILD_DIR}} - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type shell: bash run: | LRS_SRC_DIR=$(pwd) @@ -193,8 +191,6 @@ jobs: mkdir ${{env.WIN_BUILD_DIR}} - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type shell: bash run: | LRS_SRC_DIR=$(pwd) @@ -234,10 +230,10 @@ jobs: - name: Build shell: bash - run: | + run: | cd build - cmake .. -DBUILD_SHARED_LIBS=false -DBUILD_EXAMPLES=true -DBUILD_TOOLS=true -DCHECK_FOR_UPDATES=true -DBUILD_LEGACY_LIVE_TEST=true -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=$(which python3) - cmake --build . --config ${{env.LRS_RUN_CONFIG}} -- -j4 + cmake .. -DCMAKE_BUILD_TYPE=${{env.LRS_RUN_CONFIG}} -DBUILD_SHARED_LIBS=false -DBUILD_EXAMPLES=true -DBUILD_TOOLS=true -DCHECK_FOR_UPDATES=true -DBUILD_LEGACY_LIVE_TEST=true -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=$(which python3) + cmake --build . -- -j4 - name: Test shell: bash @@ -245,10 +241,10 @@ jobs: # We set continue-on-error: true as a workaround for not skipping the upload log step on failure, # The final step will check the return value from the test step and decide if to fail/pass the job continue-on-error: true - run: | + run: | export LRS_LOG_LEVEL="DEBUG"; - cd build - ./unit-tests/live-test -d yes -i [software-device] + cd build/${{env.LRS_RUN_CONFIG}}/ + ./live-test -d yes -i [software-device] - name: Upload RS log artifact uses: actions/upload-artifact@v3 @@ -300,8 +296,8 @@ jobs: shell: bash run: | cd build - cmake .. -DBUILD_SHARED_LIBS=true -DBUILD_EXAMPLES=false -DBUILD_TOOLS=true -DBUILD_UNIT_TESTS=true -DCHECK_FOR_UPDATES=false -DBUILD_WITH_DDS=false -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=$(which python3) - cmake --build . --config ${{env.LRS_RUN_CONFIG}} -- -j4 + cmake .. -DCMAKE_BUILD_TYPE=${{env.LRS_RUN_CONFIG}} -DBUILD_SHARED_LIBS=true -DBUILD_EXAMPLES=false -DBUILD_TOOLS=true -DBUILD_UNIT_TESTS=true -DCHECK_FOR_UPDATES=false -DBUILD_WITH_DDS=false -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=$(which python3) + cmake --build . -- -j4 - name: LibCI # Note: requires BUILD_UNIT_TESTS or the executable C++ unit-tests won't run (and it won't complain) @@ -343,8 +339,8 @@ jobs: shell: bash run: | cd build - cmake .. -DBUILD_SHARED_LIBS=false -DBUILD_EXAMPLES=false -DBUILD_TOOLS=true -DBUILD_UNIT_TESTS=false -DCHECK_FOR_UPDATES=false -DBUILD_WITH_DDS=true -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=$(which python3) - cmake --build . --config ${{env.LRS_RUN_CONFIG}} -- -j4 + cmake .. -DCMAKE_BUILD_TYPE=${{env.LRS_RUN_CONFIG}} -DBUILD_SHARED_LIBS=false -DBUILD_EXAMPLES=false -DBUILD_TOOLS=true -DBUILD_UNIT_TESTS=false -DCHECK_FOR_UPDATES=false -DBUILD_WITH_DDS=true -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=$(which python3) + cmake --build . -- -j4 - name: LibCI # Note: we specifically disable BUILD_UNIT_TESTS so the executable C++ unit-tests won't run @@ -390,8 +386,8 @@ jobs: shell: bash run: | cd build - cmake .. -DBUILD_SHARED_LIBS=true -DBUILD_EXAMPLES=false -DBUILD_TOOLS=false -DCHECK_FOR_UPDATES=false -DFORCE_RSUSB_BACKEND=true -DBUILD_LEGACY_LIVE_TEST=true - cmake --build . --config $LRS_BUILD_CONFIG -- -j4 + cmake .. -DCMAKE_BUILD_TYPE=${{env.LRS_BUILD_CONFIG}} -DBUILD_SHARED_LIBS=true -DBUILD_EXAMPLES=false -DBUILD_TOOLS=false -DCHECK_FOR_UPDATES=false -DFORCE_RSUSB_BACKEND=true -DBUILD_LEGACY_LIVE_TEST=true + cmake --build . -- -j4 - name: Test shell: bash @@ -401,12 +397,12 @@ jobs: continue-on-error: true run: | export LRS_LOG_LEVEL="DEBUG"; - cd build - ./unit-tests/live-test -d yes -i [software-device] + cd build/${{env.LRS_BUILD_CONFIG}}/ + ./live-test -d yes -i [software-device] - name: Upload RS log artifact uses: actions/upload-artifact@v3 - with: + with: name: Log file - U20_SH_RSUSB_LiveTest path: build/*.log @@ -451,8 +447,8 @@ jobs: # We use "greadlink -f" which is mac-os parallel command to "readlink -f" from Linux (-f to convert relative link to absolute link) export OPENSSL_ROOT_DIR=`greadlink -f /usr/local/opt/openssl@1.1` echo "OPENSSL_ROOT_DIR = ${OPENSSL_ROOT_DIR}" - cmake .. -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false -DCHECK_FOR_UPDATES=true - cmake --build . --config ${{env.LRS_BUILD_CONFIG}} -- -j4 + cmake .. -DCMAKE_BUILD_TYPE=${{env.LRS_BUILD_CONFIG}} -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false -DCHECK_FOR_UPDATES=true + cmake --build . -- -j4 ls @@ -489,7 +485,7 @@ jobs: - name: Build run: | cd build - cmake .. -DCMAKE_TOOLCHAIN_FILE=../android-ndk-r20b/build/cmake/android.toolchain.cmake -DFORCE_RSUSB_BACKEND=true - cmake --build . --config ${{env.LRS_BUILD_CONFIG}} -- -j4 + cmake .. -DCMAKE_BUILD_TYPE=${{env.LRS_BUILD_CONFIG}} -DCMAKE_TOOLCHAIN_FILE=../android-ndk-r20b/build/cmake/android.toolchain.cmake -DFORCE_RSUSB_BACKEND=true + cmake --build . -- -j4 ls diff --git a/CMake/unix_config.cmake b/CMake/unix_config.cmake index e5a3f21add..b5b39a9cd7 100644 --- a/CMake/unix_config.cmake +++ b/CMake/unix_config.cmake @@ -4,10 +4,13 @@ macro(os_set_flags) # Put all the collaterals together, so we can find when trying to run examples/tests # Note: this puts the outputs under / - # NOTE: do not uncomment -- this ruins our CI procedures -- otherwise it mirrors Windows, simplifies - # scripts, makes things easier to find... c'est la vie! - #set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}) - #set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}) + if( "${CMAKE_BUILD_TYPE}" STREQUAL "" ) + # This can happen according to the docs -- and in GHA... + message( STATUS "No output directory set; using ${CMAKE_BINARY_DIR}/Release/" ) + set( CMAKE_BUILD_TYPE "Release" ) + endif() + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -g -D_DEFAULT_SOURCE") diff --git a/common/processing-block-model.cpp b/common/processing-block-model.cpp index ac519ab602..91b25d4721 100644 --- a/common/processing-block-model.cpp +++ b/common/processing-block-model.cpp @@ -1,8 +1,6 @@ // License: Apache 2.0. See LICENSE file in root directory. // Copyright(c) 2023 Intel Corporation. All Rights Reserved. -#pragma once - #include #include #include "subdevice-model.h" diff --git a/src/gl/align-gl.cpp b/src/gl/align-gl.cpp index 4fcf032ba1..1ce9bcc9ee 100644 --- a/src/gl/align-gl.cpp +++ b/src/gl/align-gl.cpp @@ -20,7 +20,6 @@ #include #include -#include #include "synthetic-stream-gl.h" @@ -269,4 +268,4 @@ align_gl::~align_gl() { cleanup_gpu_resources(); }, []{}); -} \ No newline at end of file +} diff --git a/src/gl/colorizer-gl.cpp b/src/gl/colorizer-gl.cpp index d35010d556..fa60a46067 100644 --- a/src/gl/colorizer-gl.cpp +++ b/src/gl/colorizer-gl.cpp @@ -19,7 +19,6 @@ #include #include -#include static const char* fragment_shader_text = "#version 110\n" @@ -357,4 +356,4 @@ namespace librealsense return res; } } -} \ No newline at end of file +} diff --git a/src/gl/upload.cpp b/src/gl/upload.cpp index c4fa30bf85..3f27caf53f 100644 --- a/src/gl/upload.cpp +++ b/src/gl/upload.cpp @@ -21,7 +21,6 @@ #include #include -#include #include "synthetic-stream-gl.h" diff --git a/src/gl/yuy2rgb-gl.cpp b/src/gl/yuy2rgb-gl.cpp index 4f761c864f..0aebb884a0 100644 --- a/src/gl/yuy2rgb-gl.cpp +++ b/src/gl/yuy2rgb-gl.cpp @@ -18,7 +18,6 @@ #include #include -#include #include "synthetic-stream-gl.h" diff --git a/unit-tests/run-unit-tests.py b/unit-tests/run-unit-tests.py index 1d7df2abfe..d542f48f88 100644 --- a/unit-tests/run-unit-tests.py +++ b/unit-tests/run-unit-tests.py @@ -196,10 +196,7 @@ def find_build_dir( dir ): log.d( 'found python libraries in:', pyd_dirs ) if not exe_dir: build_dir = find_build_dir( pyrs_path ) - if linux: - exe_dir = build_dir - else: - exe_dir = pyrs_path + exe_dir = pyrs_path # Try to assume exe directory from inside build directory. Only works if there is only one location with tests if not exe_dir and build_dir: From 0e34b2eb9e7c8f00943d2dd60ff3e495787e0252 Mon Sep 17 00:00:00 2001 From: Eran Date: Sun, 30 Jul 2023 11:02:36 +0300 Subject: [PATCH 05/16] PR #12051 from Eran: remove debug enforcement (-g) from unix compile options (cherry picked from commit 77a975f58d8657dd3690396974e3c739feba33c2) --- CMake/unix_config.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMake/unix_config.cmake b/CMake/unix_config.cmake index b5b39a9cd7..1a8bd74dbc 100644 --- a/CMake/unix_config.cmake +++ b/CMake/unix_config.cmake @@ -13,8 +13,8 @@ macro(os_set_flags) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}) set(CMAKE_POSITION_INDEPENDENT_CODE ON) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -g -D_DEFAULT_SOURCE") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -g -Wno-missing-field-initializers") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -D_DEFAULT_SOURCE") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-missing-field-initializers") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-multichar -Wsequence-point -Wformat -Wformat-security") execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine OUTPUT_VARIABLE MACHINE) From f0c3b6a636ffd28d1d6feca7263f01740a49ae3e Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Mon, 7 Aug 2023 20:06:01 +0300 Subject: [PATCH 06/16] enable hdr for d457 --- src/ds/d400/d400-device.cpp | 36 +++++++++++++++++++++++++++++++++--- src/ds/d400/d400-device.h | 2 +- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/ds/d400/d400-device.cpp b/src/ds/d400/d400-device.cpp index 6fbfeae585..dcf2650898 100644 --- a/src/ds/d400/d400-device.cpp +++ b/src/ds/d400/d400-device.cpp @@ -748,7 +748,7 @@ namespace librealsense depth_sensor.register_option(RS2_OPTION_ENABLE_AUTO_EXPOSURE, enable_auto_exposure); // register HDR options - if (!mipi_sensor && (_fw_version >= hdr_firmware_version)) + if (_fw_version >= hdr_firmware_version) { auto d400_depth = As(&get_depth_sensor()); d400_depth->init_hdr_config(exposure_range, gain_range); @@ -934,7 +934,7 @@ namespace librealsense else { // used for mipi device - register_metadata_mipi(depth_sensor); + register_metadata_mipi(depth_sensor, hdr_firmware_version); } //mipi @@ -1047,7 +1047,7 @@ namespace librealsense } } - void d400_device::register_metadata_mipi(const synthetic_sensor &depth_sensor) const + void d400_device::register_metadata_mipi(const synthetic_sensor &depth_sensor, const firmware_version& hdr_firmware_version) const { depth_sensor.register_metadata(RS2_FRAME_METADATA_FRAME_TIMESTAMP, make_uvc_header_parser(&platform::uvc_header::timestamp)); @@ -1120,6 +1120,36 @@ namespace librealsense make_attribute_parser(&md_mipi_depth_mode::crc, md_mipi_depth_control_attributes::crc_attribute, md_prop_offset)); + + if (_fw_version >= hdr_firmware_version) + { + depth_sensor.register_metadata(RS2_FRAME_METADATA_SEQUENCE_SIZE, + make_attribute_parser(&md_mipi_depth_mode::sub_preset_info, + md_configuration_attributes::sub_preset_info_attribute, md_prop_offset, + [](const rs2_metadata_type& param) { + // bit mask and offset used to get data from bitfield + return (param & md_configuration::SUB_PRESET_BIT_MASK_SEQUENCE_SIZE) + >> md_configuration::SUB_PRESET_BIT_OFFSET_SEQUENCE_SIZE; + })); + + depth_sensor.register_metadata(RS2_FRAME_METADATA_SEQUENCE_ID, + make_attribute_parser(&md_mipi_depth_mode::sub_preset_info, + md_configuration_attributes::sub_preset_info_attribute, md_prop_offset, + [](const rs2_metadata_type& param) { + // bit mask and offset used to get data from bitfield + return (param & md_configuration::SUB_PRESET_BIT_MASK_SEQUENCE_ID) + >> md_configuration::SUB_PRESET_BIT_OFFSET_SEQUENCE_ID; + })); + + depth_sensor.register_metadata(RS2_FRAME_METADATA_SEQUENCE_NAME, + make_attribute_parser(&md_mipi_depth_mode::sub_preset_info, + md_configuration_attributes::sub_preset_info_attribute, md_prop_offset, + [](const rs2_metadata_type& param) { + // bit mask and offset used to get data from bitfield + return (param & md_configuration::SUB_PRESET_BIT_MASK_ID) + >> md_configuration::SUB_PRESET_BIT_OFFSET_ID; + })); + } } void d400_device::create_snapshot(std::shared_ptr& snapshot) const diff --git a/src/ds/d400/d400-device.h b/src/ds/d400/d400-device.h index b855ae3c19..b14c21b288 100644 --- a/src/ds/d400/d400-device.h +++ b/src/ds/d400/d400-device.h @@ -80,7 +80,7 @@ namespace librealsense command get_flash_logs_command() const; void register_metadata(const synthetic_sensor& depth_sensor, const firmware_version& hdr_firmware_version) const; - void register_metadata_mipi(const synthetic_sensor& depth_sensor) const; + void register_metadata_mipi(const synthetic_sensor& depth_sensor, const firmware_version& hdr_firmware_version) const; void init(std::shared_ptr ctx, const platform::backend_device_group& group); From fa5fe4f3d65282bec25cab1bf1bd086bd0e1fc49 Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Tue, 8 Aug 2023 16:40:57 +0300 Subject: [PATCH 07/16] D457 Segfault when calling get_motion_intrinsics --- src/ds/d400/d400-motion.cpp | 15 ++++----- src/ds/d400/d400-motion.h | 2 -- src/ds/ds-motion-common.cpp | 4 +-- src/ds/ds-motion-common.h | 2 +- unit-tests/live/intrinsics/test-motion.py | 40 +++++++++++++++++++++++ 5 files changed, 49 insertions(+), 14 deletions(-) create mode 100644 unit-tests/live/intrinsics/test-motion.py diff --git a/src/ds/d400/d400-motion.cpp b/src/ds/d400/d400-motion.cpp index 7399641217..b10f9094d6 100644 --- a/src/ds/d400/d400-motion.cpp +++ b/src/ds/d400/d400-motion.cpp @@ -93,11 +93,6 @@ namespace librealsense return _ds_motion_common->create_hid_device(ctx, all_hid_infos, camera_fw_version, _tf_keeper); } - rs2_motion_device_intrinsic d400_motion::get_motion_intrinsics(rs2_stream stream) const - { - return d400_motion_base::get_motion_intrinsics(stream); - } - d400_motion_base::d400_motion_base(std::shared_ptr ctx, const platform::backend_device_group& group) : device(ctx, group), @@ -119,7 +114,7 @@ namespace librealsense std::vector hid_infos = group.hid_devices; - _ds_motion_common->init_hid(hid_infos, *_depth_stream); + _ds_motion_common->init_motion(hid_infos.empty(), *_depth_stream); initialize_fisheye_sensor(ctx,group); @@ -136,14 +131,16 @@ namespace librealsense d400_motion_uvc::d400_motion_uvc(std::shared_ptr ctx, const platform::backend_device_group& group) - : d400_motion_base(ctx, group), - device(ctx, group), - d400_device(ctx, group) + : device(ctx, group), + d400_device(ctx, group), + d400_motion_base(ctx, group) { using namespace ds; std::vector uvc_infos = group.uvc_devices; + _ds_motion_common->init_motion(uvc_infos.empty(), *_depth_stream); + if (!uvc_infos.empty()) { // product id - D457 dev - check - must not be the front of uvc_infos vector diff --git a/src/ds/d400/d400-motion.h b/src/ds/d400/d400-motion.h index 45207c955a..b9ce37b061 100644 --- a/src/ds/d400/d400-motion.h +++ b/src/ds/d400/d400-motion.h @@ -49,8 +49,6 @@ namespace librealsense const std::vector& all_hid_infos, const firmware_version& camera_fw_version); - rs2_motion_device_intrinsic get_motion_intrinsics(rs2_stream) const; - protected: friend class ds_motion_common; friend class ds_fisheye_sensor; diff --git a/src/ds/ds-motion-common.cpp b/src/ds/ds-motion-common.cpp index b6d79d92ba..2655343a0b 100644 --- a/src/ds/ds-motion-common.cpp +++ b/src/ds/ds-motion-common.cpp @@ -490,9 +490,9 @@ namespace librealsense return hid_ep; } - void ds_motion_common::init_hid(const std::vector& hid_infos, const stream_interface& depth_stream) + void ds_motion_common::init_motion(bool is_infos_empty, const stream_interface& depth_stream) { - if (!hid_infos.empty()) + if (!is_infos_empty) { // motion correction _mm_calib = std::make_shared(_hw_monitor, _owner->_pid); diff --git a/src/ds/ds-motion-common.h b/src/ds/ds-motion-common.h index fb4b50121d..bf5c5db29d 100644 --- a/src/ds/ds-motion-common.h +++ b/src/ds/ds-motion-common.h @@ -126,7 +126,7 @@ namespace librealsense const firmware_version& camera_fw_version, std::shared_ptr tf_keeper); - void init_hid(const std::vector& hid_infos, const stream_interface& depth_stream); + void init_motion(bool is_infos_empty, const stream_interface& depth_stream); const std::vector& get_fisheye_calibration_table() const; diff --git a/unit-tests/live/intrinsics/test-motion.py b/unit-tests/live/intrinsics/test-motion.py new file mode 100644 index 0000000000..9a12f01c85 --- /dev/null +++ b/unit-tests/live/intrinsics/test-motion.py @@ -0,0 +1,40 @@ +# License: Apache 2.0. See LICENSE file in root directory. +# Copyright(c) 2023 Intel Corporation. All Rights Reserved. + +# test:device:jetson D457 +# test:device:!jetson D455 +# This test check existence motion intrinsic data in accel and gyro profiles. + +import pyrealsense2 as rs +from rspy import test, log + +device = test.find_first_device_or_exit() +motion_sensor = device.first_motion_sensor() + +test.start('Check intrinsics in motion sensor:') + +test.check(motion_sensor) + +if motion_sensor: + + motion_profile_accel = next(p for p in motion_sensor.profiles if p.stream_type() == rs.stream.accel) + motion_profile_gyro = next(p for p in motion_sensor.profiles if p.stream_type() == rs.stream.gyro) + + test.check(motion_profile_accel and motion_profile_gyro) + + if motion_profile_accel: + motion_profile_accel = motion_profile_accel.as_motion_stream_profile() + intrinsics_accel = motion_profile_accel.get_motion_intrinsics() + + log.d(str(intrinsics_accel)) + test.check(len(str(intrinsics_accel)) > 0) # Checking if intrinsics has data + + if motion_profile_gyro: + motion_profile_gyro = motion_profile_gyro.as_motion_stream_profile() + intrinsics_gyro = motion_profile_gyro.get_motion_intrinsics() + + log.d(intrinsics_gyro) + test.check(len(str(intrinsics_gyro)) > 0) # Checking if intrinsics has data + + test.finish() + test.print_results_and_exit() From d6b4c87722a5d907ce423536282bc3e97dfb9694 Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Mon, 14 Aug 2023 15:08:55 +0300 Subject: [PATCH 08/16] cherry pick rs-fw-update tool - handle D457 MIPI device --- tools/fw-update/rs-fw-update.cpp | 124 +++++++++++++++++++++++++++++-- 1 file changed, 118 insertions(+), 6 deletions(-) diff --git a/tools/fw-update/rs-fw-update.cpp b/tools/fw-update/rs-fw-update.cpp index 15c1ecc50f..45cff625d1 100644 --- a/tools/fw-update/rs-fw-update.cpp +++ b/tools/fw-update/rs-fw-update.cpp @@ -35,13 +35,31 @@ std::vector read_fw_file(std::string file_path) std::vector rv; std::ifstream file(file_path, std::ios::in | std::ios::binary | std::ios::ate); + auto file_deleter = std::unique_ptr< std::ifstream, void ( * )( std::ifstream * ) >( &file, + []( std::ifstream * file ) + { + if( file ) + file->close(); + } ); if (file.is_open()) { rv.resize(file.tellg()); - file.seekg(0, std::ios::beg); - file.read((char*)rv.data(), rv.size()); - file.close(); + try + { + file.seekg( 0, std::ios::beg ); + file.read( (char *)rv.data(), rv.size() ); + } + catch( ... ) + { + // Nothing to do, file goodbit is false + } + if( ! file.good() ) + { + std::cout << std::endl << "Error reading firmware file"; + rv.resize( 0 ); // Signal error, don't use partial read data + } + } return rv; @@ -119,7 +137,72 @@ void list_devices(rs2::context ctx) } } -int main(int argc, char** argv) try +int write_fw_to_mipi_device( const std::vector< uint8_t > & fw_image) +{ + // Write firmware to appropriate file descritptor + std::cout << std::endl << "Update can take up to 2 minutes" << std::endl; + std::ofstream fw_path_in_device( "/dev/d4xx-dfu504", std::ios::binary ); + auto file_deleter = std::unique_ptr< std::ofstream, void ( * )( std::ofstream * ) >( &fw_path_in_device, + []( std::ofstream * file ) + { + if( file ) + file->close(); + } ); + if( fw_path_in_device ) + { + bool done = false; + std::thread show_progress_thread( + [&done]() + { + for( int i = 0; i < 101 && ! done; ++i ) // Show percentage [0-100] + { + printf( "%d%%\r", i ); + std::cout.flush(); + std::this_thread::sleep_for( std::chrono::seconds( 1 ) ); + } + } ); + try + { + fw_path_in_device.write( reinterpret_cast< const char * >( fw_image.data() ), fw_image.size() ); + } + catch( ... ) + { + // Nothing to do, file goodbit is false + } + done = true; + show_progress_thread.join(); + printf( " \r" ); // Delete progress, as it is not accurate, don't leave 85% when writing done + if( ! fw_path_in_device.good() ) + { + std::cout << std::endl << "Firmware Update failed - write to device error"; + return EXIT_FAILURE; + } + } + else + { + std::cout << std::endl << "Firmware Update failed - wrong path or permissions missing"; + return EXIT_FAILURE; + } + std::cout << std::endl << "Firmware update done" << std::endl; + + return EXIT_SUCCESS; +} + +bool is_mipi_device( const rs2::device & dev ) +{ + std::string usb_type = "unknown"; + + if( dev.supports( RS2_CAMERA_INFO_USB_TYPE_DESCRIPTOR ) ) + usb_type = dev.get_info( RS2_CAMERA_INFO_USB_TYPE_DESCRIPTOR ); + + bool d457_device = strcmp( dev.get_info( RS2_CAMERA_INFO_PRODUCT_ID ), "ABCD" ) == 0; + + // Currently only D457 model has MIPI connection + return d457_device && usb_type.compare( "unknown" ) == 0; +} + +int main( int argc, char ** argv ) +try { #ifdef BUILD_EASYLOGGINGPP rs2::log_to_console(RS2_LOG_SEVERITY_WARN); @@ -301,7 +384,7 @@ int main(int argc, char** argv) try if (d.supports(RS2_CAMERA_INFO_USB_TYPE_DESCRIPTOR)) { - std::string usb_type = d.get_info(RS2_CAMERA_INFO_USB_TYPE_DESCRIPTOR); + std::string usb_type = d.get_info( RS2_CAMERA_INFO_USB_TYPE_DESCRIPTOR ); if (usb_type.find("2.") != std::string::npos) { std::cout << std::endl << "Warning! the camera is connected via USB 2 port, in case the process fails, connect the camera to a USB 3 port and try again" << std::endl; } @@ -331,7 +414,24 @@ int main(int argc, char** argv) try auto temp = backup_arg.getValue(); std::ofstream file(temp.c_str(), std::ios::binary); - file.write((const char*)flash.data(), flash.size()); + auto file_deleter = std::unique_ptr< std::ofstream, void ( * )( std::ofstream * ) >( &file, + []( std::ofstream * file ) + { + if( file ) + file->close(); + } ); + try + { + file.write( (const char *)flash.data(), flash.size() ); + } + catch( ... ) + { + // Nothing to do, file goodbit is false + } + if( ! file.good() ) + { + std::cout << std::endl << "Creating backup file failed"; + } } if (!file_arg.isSet()) @@ -342,6 +442,18 @@ int main(int argc, char** argv) try std::cout << std::endl << "Updating device: " << std::endl; print_device_info(d); + // If device is D457 connected by MIPI connector + if( is_mipi_device( d ) ) + { + if( unsigned_arg.isSet() ) + { + std::cout << std::endl << "Only signed FW is currently supported for MIPI devices" << std::endl; + return EXIT_FAILURE; + } + + return write_fw_to_mipi_device( fw_image ); + } + if (unsigned_arg.isSet()) { std::cout << std::endl << "Firmware update started" << std::endl << std::endl; From bc24c894ef56930ed6bb2b1ab2b16f8a72f95b9a Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Tue, 15 Aug 2023 00:20:04 +0300 Subject: [PATCH 09/16] add missing include --- tools/fw-update/rs-fw-update.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/fw-update/rs-fw-update.cpp b/tools/fw-update/rs-fw-update.cpp index 45cff625d1..5839cceca7 100644 --- a/tools/fw-update/rs-fw-update.cpp +++ b/tools/fw-update/rs-fw-update.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include From fba97975b119c292d6e15a418191a74296485a3e Mon Sep 17 00:00:00 2001 From: Eran Date: Wed, 23 Aug 2023 14:33:02 +0300 Subject: [PATCH 10/16] PR #12128 from Ohad: Restore calibration changed options only after apply or dismiss --- common/on-chip-calib.cpp | 74 +++++++++++++++++++++++----------------- common/on-chip-calib.h | 21 +++++++----- 2 files changed, 54 insertions(+), 41 deletions(-) diff --git a/common/on-chip-calib.cpp b/common/on-chip-calib.cpp index d51c0c0539..69d69faf7b 100644 --- a/common/on-chip-calib.cpp +++ b/common/on-chip-calib.cpp @@ -74,12 +74,34 @@ namespace rs2 } } + void on_chip_calib_manager::save_options_controlled_by_calib() + { + // Calibration might fail and be restarted, save only once, or we will keep chaged options. + if( ! _options_saved ) + { + save_laser_emitter_state(); + save_thermal_loop_state(); + _options_saved = true; + } + } + + void on_chip_calib_manager::restore_options_controlled_by_calib() + { + // Restore might be called several times, restore only if options where actually saved. + if( _options_saved ) + { + restore_laser_emitter_state(); + restore_thermal_loop_state(); + _options_saved = false; + } + } + void on_chip_calib_manager::save_laser_emitter_state() { 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 ); + _laser_status_prev = _sub->s->get_option( RS2_OPTION_EMITTER_ENABLED ); } } @@ -88,18 +110,18 @@ namespace rs2 auto 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 ); + _thermal_loop_prev = _sub->s->get_option( RS2_OPTION_THERMAL_COMPENSATION ); } } void on_chip_calib_manager::restore_laser_emitter_state() { - set_laser_emitter_state( laser_status_prev ); + set_laser_emitter_state( _laser_status_prev ); } void on_chip_calib_manager::restore_thermal_loop_state() { - set_thermal_loop_state( thermal_loop_prev ); + set_thermal_loop_state( _thermal_loop_prev ); } void on_chip_calib_manager::set_laser_emitter_state( float value ) @@ -1417,6 +1439,19 @@ namespace rs2 _restored = false; + save_options_controlled_by_calib(); // Restored by GUI thread on dismiss or apply. + + // Emitter on by default, off for GT/FL calib and for D415 model + float emitter_value = on_value; + if( action == RS2_CALIB_ACTION_FL_CALIB || + action == RS2_CALIB_ACTION_TARE_GROUND_TRUTH || + device_name_string == std::string( "Intel RealSense D415" ) ) + emitter_value = off_value; + set_laser_emitter_state( emitter_value ); + + // Thermal loop should be off during calibration as to not change calibration tables during calibration + set_thermal_loop_state( off_value ); + auto fps = 30; if (_sub->dev.supports(RS2_CAMERA_INFO_USB_TYPE_DESCRIPTOR)) { @@ -1465,40 +1500,18 @@ namespace rs2 if ( action == RS2_CALIB_ACTION_TARE_GROUND_TRUTH ) { - // Laser should be turned off during ground truth calculation - save_laser_emitter_state(); - set_laser_emitter_state( off_value ); - get_ground_truth(); - - restore_laser_emitter_state(); } else { try { - // Save options that are going to change during the calibration - save_laser_emitter_state(); - save_thermal_loop_state(); - - // Emitter on by default, off for FL calib and for D415 model - float emitter_value = on_value; - if( action == RS2_CALIB_ACTION_FL_CALIB || device_name_string == std::string( "Intel RealSense D415" ) ) - emitter_value = off_value; - set_laser_emitter_state( emitter_value ); - - // Thermal loop should be off during calibration as to not change calibration tables during calibration - set_thermal_loop_state( off_value ); - if (action == RS2_CALIB_ACTION_FL_CALIB) calibrate_fl(); else if (action == RS2_CALIB_ACTION_UVMAPPING_CALIB) calibrate_uv_mapping(); else calibrate(); - - restore_laser_emitter_state(); - restore_thermal_loop_state(); } catch (...) { @@ -1515,11 +1528,6 @@ namespace rs2 _ui_color.reset(); } - //Restore options that were changed during the calibration. - //When calibration is successful options are restored in autocalib_notification_model::draw_content() - restore_laser_emitter_state(); - restore_thermal_loop_state(); - if (_was_streaming) start_viewer(0, 0, 0, invoke); @@ -2861,6 +2869,7 @@ namespace rs2 dismiss(false); } + get_manager().restore_options_controlled_by_calib(); get_manager().restore_workspace([](std::function a) { a(); }); } @@ -2979,7 +2988,8 @@ namespace rs2 if (!use_new_calib && get_manager().done()) get_manager().apply_calib(false); - get_manager().restore_workspace([](std::function a){ a(); }); + get_manager().restore_options_controlled_by_calib(); + get_manager().restore_workspace( []( std::function< void() > a ) { a(); } ); if (update_state != RS2_CALIB_STATE_TARE_INPUT) update_state = RS2_CALIB_STATE_INITIAL_PROMPT; diff --git a/common/on-chip-calib.h b/common/on-chip-calib.h index efbda26c88..1bddb10a47 100644 --- a/common/on-chip-calib.h +++ b/common/on-chip-calib.h @@ -112,12 +112,8 @@ namespace rs2 void turn_roi_on(); void turn_roi_off(); - void save_laser_emitter_state(); - void save_thermal_loop_state(); - void restore_laser_emitter_state(); - void restore_thermal_loop_state(); - void set_laser_emitter_state( float value ); - void set_thermal_loop_state( float value ); + void save_options_controlled_by_calib(); + void restore_options_controlled_by_calib(); void start_gt_viewer(); void start_fl_viewer(); @@ -127,6 +123,13 @@ namespace rs2 void reset_device() { _dev.hardware_reset(); } private: + void save_laser_emitter_state(); + void save_thermal_loop_state(); + void restore_laser_emitter_state(); + void restore_thermal_loop_state(); + void set_laser_emitter_state( float value ); + void set_thermal_loop_state( float value ); + std::vector safe_send_command(const std::vector& cmd, const std::string& name); rs2::depth_frame fetch_depth_frame(invoker invoke, int timeout_ms = 5000); // Wait for next depth frame and return it std::pair get_depth_metrics(invoker invoke); @@ -141,9 +144,9 @@ namespace rs2 device _dev; - - float laser_status_prev = 0.0f; - float thermal_loop_prev = 0.0f; + bool _options_saved = false; + float _laser_status_prev = 0.0f; + float _thermal_loop_prev = 0.0f; bool _was_streaming = false; bool _synchronized = false; From 59dcf996f68c5235f1cd78e703689945f953b071 Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Mon, 4 Sep 2023 15:59:02 +0300 Subject: [PATCH 11/16] cherry pick PR#12162-rs-hdr fix for d457 --- src/proc/hdr-merge.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/proc/hdr-merge.cpp b/src/proc/hdr-merge.cpp index 00974f5607..bcbb804b83 100644 --- a/src/proc/hdr-merge.cpp +++ b/src/proc/hdr-merge.cpp @@ -258,6 +258,13 @@ namespace librealsense // checking frame counter of first depth and ir are the same if (use_ir) { + // on devices that does not support meta data on IR frames, do not use IR for hdr merging + if (!first_ir.supports_frame_metadata(RS2_FRAME_METADATA_FRAME_COUNTER) || + !second_ir.supports_frame_metadata(RS2_FRAME_METADATA_FRAME_COUNTER) || + !first_ir.supports_frame_metadata(RS2_FRAME_METADATA_SEQUENCE_ID) || + !second_ir.supports_frame_metadata(RS2_FRAME_METADATA_SEQUENCE_ID)) + return false; + int depth_frame_counter = static_cast(first_depth.get_frame_metadata(RS2_FRAME_METADATA_FRAME_COUNTER)); int ir_frame_counter = static_cast(first_ir.get_frame_metadata(RS2_FRAME_METADATA_FRAME_COUNTER)); use_ir = (depth_frame_counter == ir_frame_counter); From f011c9be50451fd40e6892cf2657564570572bac Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Mon, 4 Sep 2023 17:04:57 +0300 Subject: [PATCH 12/16] cherry pick #11892 - depth ae mode added to options to ignore in test --- unit-tests/live/options/test-drops-on-set.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unit-tests/live/options/test-drops-on-set.py b/unit-tests/live/options/test-drops-on-set.py index 9b99741f74..18bc0c61ae 100644 --- a/unit-tests/live/options/test-drops-on-set.py +++ b/unit-tests/live/options/test-drops-on-set.py @@ -108,7 +108,7 @@ def check_color_frame_drops(frame): # inter_cam_sync_mode --> frame drops are expected during inter_cam_sync_mode change # emitter_frequency --> Not allowed to be set during streaming if product_line == "D400": - options_to_ignore = [rs.option.visual_preset, rs.option.inter_cam_sync_mode, rs.option.emitter_frequency] + options_to_ignore = [rs.option.visual_preset, rs.option.inter_cam_sync_mode, rs.option.emitter_frequency, rs.option.auto_exposure_mode] def test_option_changes(sensor): global options_to_ignore From 845f4768bf078469aec118b86556e8b95ae05dbe Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Tue, 5 Sep 2023 13:35:09 +0300 Subject: [PATCH 13/16] add comment --- unit-tests/live/options/test-drops-on-set.py | 1 + 1 file changed, 1 insertion(+) diff --git a/unit-tests/live/options/test-drops-on-set.py b/unit-tests/live/options/test-drops-on-set.py index 18bc0c61ae..0396647044 100644 --- a/unit-tests/live/options/test-drops-on-set.py +++ b/unit-tests/live/options/test-drops-on-set.py @@ -107,6 +107,7 @@ def check_color_frame_drops(frame): # visual_preset --> frame drops are expected during visual_preset change # inter_cam_sync_mode --> frame drops are expected during inter_cam_sync_mode change # emitter_frequency --> Not allowed to be set during streaming +# auto_exposure_mode --> Not allowed to be set during streaming if product_line == "D400": options_to_ignore = [rs.option.visual_preset, rs.option.inter_cam_sync_mode, rs.option.emitter_frequency, rs.option.auto_exposure_mode] From c9d494455a3100a1ed311cdcb81ba4578cef89eb Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Tue, 5 Sep 2023 13:38:04 +0300 Subject: [PATCH 14/16] update comment --- src/proc/hdr-merge.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proc/hdr-merge.cpp b/src/proc/hdr-merge.cpp index bcbb804b83..966c6e7547 100644 --- a/src/proc/hdr-merge.cpp +++ b/src/proc/hdr-merge.cpp @@ -258,7 +258,7 @@ namespace librealsense // checking frame counter of first depth and ir are the same if (use_ir) { - // on devices that does not support meta data on IR frames, do not use IR for hdr merging + // on devices that do not support meta data on IR frames (like D457), do not use IR for hdr merging if (!first_ir.supports_frame_metadata(RS2_FRAME_METADATA_FRAME_COUNTER) || !second_ir.supports_frame_metadata(RS2_FRAME_METADATA_FRAME_COUNTER) || !first_ir.supports_frame_metadata(RS2_FRAME_METADATA_SEQUENCE_ID) || From 282b6dc0f8bd502cb9513fb57800124517664227 Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Tue, 15 Aug 2023 00:11:01 +0300 Subject: [PATCH 15/16] PR #12105 from OhadMeir: Draw cross in calibration ROI --- common/stream-model.cpp | 18 ++++++++++++++++-- common/stream-model.h | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/common/stream-model.cpp b/common/stream-model.cpp index fedc734a58..acbcb8c6d3 100644 --- a/common/stream-model.cpp +++ b/common/stream-model.cpp @@ -78,7 +78,7 @@ namespace rs2 glPopAttrib(); } - void draw_rect(const rect& r, int line_width) + void draw_rect( const rect & r, int line_width, bool draw_cross ) { glPushAttrib(GL_ENABLE_BIT); @@ -96,6 +96,20 @@ namespace rs2 glVertex2f(r.x, r.y); glEnd(); + if( draw_cross ) + { + glLineStipple( 1, 0x0808 ); + glEnable( GL_LINE_STIPPLE ); + glBegin( GL_LINES ); + glVertex2f( r.x, r.y + r.h / 2 ); + glVertex2f( r.x + r.w, r.y + r.h / 2 ); + glEnd(); + glBegin( GL_LINES ); + glVertex2f( r.x + r.w / 2, r.y ); + glVertex2f( r.x + r.w / 2, r.y + r.h ); + glEnd(); + } + glPopAttrib(); } @@ -1541,7 +1555,7 @@ namespace rs2 r = r.normalize(_normalized_zoom.unnormalize(get_original_stream_bounds())).unnormalize(stream_rect).cut_by(stream_rect); glColor3f(yellow.x, yellow.y, yellow.z); - draw_rect(r, 2); + draw_rect(r, 2, true); std::string message = "Metrics Region of Interest"; auto msg_width = stb_easy_font_width((char*)message.c_str()); diff --git a/common/stream-model.h b/common/stream-model.h index e80acd8766..987084952f 100644 --- a/common/stream-model.h +++ b/common/stream-model.h @@ -14,7 +14,7 @@ namespace rs2 class subdevice_model; class viewer_model; - void draw_rect(const rect& r, int line_width = 1); + void draw_rect(const rect& r, int line_width = 1, bool draw_cross = false); struct frame_metadata { From 81d735c6b0dc7360e7b981a01ac07df631353c68 Mon Sep 17 00:00:00 2001 From: Eran Date: Thu, 7 Sep 2023 14:32:17 +0300 Subject: [PATCH 16/16] bump FW to 5.15.1.0 --- common/fw/CMakeLists.txt | 2 +- common/fw/firmware-version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/fw/CMakeLists.txt b/common/fw/CMakeLists.txt index ed52c6cf83..9cfdd9b5ff 100644 --- a/common/fw/CMakeLists.txt +++ b/common/fw/CMakeLists.txt @@ -14,7 +14,7 @@ set(REALSENSE_FIRMWARE_URL "https://librealsense.intel.com" CACHE STRING string(REGEX MATCH "D4XX_RECOMMENDED_FIRMWARE_VERSION \"([0-9]+.[0-9]+.[0-9]+.[0-9]+)\"" _ ${ver}) set(D4XX_FW_VERSION ${CMAKE_MATCH_1}) #message(STATUS "D4XX_FW_VERSION: ${D4XX_FW_VERSION}") -set(D4XX_FW_SHA1 b4dfa2ceb46e9b79c2d64480b149f188f7538e65) +set(D4XX_FW_SHA1 20d1cf628957941689a948f2e17ecc6a11e8ab01) set(D4XX_FW_URL "${REALSENSE_FIRMWARE_URL}/Releases/RS4xx/FW") string(REGEX MATCH "SR3XX_RECOMMENDED_FIRMWARE_VERSION \"([0-9]+.[0-9]+.[0-9]+.[0-9]+)\"" _ ${ver}) diff --git a/common/fw/firmware-version.h b/common/fw/firmware-version.h index f017897362..61e186f165 100644 --- a/common/fw/firmware-version.h +++ b/common/fw/firmware-version.h @@ -3,7 +3,7 @@ #pragma once -#define D4XX_RECOMMENDED_FIRMWARE_VERSION "5.15.0.2" +#define D4XX_RECOMMENDED_FIRMWARE_VERSION "5.15.1.0" #define SR3XX_RECOMMENDED_FIRMWARE_VERSION "3.26.1.0" #define T26X_FIRMWARE_VERSION "0.2.0.951" #define L51X_RECOMMENDED_FIRMWARE_VERSION "1.5.8.1"