diff --git a/CMake/external_libcurl.cmake b/CMake/external_libcurl.cmake index 6fbe570bff0..18ce553f00d 100644 --- a/CMake/external_libcurl.cmake +++ b/CMake/external_libcurl.cmake @@ -2,7 +2,7 @@ if(CHECK_FOR_UPDATES) include(ExternalProject) message(STATUS "Building libcurl enabled") - set(CURL_FLAGS -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DUSE_WIN32_LDAP=OFF -DHTTP_ONLY=ON -DCURL_ZLIB=OFF -DCURL_DISABLE_CRYPTO_AUTH=ON -DCMAKE_USE_OPENSSL=OFF -DCMAKE_USE_LIBSSH2=OFF) + set(CURL_FLAGS -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DUSE_WIN32_LDAP=OFF -DHTTP_ONLY=ON -DCURL_ZLIB=OFF -DCURL_DISABLE_CRYPTO_AUTH=ON -DCMAKE_USE_OPENSSL=OFF -DCMAKE_USE_LIBSSH2=OFF -DBUILD_TESTING=OFF ) if (WIN32) set(CURL_FLAGS ${CURL_FLAGS} -DCURL_STATIC_CRT=ON ) endif() @@ -14,10 +14,17 @@ if(CHECK_FOR_UPDATES) GIT_TAG "53cdc2c963e33bc0cc1a51ad2df79396202e07f8" # curl-7_70_0 SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/third-party/libcurl TEST_COMMAND "" - CMAKE_ARGS -DCMAKE_CXX_STANDARD_LIBRARIES=${CMAKE_CXX_STANDARD_LIBRARIES} + CMAKE_ARGS -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} + -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG} + -DCMAKE_C_FLAGS_MINSIZEREL=${CMAKE_C_FLAGS_MINSIZEREL} + -DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE} + -DCMAKE_C_FLAGS_RELWITHDEBINFO=${CMAKE_C_FLAGS_RELWITHDEBINFO} + -DCMAKE_CXX_STANDARD_LIBRARIES=${CMAKE_CXX_STANDARD_LIBRARIES} -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/libcurl/libcurl_install + -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DANDROID_ABI=${ANDROID_ABI} -DANDROID_STL=${ANDROID_STL} ${CURL_FLAGS} ) diff --git a/common/fw-update-helper.cpp b/common/fw-update-helper.cpp index 3e444dba568..a5b08ac83da 100644 --- a/common/fw-update-helper.cpp +++ b/common/fw-update-helper.cpp @@ -16,11 +16,15 @@ #ifdef INTERNAL_FW #include "common/fw/D4XX_FW_Image.h" #include "common/fw/SR3XX_FW_Image.h" +#include "common/fw/L5XX_FW_Image.h" #else #define FW_D4XX_FW_IMAGE_VERSION "" #define FW_SR3XX_FW_IMAGE_VERSION "" +#define FW_L5XX_FW_IMAGE_VERSION "" const char* fw_get_D4XX_FW_Image(int) { return NULL; } const char* fw_get_SR3XX_FW_Image(int) { return NULL; } +const char* fw_get_L5XX_FW_Image(int) { return NULL; } + #endif // INTERNAL_FW constexpr const char* recommended_fw_url = "https://dev.intelrealsense.com/docs/firmware-releases"; @@ -46,6 +50,7 @@ namespace rs2 { if (id == "D400") return RS2_PRODUCT_LINE_D400; else if (id == "SR300") return RS2_PRODUCT_LINE_SR300; + else if (id == "L500") return RS2_PRODUCT_LINE_L500; else return -1; } @@ -55,6 +60,7 @@ namespace rs2 if (product_line == RS2_PRODUCT_LINE_D400) return FW_D4XX_FW_IMAGE_VERSION; //else if (product_line == RS2_PRODUCT_LINE_SR300) return FW_SR3XX_FW_IMAGE_VERSION; + else if (product_line == RS2_PRODUCT_LINE_L500) return FW_L5XX_FW_IMAGE_VERSION; else return ""; } @@ -80,6 +86,14 @@ namespace rs2 rv[RS2_PRODUCT_LINE_SR300] = vec; } + if (strlen(FW_L5XX_FW_IMAGE_VERSION)) + { + int size = 0; + auto hex = fw_get_L5XX_FW_Image(size); + auto vec = std::vector(hex, hex + size); + rv[RS2_PRODUCT_LINE_L500] = vec; + } + return rv; } diff --git a/common/fw/CMakeLists.txt b/common/fw/CMakeLists.txt index 4acc2d66e06..d0c7ed11a97 100644 --- a/common/fw/CMakeLists.txt +++ b/common/fw/CMakeLists.txt @@ -30,6 +30,12 @@ message(STATUS "T26X_FW_VERSION: ${T26X_FW_VERSION}") set(T26X_FW_SHA1 c3940ccbb0e3045603e4aceaa2d73427f96e24bc) set(T26X_FW_URL "${REALSENSE_FIRMWARE_URL}/Releases/TM2/FW/target/${T26X_FW_VERSION}") +string(REGEX MATCH "L5XX_RECOMMENDED_FIRMWARE_VERSION \"([0-9]+.[0-9]+.[0-9]+.[0-9]+)\"" _ ${ver}) +set(L5XX_FW_VERSION ${CMAKE_MATCH_1}) +message(STATUS "L5XX_FW_VERSION: ${L5XX_FW_VERSION}") +set(L5XX_FW_SHA1 5bb7d4e68994328f324559db66a0c586c3037afa) +set(L5XX_FW_URL "${REALSENSE_FIRMWARE_URL}/Releases/L5xx/FW") + add_library(${PROJECT_NAME} STATIC empty.c) if (MSVC) @@ -74,6 +80,8 @@ endfunction() target_binary( "${D4XX_FW_URL}" "${D4XX_FW_VERSION}" "${D4XX_FW_SHA1}" D4XX_FW_Image .bin) target_binary( "${SR3XX_FW_URL}" "${SR3XX_FW_VERSION}" "${SR3XX_FW_SHA1}" SR3XX_FW_Image .bin) target_binary( "${T26X_FW_URL}" "${T26X_FW_VERSION}" "${T26X_FW_SHA1}" target .mvcmd) +target_binary( "${L5XX_FW_URL}" "${L5XX_FW_VERSION}" "${L5XX_FW_SHA1}" L5XX_FW_Image .bin) + install(TARGETS ${PROJECT_NAME} EXPORT realsense2Targets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/common/fw/firmware-version.h b/common/fw/firmware-version.h index f1e9523335d..086ce579232 100644 --- a/common/fw/firmware-version.h +++ b/common/fw/firmware-version.h @@ -6,3 +6,4 @@ #define D4XX_RECOMMENDED_FIRMWARE_VERSION "5.12.5.0" #define SR3XX_RECOMMENDED_FIRMWARE_VERSION "3.26.1.0" #define T26X_FIRMWARE_VERSION "0.2.0.951" +#define L5XX_RECOMMENDED_FIRMWARE_VERSION "1.4.1.0" diff --git a/common/fw/fw.rc b/common/fw/fw.rc index 966e9954009..5a69fe5710c 100644 --- a/common/fw/fw.rc +++ b/common/fw/fw.rc @@ -1,3 +1,4 @@ #include "D4XX_FW_Image.rc" #include "SR3XX_FW_Image.rc" +#include "L5XX_FW_Image.rc" #include "target.rc" diff --git a/common/model-views.cpp b/common/model-views.cpp index 0092c7aedd9..9e922a28cbd 100644 --- a/common/model-views.cpp +++ b/common/model-views.cpp @@ -3252,7 +3252,7 @@ namespace rs2 { for (auto&& n : related_notifications) n->dismiss(false); - _updates->remove_profile(_updates_profile); + _updates->set_device_status(_updates_profile, false); } @@ -4342,15 +4342,23 @@ namespace rs2 bool sw_update_required = updates_profile.retrieve_updates(versions_db_manager::LIBREALSENSE); bool fw_update_required = updates_profile.retrieve_updates(versions_db_manager::FIRMWARE); + _updates_profile = updates_profile.get_update_profile(); + updates_model::update_profile_model updates_profile_model(_updates_profile, ctx, this); + if (sw_update_required || fw_update_required) { - _updates_profile = updates_profile.get_update_profile(); - updates_model::update_profile_model updates_profile_model(updates_profile.get_update_profile(), ctx, this); if (auto viewer_updates = updates_model_protected.lock()) { viewer_updates->add_profile(updates_profile_model); } } + else + { // For updating current device profile if exists (Could update firmware version) + if (auto viewer_updates = updates_model_protected.lock()) + { + viewer_updates->update_profile(updates_profile_model); + } + } } catch (const std::exception& e) { diff --git a/common/model-views.h b/common/model-views.h index 89b8bae37d8..dd245dec28c 100644 --- a/common/model-views.h +++ b/common/model-views.h @@ -233,7 +233,6 @@ namespace rs2 static const textual_icon camera { u8"\uf030" }; static const textual_icon video_camera { u8"\uf03d" }; static const textual_icon edit { u8"\uf044" }; - static const textual_icon check_square_o { u8"\uf046" }; static const textual_icon step_backward { u8"\uf048" }; static const textual_icon play { u8"\uf04b" }; static const textual_icon pause { u8"\uf04c" }; @@ -256,6 +255,7 @@ namespace rs2 static const textual_icon caret_down { u8"\uf0d7" }; static const textual_icon repeat { u8"\uf0e2" }; static const textual_icon circle { u8"\uf111" }; + static const textual_icon check_square_o { u8"\uf14a" }; static const textual_icon cubes { u8"\uf1b3" }; static const textual_icon toggle_off { u8"\uf204" }; static const textual_icon toggle_on { u8"\uf205" }; diff --git a/common/sw-update/dev-updates-profile.cpp b/common/sw-update/dev-updates-profile.cpp index 0086d8f9fe4..dbb4f7e994a 100644 --- a/common/sw-update/dev-updates-profile.cpp +++ b/common/sw-update/dev-updates-profile.cpp @@ -31,26 +31,30 @@ namespace rs2 { bool update_required(false); - std::map &versions_vec((comp == versions_db_manager::FIRMWARE)? - _update_profile.firmware_versions : _update_profile.software_versions); - - versions_db_manager::version ¤t_version((comp == versions_db_manager::FIRMWARE) ? _update_profile.firmware_version : _update_profile.software_version); + if (_update_profile.device_name.find("Recovery") == std::string::npos) { - update_description experimental_update; - if (try_parse_update(_versions_db, _update_profile.device_name, versions_db_manager::EXPERIMENTAL, comp, experimental_update)) - { - versions_vec[experimental_update.ver] = experimental_update; - } - update_description recommened_update; - if (try_parse_update(_versions_db, _update_profile.device_name, versions_db_manager::RECOMMENDED, comp, recommened_update)) - { - versions_vec[recommened_update.ver] = recommened_update; - } - update_description required_update; - if (try_parse_update(_versions_db, _update_profile.device_name, versions_db_manager::ESSENTIAL, comp, required_update)) + std::map &versions_vec((comp == versions_db_manager::FIRMWARE) ? + _update_profile.firmware_versions : _update_profile.software_versions); + + versions_db_manager::version ¤t_version((comp == versions_db_manager::FIRMWARE) ? _update_profile.firmware_version : _update_profile.software_version); { - versions_vec[required_update.ver] = required_update; - update_required = update_required || (current_version < required_update.ver); + update_description experimental_update; + if (try_parse_update(_versions_db, _update_profile.device_name, versions_db_manager::EXPERIMENTAL, comp, experimental_update)) + { + versions_vec[experimental_update.ver] = experimental_update; + } + update_description recommened_update; + if (try_parse_update(_versions_db, _update_profile.device_name, versions_db_manager::RECOMMENDED, comp, recommened_update)) + { + versions_vec[recommened_update.ver] = recommened_update; + } + update_description required_update; + if (try_parse_update(_versions_db, _update_profile.device_name, versions_db_manager::ESSENTIAL, comp, required_update)) + { + versions_vec[required_update.ver] = required_update; + // Ignore version zero as an indication of Recovery mode. + update_required = update_required || (current_version < required_update.ver); + } } } diff --git a/common/sw-update/dev-updates-profile.h b/common/sw-update/dev-updates-profile.h index 7965200ee1b..1432c47df8f 100644 --- a/common/sw-update/dev-updates-profile.h +++ b/common/sw-update/dev-updates-profile.h @@ -41,6 +41,10 @@ namespace rs2 std::map firmware_versions; device dev; + bool dev_active; + + update_profile() :dev_active(true){}; + }; explicit dev_updates_profile(const device& dev, const std::string &url, const bool use_url_as_local_path = false, http::user_callback_func_type download_callback = http::user_callback_func_type()); diff --git a/common/sw-update/versions-db-manager.cpp b/common/sw-update/versions-db-manager.cpp index f8392697e2c..523de593485 100644 --- a/common/sw-update/versions-db-manager.cpp +++ b/common/sw-update/versions-db-manager.cpp @@ -18,7 +18,7 @@ namespace rs2 using namespace http; // Get current platform - constexpr char* PLATFORM = + constexpr const char* PLATFORM = #ifdef _WIN64 "Windows amd64"; diff --git a/common/updates-model.cpp b/common/updates-model.cpp index a477c110e79..094a71d4741 100644 --- a/common/updates-model.cpp +++ b/common/updates-model.cpp @@ -16,23 +16,12 @@ using namespace http; void updates_model::draw(ux_window& window, std::string& error_message) { // Protect resources - std::vector updates_copy; + static std::vector updates_copy; { std::lock_guard lock(_lock); updates_copy = _updates; } - // When devices model size changed reset inner variables. - static size_t prv_profiles_size(updates_copy.size()); - if (prv_profiles_size != updates_copy.size() && - _fw_update_state != fw_update_states::started) - { - _fw_update_state = fw_update_states::ready; - prv_profiles_size = updates_copy.size(); - emphasize_dismiss_text = false; - ignore = false; - } - // Prepare camera icon if (!_icon) { @@ -46,10 +35,13 @@ void updates_model::draw(ux_window& window, std::string& error_message) } const auto window_name = "Updates Window"; - + //Main window pop up only if essential updates exists - if (updates_copy.size() && !ignore) + if (!popup_opened && updates_copy.size() && !ignore) + { ImGui::OpenPopup(window_name); + popup_opened = true; + } position_params positions; @@ -71,17 +63,7 @@ void updates_model::draw(ux_window& window, std::string& error_message) if (ImGui::BeginPopupModal(window_name, nullptr, flags)) { - // End and close the pop up if no updates exists (Device removal) - if (updates_copy.size() == 0) - { - ImGui::CloseCurrentPopup(); - ImGui::EndPopup(); - ImGui::PopStyleColor(3); - ImGui::PopStyleVar(2); - std::lock_guard lock(_lock); - _updates.clear(); - return; - } + std::string title_message = "SOFTWARE UPDATES"; auto title_size = ImGui::CalcTextSize(title_message.c_str()); ImGui::SetCursorPosX(positions.w / 2 - title_size.x / 2); @@ -104,7 +86,7 @@ void updates_model::draw(ux_window& window, std::string& error_message) // Draw Left Pane // =========================================================================== - for (int i = 0; i < updates_copy.size(); i++) + for (int i = 0; i < static_cast(updates_copy.size()); i++) { auto& update = updates_copy[i]; @@ -145,17 +127,40 @@ void updates_model::draw(ux_window& window, std::string& error_message) auto& update = updates_copy[selected_index]; - // =========================================================================== - // Draw Software update Pane - // =========================================================================== - auto sw_update_needed = draw_software_section(window_name, update, positions, window); + bool sw_update_needed(false), fw_update_needed(false); - // =========================================================================== - // Draw Firmware update Pane - // =========================================================================== - auto fw_update_needed = draw_firmware_section(window_name, update, positions, window); + // Verify Device Exists + if (update.profile.dev_active || _fw_update_state == fw_update_states::started) + { + // =========================================================================== + // Draw Software update Pane + // =========================================================================== + sw_update_needed = draw_software_section(window_name, update, positions, window); + + // =========================================================================== + // Draw Firmware update Pane + // =========================================================================== + fw_update_needed = draw_firmware_section(window_name, update, positions, window); + } + else + { + ImGui::PushFont(window.get_large_font()); + ImGui::PushStyleColor(ImGuiCol_Text, white); + ImGui::SetCursorPos({ positions.orig_pos.x, positions.y0 - 100 }); + ImGui::SetWindowFontScale(1.5); + ImGui::Text("%s","THE DEVICE HAS BEEN DISCONNECTED,"); + ImGui::SetCursorPos({ positions.orig_pos.x - 100, positions.y0 - 70 }); + ImGui::Text("%s", "PLEASE RECONNECT IT OR CLOSE THE UPDATES WINDOW."); + ImGui::PopFont(); + ImGui::SetCursorPos({ positions.orig_pos.x + 230, positions.y0 }); + ImGui::SetWindowFontScale(3.); + ImGui::Text("%s", static_cast(textual_icons::lock)); + ImGui::SetWindowFontScale(1.); + ImGui::PopStyleColor(); + + } // =========================================================================== // Draw Lower Pane // =========================================================================== @@ -183,16 +188,36 @@ void updates_model::draw(ux_window& window, std::string& error_message) auto enabled = ignore || no_update_needed; if (enabled) { - if (ImGui::Button("Close", { 120, 20 })) + if (_fw_update_state != fw_update_states::started) + { + if (ImGui::Button("Close", { 120, 20 })) + { + { + std::lock_guard lock(_lock); + _updates.clear(); + } + + ImGui::CloseCurrentPopup(); + popup_opened = false; + emphasize_dismiss_text = false; + ignore = false; + _fw_update_state = fw_update_states::ready; + ignore = false; + _fw_download_progress = 0; + } + } + else { - ImGui::CloseCurrentPopup(); - std::lock_guard lock(_lock); - _updates.clear(); - ignore = false; + ImGui::PushStyleColor(ImGuiCol_Button, sensor_bg); + ImGui::Button("Close", { 120, 20 }); + ImGui::PopStyleColor(); } } else { + ImGui::PushStyleColor(ImGuiCol_Button, sensor_bg); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, sensor_bg); + if (ImGui::Button("Close", { 120, 20 })) { emphasize_dismiss_text = true; @@ -201,15 +226,15 @@ void updates_model::draw(ux_window& window, std::string& error_message) { ImGui::SetTooltip("To close this window you must install all essential update\n" "or agree to the warning of closing without it"); - window.link_hovered(); + } + ImGui::PopStyleColor(2); } ImGui::EndPopup(); } ImGui::PopStyleColor(3); ImGui::PopStyleVar(2); - } bool updates_model::draw_software_section(const char * window_name, update_profile_model& selected_profile, position_params& pos, ux_window& window) @@ -225,17 +250,48 @@ bool updates_model::draw_software_section(const char * window_name, update_profi std::sort(software_updates.begin(), software_updates.end(), [](dev_updates_profile::update_description& a, dev_updates_profile::update_description& b) { return a.ver < b.ver; }); - if (software_updates.size() <= selected_software_update_index) selected_software_update_index = 0; + if (static_cast(software_updates.size()) <= selected_software_update_index) selected_software_update_index = 0; dev_updates_profile::update_description selected_software_update; if (software_updates.size() != 0) { - bool essential_found = software_updates[0].name.find("ESSENTIAL") != std::string::npos; - essential_sw_update_needed = essential_found && (selected_profile.profile.software_version < software_updates[0].ver); + bool essential_found(false); + bool recommended_found(false); + for (auto sw_update : software_updates) + { + if (!essential_found) + { + essential_found = essential_found || sw_update.name.find("ESSENTIAL") != std::string::npos; + essential_sw_update_needed = essential_sw_update_needed || essential_found && (selected_profile.profile.software_version < sw_update.ver); + } + + if (!recommended_found) + { + recommended_found = recommended_found || sw_update.name.find("RECOMMENDED") != std::string::npos; + recommended_sw_update_needed = recommended_sw_update_needed || recommended_found && (selected_profile.profile.software_version < sw_update.ver); + } + } - bool recommended_found = software_updates[0].name.find("RECOMMENDED") != std::string::npos; - recommended_sw_update_needed = recommended_found && (selected_profile.profile.software_version < software_updates[0].ver); + // If essential update found on DB but not needed - Remove it + if (essential_found && !essential_sw_update_needed) + { + auto it = std::find_if(software_updates.begin(), software_updates.end(), [&](dev_updates_profile::update_description& u) { + return (u.name.find("ESSENTIAL") != std::string::npos); + }); + if (it != software_updates.end()) + software_updates.erase(it); + } + // If recommended update found on DB but not needed - Remove it + if (recommended_found && !recommended_sw_update_needed) + { + auto it = std::find_if(software_updates.begin(), software_updates.end(), [&](dev_updates_profile::update_description& u) { + return (u.name.find("RECOMMENDED") != std::string::npos); + }); + if (it != software_updates.end()) + software_updates.erase(it); + } + if (essential_sw_update_needed || recommended_sw_update_needed) { selected_software_update = software_updates[selected_software_update_index]; @@ -260,8 +316,10 @@ bool updates_model::draw_software_section(const char * window_name, update_profi } else { - ImGui::PushStyleColor(ImGuiCol_Text, white); - ImGui::Text(u8"\uF046 Up to date."); + ImGui::PushStyleColor(ImGuiCol_Text, light_blue); + ImGui::Text("%s", static_cast(textual_icons::check_square_o)); + ImGui::SameLine(); + ImGui::Text("%s", "Up to date."); } ImGui::PopStyleColor(); } @@ -430,7 +488,7 @@ bool updates_model::draw_software_section(const char * window_name, update_profi } ImGui::PopStyleColor(3); - ImGui::SetCursorScreenPos({ pos.orig_pos.x + 150, pos.mid_y - 25 }); + ImGui::SetCursorScreenPos({ pos.orig_pos.x + 150, pos.mid_y - 25 }); ImGui::Text("%s", "Visit the release page before download to identify the most suitable package."); } @@ -451,18 +509,49 @@ bool updates_model::draw_firmware_section(const char * window_name, update_profi std::sort(firmware_updates.begin(), firmware_updates.end(), [](dev_updates_profile::update_description& a, dev_updates_profile::update_description& b) { return a.ver < b.ver; }); - if (firmware_updates.size() <= selected_firmware_update_index) selected_firmware_update_index = 0; + if (static_cast(firmware_updates.size()) <= selected_firmware_update_index) selected_firmware_update_index = 0; dev_updates_profile::update_description selected_firmware_update; if (firmware_updates.size() != 0) { - bool essential_found = firmware_updates[0].name.find("ESSENTIAL") != std::string::npos; - essential_fw_update_needed = essential_found && (selected_profile.profile.firmware_version < firmware_updates[0].ver); + bool essential_found(false); + bool recommended_found(false); - bool recommended_found = firmware_updates[0].name.find("RECOMMENDED") != std::string::npos; - recommended_fw_update_needed = recommended_found && (selected_profile.profile.firmware_version < firmware_updates[0].ver); + for (auto fw_update : firmware_updates) + { + if (!essential_found) + { + essential_found = essential_found || fw_update.name.find("ESSENTIAL") != std::string::npos; + essential_fw_update_needed = essential_fw_update_needed || essential_found && (selected_profile.profile.firmware_version < fw_update.ver); + } + if (!recommended_found) + { + recommended_found = recommended_found || fw_update.name.find("RECOMMENDED") != std::string::npos; + recommended_fw_update_needed = recommended_fw_update_needed || recommended_found && (selected_profile.profile.firmware_version < fw_update.ver); + } + } + + // If essential update found on DB but not needed - Remove it + if (essential_found && !essential_fw_update_needed) + { + auto it = std::find_if(firmware_updates.begin(), firmware_updates.end(), [&](dev_updates_profile::update_description& u) { + return (u.name.find("ESSENTIAL") != std::string::npos); + }); + if (it != firmware_updates.end()) + firmware_updates.erase(it); + } + + // If recommended update found on DB but not needed - Remove it + if (recommended_found && !recommended_fw_update_needed) + { + auto it = std::find_if(firmware_updates.begin(), firmware_updates.end(), [&](dev_updates_profile::update_description& u) { + return (u.name.find("RECOMMENDED") != std::string::npos); + }); + if (it != firmware_updates.end()) + firmware_updates.erase(it); + } if (essential_fw_update_needed || recommended_fw_update_needed) { selected_firmware_update = firmware_updates[selected_firmware_update_index]; @@ -487,8 +576,10 @@ bool updates_model::draw_firmware_section(const char * window_name, update_profi } else { - ImGui::PushStyleColor(ImGuiCol_Text, white); - ImGui::Text(u8"\uF046 Up to date."); + ImGui::PushStyleColor(ImGuiCol_Text, light_blue); + ImGui::Text("%s", static_cast(textual_icons::check_square_o)); + ImGui::SameLine(); + ImGui::Text("%s", "Up to date."); } ImGui::PopStyleColor(); } @@ -509,7 +600,7 @@ bool updates_model::draw_firmware_section(const char * window_name, update_profi ImGui::Text("%s", "Content:"); ImGui::SameLine(); ImGui::PopStyleColor(); ImGui::Text("%s", "Signed Firmware Image (.bin file)"); - + fw_text_pos.y += 50; ImGui::SetCursorScreenPos(fw_text_pos); ImGui::PushStyleColor(ImGuiCol_Text, white); @@ -519,202 +610,199 @@ bool updates_model::draw_firmware_section(const char * window_name, update_profi auto current_fw_ver_str = std::string(selected_profile.profile.firmware_version); ImGui::Text("%s", current_fw_ver_str.c_str()); - if (essential_fw_update_needed) - { - ImGui::SameLine(); - ImGui::PushStyleColor(ImGuiCol_Text, yellowish); - ImGui::Text("%s", " (Your version is older than the minimum version required for the proper functioning of your device)"); - ImGui::PopStyleColor(); - } - - if (selected_firmware_update.ver != versions_db_manager::version(0)) + if (_fw_update_state != fw_update_states::completed) { - fw_text_pos.y += 25; - ImGui::SetCursorScreenPos(fw_text_pos); - ImGui::PushStyleColor(ImGuiCol_Text, white); - - ImGui::Text("%s", (firmware_updates.size() >= 2) ? - "Versions available:" : - "Version to download:"); - ImGui::SameLine(); - ImGui::PopStyleColor(); - // Combo box for multiple versions - if (firmware_updates.size() >= 2) + if (essential_fw_update_needed) { - std::vector fwu_labels; - for (auto&& fwu : firmware_updates) - { - fwu_labels.push_back(fwu.name.c_str()); - } - - ImGui::PushStyleColor(ImGuiCol_BorderShadow, dark_grey); - ImGui::PushStyleColor(ImGuiCol_FrameBg, sensor_bg); - - std::string combo_id = "##Firmware Update Version"; - ImGui::PushItemWidth(200); - ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 3); - ImGui::Combo(combo_id.c_str(), &selected_firmware_update_index, fwu_labels.data(), static_cast(fwu_labels.size())); - ImGui::PopItemWidth(); - ImGui::PopStyleColor(2); - ImGui::SetWindowFontScale(1.); - } - else - { // Single version - ImGui::Text("%s", std::string(selected_firmware_update.ver).c_str()); + ImGui::SameLine(); + ImGui::PushStyleColor(ImGuiCol_Text, yellowish); + ImGui::Text("%s", " (Your version is older than the minimum version required for the proper functioning of your device)"); + ImGui::PopStyleColor(); } - } - if (selected_firmware_update.release_page != "") - { - fw_text_pos.y += 25; - ImGui::SetCursorScreenPos(fw_text_pos); - ImGui::PushStyleColor(ImGuiCol_Text, white); - ImGui::Text("%s", "Release Link:"); ImGui::SameLine(); - ImGui::PopStyleColor(); - ImGui::PushStyleColor(ImGuiCol_Text, light_grey); - ImGui::Text("%s", selected_firmware_update.release_page.c_str()); + if (selected_firmware_update.ver != versions_db_manager::version(0)) + { + fw_text_pos.y += 25; + ImGui::SetCursorScreenPos(fw_text_pos); + ImGui::PushStyleColor(ImGuiCol_Text, white); - ImGui::SameLine(); - auto underline_start = ImVec2(ImGui::GetCursorScreenPos().x - (ImGui::CalcTextSize(selected_firmware_update.release_page.c_str()).x + 8), ImGui::GetCursorScreenPos().y + ImGui::GetFontSize()); - auto underline_end = ImVec2(ImGui::GetCursorScreenPos().x - 8, ImGui::GetCursorScreenPos().y + ImGui::GetFontSize()); - ImGui::GetWindowDrawList()->AddLine(underline_start, underline_end, ImColor(light_grey)); + ImGui::Text("%s", (firmware_updates.size() >= 2) ? + "Versions available:" : + "Version to download:"); + ImGui::SameLine(); + ImGui::PopStyleColor(); + // Combo box for multiple versions + if (firmware_updates.size() >= 2) + { + std::vector fwu_labels; + for (auto&& fwu : firmware_updates) + { + fwu_labels.push_back(fwu.name.c_str()); + } + ImGui::PushStyleColor(ImGuiCol_BorderShadow, dark_grey); + ImGui::PushStyleColor(ImGuiCol_FrameBg, sensor_bg); - ImGui::PopStyleColor(); - if (ImGui::IsItemHovered()) - window.link_hovered(); - if (ImGui::IsItemClicked()) - { - try - { - open_url(selected_firmware_update.release_page.c_str()); + std::string combo_id = "##Firmware Update Version"; + ImGui::PushItemWidth(200); + ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 3); + ImGui::Combo(combo_id.c_str(), &selected_firmware_update_index, fwu_labels.data(), static_cast(fwu_labels.size())); + ImGui::PopItemWidth(); + ImGui::PopStyleColor(2); + ImGui::SetWindowFontScale(1.); } - catch (...) - { - LOG_ERROR("Error opening URL: " + selected_firmware_update.release_page); + else + { // Single version + ImGui::Text("%s", std::string(selected_firmware_update.ver).c_str()); } } - } - if (selected_firmware_update.description != "") - { - fw_text_pos.y += 25; - ImGui::SetCursorScreenPos(fw_text_pos); - ImGui::PushStyleColor(ImGuiCol_Text, white); - ImGui::Text("%s", "Description:"); - ImGui::PopStyleColor(); - - ImGui::PushTextWrapPos(pos.w - 150); - ImGui::PushStyleColor(ImGuiCol_Border, transparent); - ImGui::PushStyleColor(ImGuiCol_FrameBg, transparent); - ImGui::PushStyleColor(ImGuiCol_ScrollbarBg, transparent); - ImGui::PushStyleColor(ImGuiCol_ScrollbarGrab, transparent); - ImGui::PushStyleColor(ImGuiCol_ScrollbarGrabActive, transparent); - ImGui::PushStyleColor(ImGuiCol_ScrollbarGrabHovered, transparent); - ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, regular_blue); - auto msg = selected_firmware_update.description.c_str(); - fw_text_pos.x -= 4; - fw_text_pos.y += 15; - ImGui::SetCursorScreenPos(fw_text_pos); - ImGui::InputTextMultiline("##Firmware Update Description", const_cast(msg), - strlen(msg) + 1, ImVec2(ImGui::GetContentRegionAvailWidth() - 150, 75), - ImGuiInputTextFlags_ReadOnly); - ImGui::PopStyleColor(7); - ImGui::PopTextWrapPos(); - } + if (selected_firmware_update.release_page != "") + { + fw_text_pos.y += 25; + ImGui::SetCursorScreenPos(fw_text_pos); + ImGui::PushStyleColor(ImGuiCol_Text, white); + ImGui::Text("%s", "Release Link:"); ImGui::SameLine(); + ImGui::PopStyleColor(); + ImGui::PushStyleColor(ImGuiCol_Text, light_grey); + ImGui::Text("%s", selected_firmware_update.release_page.c_str()); + ImGui::SameLine(); + auto underline_start = ImVec2(ImGui::GetCursorScreenPos().x - (ImGui::CalcTextSize(selected_firmware_update.release_page.c_str()).x + 8), ImGui::GetCursorScreenPos().y + ImGui::GetFontSize()); + auto underline_end = ImVec2(ImGui::GetCursorScreenPos().x - 8, ImGui::GetCursorScreenPos().y + ImGui::GetFontSize()); + ImGui::GetWindowDrawList()->AddLine(underline_start, underline_end, ImColor(light_grey)); - if (_fw_update_state == fw_update_states::ready && - (essential_fw_update_needed || recommended_fw_update_needed)) - { - ImGui::SetCursorScreenPos({ pos.orig_pos.x + pos.w - 150, pos.orig_pos.y + pos.h - 115 }); - ImGui::PushStyleColor(ImGuiCol_Text, white); - ImGui::PushStyleColor(ImGuiCol_Button, sensor_bg); - if (ImGui::Button("Download &\n Install", ImVec2(120, 40)) || _retry) - { - _retry = false; - auto link = selected_firmware_update.download_link; - std::thread download_thread([link, this]() { - std::vector vec; - http_downloader client; - - if (!client.download_to_bytes_vector(link, vec, - [this](uint64_t dl_current_bytes, uint64_t dl_total_bytes) -> callback_result { - _fw_download_progress = static_cast((dl_current_bytes * 100) / dl_total_bytes); - return callback_result::CONTINUE_DOWNLOAD; - })) + ImGui::PopStyleColor(); + if (ImGui::IsItemHovered()) + window.link_hovered(); + if (ImGui::IsItemClicked()) + { + try { - _fw_update_state = fw_update_states::failed_downloading; - LOG_ERROR("Error in download firmware version from: " + link); + open_url(selected_firmware_update.release_page.c_str()); } + catch (...) + { + LOG_ERROR("Error opening URL: " + selected_firmware_update.release_page); + } + } + } - _fw_image = vec; - - _fw_download_progress = 100; - }); - download_thread.detach(); + if (selected_firmware_update.description != "") + { + fw_text_pos.y += 25; + ImGui::SetCursorScreenPos(fw_text_pos); + ImGui::PushStyleColor(ImGuiCol_Text, white); + ImGui::Text("%s", "Description:"); + ImGui::PopStyleColor(); - _fw_update_state = fw_update_states::downloading; + ImGui::PushTextWrapPos(pos.w - 150); + ImGui::PushStyleColor(ImGuiCol_Border, transparent); + ImGui::PushStyleColor(ImGuiCol_FrameBg, transparent); + ImGui::PushStyleColor(ImGuiCol_ScrollbarBg, transparent); + ImGui::PushStyleColor(ImGuiCol_ScrollbarGrab, transparent); + ImGui::PushStyleColor(ImGuiCol_ScrollbarGrabActive, transparent); + ImGui::PushStyleColor(ImGuiCol_ScrollbarGrabHovered, transparent); + ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, regular_blue); + auto msg = selected_firmware_update.description.c_str(); + fw_text_pos.x -= 4; + fw_text_pos.y += 15; + ImGui::SetCursorScreenPos(fw_text_pos); + ImGui::InputTextMultiline("##Firmware Update Description", const_cast(msg), + strlen(msg) + 1, ImVec2(ImGui::GetContentRegionAvailWidth() - 150, 75), + ImGuiInputTextFlags_ReadOnly); + ImGui::PopStyleColor(7); + ImGui::PopTextWrapPos(); } - if (ImGui::IsItemHovered()) + + + if ((_fw_update_state == fw_update_states::ready) && + (essential_fw_update_needed || recommended_fw_update_needed)) { - ImGui::SetTooltip("This will download selected firmware and install it to the device"); - window.link_hovered(); + ImGui::SetCursorScreenPos({ pos.orig_pos.x + pos.w - 150, pos.orig_pos.y + pos.h - 115 }); + ImGui::PushStyleColor(ImGuiCol_Text, white); + ImGui::PushStyleColor(ImGuiCol_Button, sensor_bg); + + if (ImGui::Button("Download &\n Install", ImVec2(120, 40)) || _retry) + { + _retry = false; + auto link = selected_firmware_update.download_link; + std::thread download_thread([link, this]() { + std::vector vec; + http_downloader client; + + if (!client.download_to_bytes_vector(link, vec, + [this](uint64_t dl_current_bytes, uint64_t dl_total_bytes) -> callback_result { + _fw_download_progress = static_cast((dl_current_bytes * 100) / dl_total_bytes); + return callback_result::CONTINUE_DOWNLOAD; + })) + { + _fw_update_state = fw_update_states::failed_downloading; + LOG_ERROR("Error in download firmware version from: " + link); + } + + _fw_image = vec; + + _fw_download_progress = 100; + }); + download_thread.detach(); + + _fw_update_state = fw_update_states::downloading; + } + if (ImGui::IsItemHovered()) + { + ImGui::SetTooltip("This will download selected firmware and install it to the device"); + window.link_hovered(); + } + ImGui::PopStyleColor(2); } - ImGui::PopStyleColor(2); - } - else if (_fw_update_state == fw_update_states::downloading) - { - ImGui::SetCursorScreenPos({ pos.orig_pos.x + 150, pos.orig_pos.y + pos.h - 95 }); - _progress.draw(window, static_cast(pos.w) - 170, _fw_download_progress / 3); - if (_fw_download_progress == 100) + else if (_fw_update_state == fw_update_states::downloading) { - _fw_update_state = fw_update_states::started; - - _update_manager = std::make_shared( - *selected_profile.dev_model, selected_profile.profile.dev, selected_profile.ctx, _fw_image, true - ); - auto invoke = [](std::function action) { action(); }; - _update_manager->start(invoke); - // update.dev = rs2::device{}; - // update.dev_model->dev = rs2::device{}; - } - } - else if (_fw_update_state == fw_update_states::started) - { - ImGui::SetCursorScreenPos({ pos.orig_pos.x + 150, pos.orig_pos.y + pos.h - 95 }); - _progress.draw(window, static_cast(pos.w) - 170, static_cast(_update_manager->get_progress() * 0.66 + 33)); - if (_update_manager->done()) { - _fw_update_state = fw_update_states::completed; - } + ImGui::SetCursorScreenPos({ pos.orig_pos.x + 150, pos.orig_pos.y + pos.h - 95 }); + _progress.draw(window, static_cast(pos.w) - 170, _fw_download_progress / 3); + if (_fw_download_progress == 100) + { + _fw_update_state = fw_update_states::started; - if (_update_manager->failed()) { - _fw_update_state = fw_update_states::failed_updating; - ImGui::CloseCurrentPopup(); + _update_manager = std::make_shared( + *selected_profile.dev_model, selected_profile.profile.dev, selected_profile.ctx, _fw_image, true + ); + auto invoke = [](std::function action) { action(); }; + _update_manager->start(invoke); + } } + else if (_fw_update_state == fw_update_states::started) + { + ImGui::SetCursorScreenPos({ pos.orig_pos.x + 150, pos.orig_pos.y + pos.h - 95 }); + _progress.draw(window, static_cast(pos.w) - 170, static_cast(_update_manager->get_progress() * 0.66 + 33)); + if (_update_manager->done()) { + _fw_update_state = fw_update_states::completed; + _fw_image.clear(); + } - } - else if (_fw_update_state == fw_update_states::completed) - { - _fw_update_state = fw_update_states::ready; - ImGui::SetCursorScreenPos({ pos.orig_pos.x + 150, pos.orig_pos.y + pos.h - 95 }); - //_progress.draw(window, w - 170, 100); - } - else if (_fw_update_state == fw_update_states::failed_downloading || - _fw_update_state == fw_update_states::failed_updating) - { - ImGui::SetCursorScreenPos({ pos.orig_pos.x + 150, pos.orig_pos.y + pos.h - 95 }); - ImGui::PushStyleColor(ImGuiCol_Text, white); - std::string text = _fw_update_state == fw_update_states::failed_downloading ? - "Firmware download failed, check connection and press to retry" : - "Firmware update process failed, press to retry"; - if (ImGui::Button(text.c_str(), ImVec2(pos.w - 170, 25))) + if (_update_manager->failed()) { + _fw_update_state = fw_update_states::failed_updating; + _fw_image.clear(); + _fw_download_progress = 0; + } + + } + else if (_fw_update_state == fw_update_states::failed_downloading || + _fw_update_state == fw_update_states::failed_updating) { - _fw_update_state = fw_update_states::ready; - _retry = true; + ImGui::SetCursorScreenPos({ pos.orig_pos.x + 150, pos.orig_pos.y + pos.h - 95 }); + ImGui::PushStyleColor(ImGuiCol_Text, white); + std::string text = _fw_update_state == fw_update_states::failed_downloading ? + "Firmware download failed, check connection and press to retry" : + "Firmware update process failed, press to retry"; + if (ImGui::Button(text.c_str(), ImVec2(pos.w - 170, 25))) + { + _fw_update_state = fw_update_states::ready; + _retry = true; + } + ImGui::PopStyleColor(); } - ImGui::PopStyleColor(); } ImGui::PopStyleColor(); diff --git a/common/updates-model.h b/common/updates-model.h index 4a832ffb686..714d019206a 100644 --- a/common/updates-model.h +++ b/common/updates-model.h @@ -35,6 +35,22 @@ namespace rs2 }); if (it == _updates.end()) _updates.push_back(update); + else + { + *it = update; + } + } + + void update_profile(const update_profile_model& update) + { + std::lock_guard lock(_lock); + auto it = std::find_if(_updates.begin(), _updates.end(), [&](update_profile_model& p) { + return (p.profile.device_name == update.profile.device_name && p.profile.serial_number == update.profile.serial_number); + }); + if (it != _updates.end()) + { + *it = update; + } } void remove_profile(const sw_update::dev_updates_profile::update_profile &update) { @@ -46,6 +62,19 @@ namespace rs2 _updates.erase(it); } + // This is a helper function to indicate if a device is connected or not. + // It change its value on device connect/disconnect + // cause calling ctx.query_devices() is too slow for the UI + void set_device_status(const sw_update::dev_updates_profile::update_profile &update, bool active) + { + std::lock_guard lock(_lock); + auto it = std::find_if(_updates.begin(), _updates.end(), [&](update_profile_model& p) { + return (p.profile.device_name == update.device_name && p.profile.serial_number == update.serial_number); + }); + if (it != _updates.end()) + it->profile.dev_active = active; + } + void draw(ux_window& window, std::string& error_message); private: struct position_params @@ -71,6 +100,7 @@ namespace rs2 std::shared_ptr _icon = nullptr; std::mutex _lock; bool emphasize_dismiss_text = false; + bool popup_opened = false; std::shared_ptr _fw_update = nullptr; diff --git a/include/librealsense2/rs.h b/include/librealsense2/rs.h index ac9341f8118..6976fff8397 100644 --- a/include/librealsense2/rs.h +++ b/include/librealsense2/rs.h @@ -24,7 +24,7 @@ extern "C" { #define RS2_API_MAJOR_VERSION 2 #define RS2_API_MINOR_VERSION 35 -#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 34b07c86b81..a6180fabb72 100644 --- a/package.xml +++ b/package.xml @@ -7,7 +7,7 @@ librealsense2 - 2.35.1 + 2.35.2 Library for capturing data from the Intel(R) RealSense(TM) SR300, D400 Depth cameras and T2xx Tracking devices. This effort was initiated to better support researchers, creative coders, and app developers in domains such as robotics, virtual reality, and the internet of things. Several often-requested features of RealSense(TM); devices are implemented in this project. diff --git a/src/ds5/ds5-motion.cpp b/src/ds5/ds5-motion.cpp index 7d6d4c2efee..96fca6e4178 100644 --- a/src/ds5/ds5-motion.cpp +++ b/src/ds5/ds5-motion.cpp @@ -311,14 +311,6 @@ namespace librealsense return auto_exposure; } - std::vector ds5_motion::get_imu_eeprom_raw() const - { - const int offset = 0; - const int size = ds::eeprom_imu_table_size; - command cmd(ds::MMER, offset, size); - return _hw_monitor->send(cmd); - } - ds5_motion::ds5_motion(std::shared_ptr ctx, const platform::backend_device_group& group) : device(ctx, group), ds5_device(ctx, group), @@ -328,9 +320,7 @@ namespace librealsense { using namespace ds; - _imu_eeprom_raw = [this]() { return get_imu_eeprom_raw(); }; - - _mm_calib = std::make_shared(*_imu_eeprom_raw,_device_capabilities); + _mm_calib = std::make_shared(_hw_monitor,_device_capabilities); _accel_intrinsic = std::make_shared>([this]() { return _mm_calib->get_intrinsic(RS2_STREAM_ACCEL); }); _gyro_intrinsic = std::make_shared>([this]() { return _mm_calib->get_intrinsic(RS2_STREAM_GYRO); }); @@ -451,10 +441,10 @@ namespace librealsense _fisheye_device_idx = add_sensor(fisheye_ep); } - mm_calib_handler::mm_calib_handler(std::vector imu_raw, ds::d400_caps dev_cap) : - _dev_cap(dev_cap) + mm_calib_handler::mm_calib_handler(std::shared_ptr hw_monitor, ds::d400_caps dev_cap) : + _hw_monitor(hw_monitor), _dev_cap(dev_cap) { - _imu_eeprom_raw = imu_raw; + _imu_eeprom_raw = [this]() { return get_imu_eeprom_raw(); }; _calib_parser = [this]() { @@ -464,7 +454,7 @@ namespace librealsense try { - raw = _imu_eeprom_raw; + raw = *_imu_eeprom_raw; calib_id = *reinterpret_cast(raw.data()); valid = true; } @@ -480,8 +470,6 @@ namespace librealsense prs = std::make_shared(raw, _dev_cap, valid); break; case ds::tm1_eeprom_id: // TM1 id prs = std::make_shared(raw); break; - case ds::l500_eeprom_id: // L515 - prs = std::make_shared(raw); break; default: throw recoverable_exception(to_string() << "Motion Intrinsics unresolved - " << ((valid)? "device is not calibrated" : "invalid calib type "), @@ -491,6 +479,14 @@ namespace librealsense }; } + std::vector mm_calib_handler::get_imu_eeprom_raw() const + { + const int offset = 0; + const int size = ds::eeprom_imu_table_size; + command cmd(ds::MMER, offset, size); + return _hw_monitor->send(cmd); + } + ds::imu_intrinsic mm_calib_handler::get_intrinsic(rs2_stream stream) { return (*_calib_parser)->get_intrinsic(stream); @@ -503,7 +499,7 @@ namespace librealsense const std::vector mm_calib_handler::get_fisheye_calib_raw() { - auto fe_calib_table = (*(ds::check_calib(_imu_eeprom_raw))).calibration_table.calib_model.fe_calibration; + auto fe_calib_table = (*(ds::check_calib(*_imu_eeprom_raw))).calibration_table.calib_model.fe_calibration; uint8_t* fe_calib_ptr = reinterpret_cast(&fe_calib_table); return std::vector(fe_calib_ptr, fe_calib_ptr+ ds::fisheye_calibration_table_size); } diff --git a/src/ds5/ds5-motion.h b/src/ds5/ds5-motion.h index 77a45bc90fb..dc767def477 100644 --- a/src/ds5/ds5-motion.h +++ b/src/ds5/ds5-motion.h @@ -193,63 +193,10 @@ namespace librealsense float3x3 _imu_2_depth_rot; }; - class l500_imu_calib_parser : public mm_calib_parser - { - public: - l500_imu_calib_parser(const std::vector& raw_data) - { - imu_calib_table = *(ds::check_calib(raw_data)); - - // TODO - need to check mechanical drawing for extrinsic and orientation - // Bosch BMI055 - // L515 specific - BMI055 assembly transformation based on mechanical drawing (mm) - _def_extr = { { 1, 0, 0, 0, 1, 0, 0, 0, 1 },{ -0.01245f, 0.01642f, 0.02093f } }; - _imu_2_depth_rot = { { 1,0,0 },{ 0,1,0 },{ 0,0,1 } }; - } - - virtual ~l500_imu_calib_parser() {} - - float3x3 imu_to_depth_alignment() { return _imu_2_depth_rot; } - - ds::imu_intrinsic get_intrinsic(rs2_stream stream) - { - ds::dm_v2_imu_intrinsic in_intr; - switch (stream) - { - case RS2_STREAM_ACCEL: - in_intr = imu_calib_table.accel_intrinsic; break; - case RS2_STREAM_GYRO: - in_intr = imu_calib_table.gyro_intrinsic; - in_intr.bias = in_intr.bias * static_cast(d2r); // The gyro bias is calculated in Deg/sec - break; - default: - throw std::runtime_error(to_string() << "L515 does not provide intrinsic for stream type : " << rs2_stream_to_string(stream) << " !"); - } - - return{ in_intr.sensitivity, in_intr.bias,{ 0,0,0 },{ 0,0,0 } }; - } - - rs2_extrinsics get_extrinsic_to(rs2_stream stream) - { - if (!(RS2_STREAM_ACCEL == stream) && !(RS2_STREAM_GYRO == stream)) - throw std::runtime_error(to_string() << "L515 does not support extrinsic for : " << rs2_stream_to_string(stream) << " !"); - - rs2_extrinsics extr; - LOG_INFO("IMU extrinsic using CAD values"); - extr = _def_extr; - return extr; - } - - private: - ds::dm_v2_calibration_table imu_calib_table; - rs2_extrinsics _def_extr; - float3x3 _imu_2_depth_rot; - }; - class mm_calib_handler { public: - mm_calib_handler(std::vector imu_raw, ds::d400_caps dev_cap = ds::d400_caps::CAP_UNDEFINED); + mm_calib_handler(std::shared_ptr hw_monitor, ds::d400_caps dev_cap); ~mm_calib_handler() {} ds::imu_intrinsic get_intrinsic(rs2_stream); @@ -258,9 +205,11 @@ namespace librealsense float3x3 imu_to_depth_alignment() { return (*_calib_parser)->imu_to_depth_alignment(); } private: + std::shared_ptr _hw_monitor; ds::d400_caps _dev_cap; lazy< std::shared_ptr> _calib_parser; - std::vector _imu_eeprom_raw; + lazy> _imu_eeprom_raw; + std::vector get_imu_eeprom_raw() const; lazy> _fisheye_calibration_table_raw; }; @@ -289,9 +238,6 @@ namespace librealsense optional_value _fisheye_device_idx; optional_value _motion_module_device_idx; - std::vector get_imu_eeprom_raw() const; - lazy> _imu_eeprom_raw; - std::shared_ptr _mm_calib; std::shared_ptr> _accel_intrinsic; std::shared_ptr> _gyro_intrinsic; diff --git a/src/ds5/ds5-options.h b/src/ds5/ds5-options.h index 6325e7f9a2c..6cd0e815d66 100644 --- a/src/ds5/ds5-options.h +++ b/src/ds5/ds5-options.h @@ -54,6 +54,26 @@ namespace librealsense hid_sensor& _ep; }; + class enable_motion_correction : public option_base + { + public: + void set(float value) override; + + float query() const override; + + bool is_enabled() const override { return true; } + + const char* get_description() const override + { + return "Enable/Disable Automatic Motion Data Correction"; + } + + enable_motion_correction(sensor_base* mm_ep, const option_range& opt_range); + + private: + std::atomic _is_active; + }; + class enable_auto_exposure_option : public option_base { public: diff --git a/src/ds5/ds5-private.h b/src/ds5/ds5-private.h index 38f0e098810..05a89e5879c 100644 --- a/src/ds5/ds5-private.h +++ b/src/ds5/ds5-private.h @@ -561,8 +561,7 @@ namespace librealsense enum imu_eeprom_id : uint16_t { dm_v2_eeprom_id = 0x0101, // The pack alignment is Big-endian - tm1_eeprom_id = 0x0002, - l500_eeprom_id = 0x0105 + tm1_eeprom_id = 0x0002 }; struct depth_table_control diff --git a/src/l500/l500-device.cpp b/src/l500/l500-device.cpp index 3dd1d3933d1..9a1187f712d 100644 --- a/src/l500/l500-device.cpp +++ b/src/l500/l500-device.cpp @@ -21,6 +21,8 @@ #include "proc/syncer-processing-block.h" #include "proc/rotation-transform.h" #include "fw-update/fw-update-unsigned.h" +#include "../common/fw/firmware-version.h" + namespace librealsense { @@ -89,6 +91,7 @@ namespace librealsense auto asic_serial = _hw_monitor->get_module_serial_string(gvd_buff, module_asic_serial_offset, module_serial_size); auto fwv = _hw_monitor->get_firmware_version_string(gvd_buff, fw_version_offset); _fw_version = firmware_version(fwv); + firmware_version recommended_fw_version(L5XX_RECOMMENDED_FIRMWARE_VERSION); _is_locked = _hw_monitor->get_gvd_field(gvd_buff, is_camera_locked_offset); @@ -113,6 +116,7 @@ namespace librealsense register_info(RS2_CAMERA_INFO_ASIC_SERIAL_NUMBER, asic_serial); register_info(RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID, asic_serial); register_info(RS2_CAMERA_INFO_FIRMWARE_VERSION, _fw_version); + register_info(RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION, recommended_fw_version); register_info(RS2_CAMERA_INFO_DEBUG_OP_CODE, std::to_string(static_cast(fw_cmd::GLD))); register_info(RS2_CAMERA_INFO_PHYSICAL_PORT, group.uvc_devices.front().device_path); register_info(RS2_CAMERA_INFO_PRODUCT_ID, pid_hex_str); diff --git a/src/l500/l500-device.h b/src/l500/l500-device.h index cce7590a985..73a62a1ab76 100644 --- a/src/l500/l500-device.h +++ b/src/l500/l500-device.h @@ -71,7 +71,6 @@ namespace librealsense lazy> _calib_table_raw; firmware_version _fw_version; - std::shared_ptr _depth_stream; std::shared_ptr _ir_stream; std::shared_ptr _confidence_stream; diff --git a/src/l500/l500-motion.cpp b/src/l500/l500-motion.cpp index f45d6b5ba80..25042578608 100644 --- a/src/l500/l500-motion.cpp +++ b/src/l500/l500-motion.cpp @@ -93,14 +93,6 @@ namespace librealsense const l500_motion* _owner; }; - std::vector l500_motion::get_imu_eeprom_raw() const - { - // read imu calibration table on L515 - // READ_TABLE 0x243 0 - command cmd(ivcam2::READ_TABLE, 0x243, 0); - return _hw_monitor->send(cmd); - } - std::shared_ptr l500_motion::create_hid_device(std::shared_ptr ctx, const std::vector& all_hid_infos) { if (all_hid_infos.empty()) @@ -125,32 +117,16 @@ namespace librealsense hid_ep->get_option(RS2_OPTION_GLOBAL_TIME_ENABLED).set(0); hid_ep->register_option(RS2_OPTION_GLOBAL_TIME_ENABLED, enable_global_time_option); - // register pre-processing - bool enable_imu_correction = false; - std::shared_ptr mm_correct_opt = nullptr; - - // Motion intrinsic calibration presents is a prerequisite for motion correction. - try - { - // Writing to log to dereference underlying structure - LOG_INFO("Accel Sensitivity:" << (**_accel_intrinsic).sensitivity); - LOG_INFO("Gyro Sensitivity:" << (**_gyro_intrinsic).sensitivity); - - mm_correct_opt = std::make_shared(hid_ep.get(), option_range{ 0, 1, 1, 1 }); - hid_ep->register_option(RS2_OPTION_ENABLE_MOTION_CORRECTION, mm_correct_opt); - } - catch (...) {} - hid_ep->register_processing_block( { {RS2_FORMAT_MOTION_XYZ32F, RS2_STREAM_ACCEL} }, { {RS2_FORMAT_MOTION_XYZ32F, RS2_STREAM_ACCEL} }, - [&, mm_correct_opt]() { return std::make_shared(_mm_calib, mm_correct_opt); } + []() { return std::make_shared(); } ); hid_ep->register_processing_block( { {RS2_FORMAT_MOTION_XYZ32F, RS2_STREAM_GYRO} }, { {RS2_FORMAT_MOTION_XYZ32F, RS2_STREAM_GYRO} }, - [&, mm_correct_opt]() { return std::make_shared(_mm_calib, mm_correct_opt); } + []() { return std::make_shared(); } ); return hid_ep; @@ -161,21 +137,6 @@ namespace librealsense _accel_stream(new stream(RS2_STREAM_ACCEL)), _gyro_stream(new stream(RS2_STREAM_GYRO)) { - _imu_eeprom_raw = [this]() { return get_imu_eeprom_raw(); }; - - _mm_calib = std::make_shared(*_imu_eeprom_raw); - - _accel_intrinsic = std::make_shared>([this]() { return _mm_calib->get_intrinsic(RS2_STREAM_ACCEL); }); - _gyro_intrinsic = std::make_shared>([this]() { return _mm_calib->get_intrinsic(RS2_STREAM_GYRO); }); - // use predefined values extrinsics - _depth_to_imu = std::make_shared>([this]() { return _mm_calib->get_extrinsic(RS2_STREAM_ACCEL); }); - - // Make sure all MM streams are positioned with the same extrinsics - environment::get_instance().get_extrinsics_graph().register_extrinsics(*_depth_stream, *_accel_stream, _depth_to_imu); - environment::get_instance().get_extrinsics_graph().register_same_extrinsics(*_accel_stream, *_gyro_stream); - register_stream_to_extrinsic_group(*_gyro_stream, 0); - register_stream_to_extrinsic_group(*_accel_stream, 0); - auto hid_ep = create_hid_device(ctx, group.hid_devices); if (hid_ep) { diff --git a/src/l500/l500-motion.h b/src/l500/l500-motion.h index 500f93404ad..aaa276e20e5 100644 --- a/src/l500/l500-motion.h +++ b/src/l500/l500-motion.h @@ -8,7 +8,6 @@ #include "device.h" #include "stream.h" #include "l500/l500-device.h" -#include "../ds5/ds5-motion.h" namespace librealsense { @@ -31,14 +30,6 @@ namespace librealsense optional_value _motion_module_device_idx; - std::vector get_imu_eeprom_raw() const; - lazy> _imu_eeprom_raw; - - std::shared_ptr _mm_calib; - std::shared_ptr> _accel_intrinsic; - std::shared_ptr> _gyro_intrinsic; - std::shared_ptr> _depth_to_imu; // Mechanical installation pose - protected: std::shared_ptr _accel_stream; std::shared_ptr _gyro_stream; diff --git a/src/l500/l500-private.h b/src/l500/l500-private.h index 59f72438418..714190c8c75 100644 --- a/src/l500/l500-private.h +++ b/src/l500/l500-private.h @@ -54,7 +54,6 @@ namespace librealsense AMCSET = 0x2B, // Set options (L515) AMCGET = 0x2C, // Get options (L515) PFD = 0x3B, // Disable power features - READ_TABLE = 0x43, // read table from flash, for example, read imu calibration table, read_table 0x243 0 DPT_INTRINSICS_GET = 0x5A, TEMPERATURES_GET = 0x6A, DPT_INTRINSICS_FULL_GET = 0x7F, diff --git a/src/option.h b/src/option.h index 3e86c8d0486..51ea773ea80 100644 --- a/src/option.h +++ b/src/option.h @@ -551,24 +551,4 @@ namespace librealsense float _manual_value; std::function _recording_function = [](const option&) {}; }; - - class enable_motion_correction : public option_base - { - public: - void set(float value) override; - - float query() const override; - - bool is_enabled() const override { return true; } - - const char* get_description() const override - { - return "Enable/Disable Automatic Motion Data Correction"; - } - - enable_motion_correction(sensor_base* mm_ep, const option_range& opt_range); - - private: - std::atomic _is_active; - }; } diff --git a/src/proc/motion-transform.cpp b/src/proc/motion-transform.cpp index a51690a2e78..9e87c32e402 100644 --- a/src/proc/motion-transform.cpp +++ b/src/proc/motion-transform.cpp @@ -62,6 +62,7 @@ namespace librealsense } else { + // TODO Define L500 base transformation alignment _imu2depth_cs_alignment_matrix = { {1,0,0},{0,1,0}, {0,0,1} }; } } diff --git a/tools/realsense-viewer/realsense-viewer.cpp b/tools/realsense-viewer/realsense-viewer.cpp index 02083e195a8..6553d579b76 100644 --- a/tools/realsense-viewer/realsense-viewer.cpp +++ b/tools/realsense-viewer/realsense-viewer.cpp @@ -28,9 +28,11 @@ #ifdef INTERNAL_FW #include "common/fw/D4XX_FW_Image.h" #include "common/fw/SR3XX_FW_Image.h" +#include "common/fw/L5XX_FW_Image.h" #else #define FW_D4XX_FW_IMAGE_VERSION "" #define FW_SR3XX_FW_IMAGE_VERSION "" +#define FW_L5XX_FW_IMAGE_VERSION "" #endif // INTERNAL_FW #include