Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable test for model generation #22

Merged
merged 9 commits into from
Jan 10, 2023
Merged
16 changes: 11 additions & 5 deletions .github/workflows/generate_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,25 @@ name: Automatically generate models and commit to the repo

# Controls when the workflow will run
on:
pull_request:
paths:
- 'urdf/simmechanics/**'
push:
# Triggers the workflow on push or pull request events but only for the master branch
branches:
- master
paths:
- 'urdf/simmechanics/**'

defaults:
run:
shell: bash -el {0}

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
generate_models:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2
Expand All @@ -29,12 +34,11 @@ jobs:
channel-priority: true

- name: Dependencies
shell: bash
run: |
# Workaround for https://github.com/conda-incubator/setup-miniconda/issues/186
conda config --remove channels defaults
# Actual dependencies
mamba install python=3.8 yarp idyntree ruby
mamba install python=3.8 yarp idyntree ruby cmake compilers make

- name: Generate models
run: |
Expand Down Expand Up @@ -64,11 +68,13 @@ jobs:
# Prepare ergocub-software build
mkdir build
cd build
cmake -DERGOCUB_MODEL_GENERATE_SIMMECHANICS=BOOL:ON -DERGOCUB_MODEL_COPY_TO_SRC=BOOL:ON ..
cmake -DERGOCUB_MODEL_GENERATE_SIMMECHANICS=BOOL:ON -DERGOCUB_MODEL_COPY_TO_SRC=BOOL:ON -DBUILD_TESTING=BOOL:ON ..
# Build and run
make VERBOSE=1
ctest --output-on-failure

- name: Create Pull Request
if: ${{ github.event_name == 'push' }}
id: cpr
uses: peter-evans/create-pull-request@main
with:
Expand Down
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ option(ERGOCUB_MODEL_GENERATE_SIMMECHANICS "Generate models using the model gene
option(ERGOCUB_MODEL_COPY_TO_SRC "Copy to sources the generated urdf files" OFF)
option(BUILD_TESTING "Run tests for the generated models" OFF)

set(BUILD_PREFIX "ergoCub")
add_subdirectory(urdf)

# TODO to be defined
#if (BUILD_TESTING)
# include( CTest )
# enable_testing()
# add_subdirectory(tests)
#endif()
if (BUILD_TESTING)
include( CTest )
enable_testing()
add_subdirectory(tests)
endif()
18 changes: 18 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Tests for generated models
# We use iDynTree & YARP for the tests
find_package(iDynTree REQUIRED)
find_package(YARP REQUIRED)

add_executable(ergocub-model-test ergocub-model-test.cpp)
target_link_libraries(ergocub-model-test ${iDynTree_LIBRARIES} YARP::YARP_os)

macro(add_ergocub_model_test yarpRobotName)
add_test(NAME ${yarpRobotName}ConsistencyCheck
COMMAND ergocub-model-test --model ${CMAKE_BINARY_DIR}/${BUILD_PREFIX}/robots/${yarpRobotName}/model.urdf)
endmacro()

# Model generated with simmechanics
if( ERGOCUB_MODEL_GENERATE_SIMMECHANICS )
add_ergocub_model_test(ergoCubGazeboV1)
add_ergocub_model_test(ergoCubSN000)
endif()
Loading