Skip to content

Commit

Permalink
Avoid to download the robot and the network models if the tests are n…
Browse files Browse the repository at this point in the history
…ot enabled in ML component (#749)
  • Loading branch information
GiulioRomualdi authored Nov 6, 2023
1 parent 49b6ae8 commit 9f9e90d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 31 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
67 changes: 36 additions & 31 deletions src/ML/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 9f9e90d

Please sign in to comment.