From 9f9e90dd960df084b052ed2efd3eb9550f309da8 Mon Sep 17 00:00:00 2001 From: Giulio Romualdi Date: Mon, 6 Nov 2023 10:18:56 +0100 Subject: [PATCH] Avoid to download the robot and the network models if the tests are not enabled in ML component (#749) --- CHANGELOG.md | 2 ++ src/ML/tests/CMakeLists.txt | 67 ++++++++++++++++++++----------------- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c022de4b32..345c92baf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ All notable changes to this project are documented in this file. - Remove outdated tests for `RobotDynamicsEstimator` library (https://github.com/ami-iit/bipedal-locomotion-framework/pull/742) - Modify CI to install `RobotDynamicsEstimator` library (https://github.com/ami-iit/bipedal-locomotion-framework/pull/746) - Restructure the balancing-position-control script (https://github.com/ami-iit/bipedal-locomotion-framework/pull/716) +- Avoid to download the robot and the network models if the tests are not enabled in `ML` component (https://github.com/ami-iit/bipedal-locomotion-framework/pull/749) + ### Fixed - Fix timestamp logging for the cameras (https://github.com/ami-iit/bipedal-locomotion-framework/pull/748) diff --git a/src/ML/tests/CMakeLists.txt b/src/ML/tests/CMakeLists.txt index d92ac8054f..3491d5e634 100644 --- a/src/ML/tests/CMakeLists.txt +++ b/src/ML/tests/CMakeLists.txt @@ -2,38 +2,43 @@ # This software may be modified and distributed under the terms of the # BSD-3-Clause license. -include_directories(${CMAKE_CURRENT_BINARY_DIR}) -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/FolderPath.h.in" "${CMAKE_CURRENT_BINARY_DIR}/FolderPath.h" @ONLY) - -set(MANN_ONNX_EXPECTED_MD5 d66042fdcd270d20b86e65b674eaa3fa) -if (EXISTS "${CMAKE_CURRENT_BINARY_DIR}/model.onnx") - file(MD5 "${CMAKE_CURRENT_BINARY_DIR}/model.onnx" ONNX_MODEL_CHECKSUM_VARIABLE) - string(COMPARE EQUAL ${ONNX_MODEL_CHECKSUM_VARIABLE} ${MANN_ONNX_EXPECTED_MD5} MANN_ONNX_UPDATED) -else() - set(MANN_ONNX_UPDATED FALSE) -endif() - -if(NOT ${MANN_ONNX_UPDATED}) - message(STATUS "Fetching MANN onnx model from huggingface.co/ami-iit/mann...") - file(DOWNLOAD https://huggingface.co/ami-iit/mann/resolve/3a6fa8fe38d39deae540e4aca06063e9f2b53380/ergocubSN000_26j_49e.onnx - ${CMAKE_CURRENT_BINARY_DIR}/model.onnx - EXPECTED_MD5 ${MANN_ONNX_EXPECTED_MD5}) -endif() - - -set(ERGOCUB_MODEL_EXPECTED_MD5 7d24f42cb415e660abc4bbc8a52d355f) -if (EXISTS "${CMAKE_CURRENT_BINARY_DIR}/model.urdf") - file(MD5 "${CMAKE_CURRENT_BINARY_DIR}/model.urdf" ERGOCUB_MODEL_CHECKSUM_VARIABLE) - string(COMPARE EQUAL ${ERGOCUB_MODEL_CHECKSUM_VARIABLE} ${ERGOCUB_MODEL_EXPECTED_MD5} ERGOCUB_MODEL_UPDATED) -else() - set(ERGOCUB_MODEL_UPDATED FALSE) -endif() -if(NOT ${ERGOCUB_MODEL_UPDATED}) - message(STATUS "Fetching ergoCubSN000 model from icub-tech-iit/ergocub-software...") - file(DOWNLOAD https://raw.githubusercontent.com/icub-tech-iit/ergocub-software/f28733afcbbfcc99cbac13be530a6a072f832746/urdf/ergoCub/robots/ergoCubSN000/model.urdf - ${CMAKE_CURRENT_BINARY_DIR}/model.urdf - EXPECTED_MD5 ${ERGOCUB_MODEL_EXPECTED_MD5}) +# The following is required only for testing +if(BUILD_TESTING) + include_directories(${CMAKE_CURRENT_BINARY_DIR}) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/FolderPath.h.in" "${CMAKE_CURRENT_BINARY_DIR}/FolderPath.h" @ONLY) + + # Get the onnx model of the network + set(MANN_ONNX_EXPECTED_MD5 d66042fdcd270d20b86e65b674eaa3fa) + if (EXISTS "${CMAKE_CURRENT_BINARY_DIR}/model.onnx") + file(MD5 "${CMAKE_CURRENT_BINARY_DIR}/model.onnx" ONNX_MODEL_CHECKSUM_VARIABLE) + string(COMPARE EQUAL ${ONNX_MODEL_CHECKSUM_VARIABLE} ${MANN_ONNX_EXPECTED_MD5} MANN_ONNX_UPDATED) + else() + set(MANN_ONNX_UPDATED FALSE) + endif() + + if(NOT ${MANN_ONNX_UPDATED}) + message(STATUS "Fetching MANN onnx model from huggingface.co/ami-iit/mann...") + file(DOWNLOAD https://huggingface.co/ami-iit/mann/resolve/3a6fa8fe38d39deae540e4aca06063e9f2b53380/ergocubSN000_26j_49e.onnx + ${CMAKE_CURRENT_BINARY_DIR}/model.onnx + EXPECTED_MD5 ${MANN_ONNX_EXPECTED_MD5}) + endif() + + # Get the urdf model of the robot + set(ERGOCUB_MODEL_EXPECTED_MD5 7d24f42cb415e660abc4bbc8a52d355f) + if (EXISTS "${CMAKE_CURRENT_BINARY_DIR}/model.urdf") + file(MD5 "${CMAKE_CURRENT_BINARY_DIR}/model.urdf" ERGOCUB_MODEL_CHECKSUM_VARIABLE) + string(COMPARE EQUAL ${ERGOCUB_MODEL_CHECKSUM_VARIABLE} ${ERGOCUB_MODEL_EXPECTED_MD5} ERGOCUB_MODEL_UPDATED) + else() + set(ERGOCUB_MODEL_UPDATED FALSE) + endif() + + if(NOT ${ERGOCUB_MODEL_UPDATED}) + message(STATUS "Fetching ergoCubSN000 model from icub-tech-iit/ergocub-software...") + file(DOWNLOAD https://raw.githubusercontent.com/icub-tech-iit/ergocub-software/f28733afcbbfcc99cbac13be530a6a072f832746/urdf/ergoCub/robots/ergoCubSN000/model.urdf + ${CMAKE_CURRENT_BINARY_DIR}/model.urdf + EXPECTED_MD5 ${ERGOCUB_MODEL_EXPECTED_MD5}) + endif() endif() add_bipedal_test(