Skip to content

Commit

Permalink
Refactor the repo for using creo2urdf instead of simmechanics (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicogene committed Aug 29, 2023
1 parent b8c9fc0 commit d82ce6a
Show file tree
Hide file tree
Showing 214 changed files with 16,350 additions and 471,535 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ name: C++ CI Workflow with conda dependencies

on:
push:
paths:
- 'src/**'
branches:
- master
pull_request:
paths:
- 'src/**'
types: [opened, reopened, synchronize, ready_for_review]

schedule:
# * is a special character in YAML so you have to quote this string
# Execute a "nightly" build at 2 AM UTC
- cron: '0 2 * * *'

jobs:
jobs:
build:
name: '[${{ matrix.os }}@${{ matrix.build_type }}@conda]'
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -40,7 +40,7 @@ jobs:
# Compilation related dependencies
mamba install cmake compilers make ninja pkg-config
# Actual dependencies
mamba install ycm-cmake-modules yarp opencv
mamba install ycm-cmake-modules yarp opencv idyntree
- name: Configure [Linux&macOS]
if: contains(matrix.os, 'macos') || contains(matrix.os, 'ubuntu')
Expand All @@ -49,7 +49,7 @@ jobs:
mkdir -p build
cd build
cmake -GNinja -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCOMPILE_ergoCubEmotions:BOOL=ON ..
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCOMPILE_ergoCubEmotions:BOOL=ON -DBUILD_TESTING:BOOL=ON ..
- name: Configure [Windows]
if: contains(matrix.os, 'windows')
Expand All @@ -58,7 +58,7 @@ jobs:
mkdir -p build
cd build
cmake -G"Visual Studio 16 2019" -DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCOMPILE_ergoCubEmotions:BOOL=ON ..
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCOMPILE_ergoCubEmotions:BOOL=ON -DBUILD_TESTING:BOOL=ON ..
- name: Build
shell: bash -l {0}
Expand All @@ -72,6 +72,13 @@ jobs:
cd build
cmake --build . --config ${{ matrix.build_type }} --target install
- name: Test
shell: bash -l {0}
if: contains(matrix.os, 'ubuntu')
run: |
cd build
ctest --output-on-failure
Expand Down
92 changes: 0 additions & 92 deletions .github/workflows/generate_models.yml

This file was deleted.

8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

include(AddUninstallTarget)

option(ERGOCUB_MODEL_GENERATE_SIMMECHANICS "Generate models using the model generation pipeline from simmechanics" OFF)
option(ERGOCUB_MODEL_COPY_TO_SRC "Copy to sources the generated urdf files" OFF)
option(BUILD_TESTING "Run tests for the generated models" OFF)
option(COMPILE_ergoCubEmotions "Compile the module controlling the ergoCub emotions" OFF)

Expand All @@ -31,10 +29,10 @@ add_subdirectory(urdf)
# See https://github.com/robotology/icub-models/issues/177
# and https://github.com/icub-tech-iit/ergocub-software/issues/59
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/ergoCub_empty_file "")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ergoCub_empty_file
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ergoCub_empty_file
DESTINATION share/ament_index/resource_index/packages
RENAME ergoCub)

# TODO to be defined
if (BUILD_TESTING)
include( CTest )
Expand All @@ -44,6 +42,6 @@ endif()

if(COMPILE_ergoCubEmotions)
add_subdirectory(src)
endif()
endif()


20 changes: 2 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,8 @@ yarprobotinterface --config conf/launch_wholebodydynamics_ecub.xml
```

## URDF generation
This repo hosts the `ergoCub` urdf, enabling the cmake flag `ERGOCUB_MODEL_GENERATE_SIMMECHANICS` it is possible to generate it from simmechanics xml.
Enabling also `ERGOCUB_MODEL_COPY_TO_SRC` the generated models are copied in the `urdf` directory for being committed.
### Dependencies
- [Ruby](https://www.ruby-lang.org/en/)
- [iDynTree](https://github.com/robotology/idyntree)
- [YARP](https://github.com/robotology/yarp)
- [simmechanics-to-urdf](https://github.com/robotology/simmechanics-to-urdf)
### Usage
```sh
mkdir build
cd build
cmake -DERGOCUB_MODEL_GENERATE_SIMMECHANICS=BOOL:ON -DERGOCUB_MODEL_COPY_TO_SRC=BOOL:ON ..
make
(make install)
```

### Automatic generation
[This GitHub Action](/.github/workflows/generate_models.yml) generates automatically the urdf everytime a commit in `urdf/simmechanics` on master branch is done and opens a PR containing the changes in the models.
This repository hosts the configuration files for generating ergoCub urdf via [`creo2urdf`](https://github.com/icub-tech-iit/creo2urdf).
You can find there the relative documentation on how write those configuration files.

### Maintainers
This repository is maintained by:
Expand Down
9 changes: 5 additions & 4 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ macro(add_ergocub_model_test yarpRobotName)
endmacro()

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

44 changes: 33 additions & 11 deletions tests/ergocub-model-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
#include <cmath>
#include <cstdlib>

bool isergoCub1_1Model(const std::string& modelPath)
{
return (modelPath.find("SN001") != std::string::npos ||
modelPath.find("GazeboV1_1") != std::string::npos);
}

inline bool checkDoubleAreEqual(const double & val1,
const double & val2,
const double tol)
Expand Down Expand Up @@ -226,7 +232,7 @@ bool checkSolesAreParallel(iDynTree::KinDynComputations & comp)



bool checkAxisDirections(iDynTree::KinDynComputations & comp)
bool checkAxisDirections(iDynTree::KinDynComputations & comp, bool isergoCub1_1Model)
{

std::vector<std::string> axisNames;
Expand Down Expand Up @@ -287,10 +293,27 @@ bool checkAxisDirections(iDynTree::KinDynComputations & comp)
expectedDirectionInRootLink.push_back(iDynTree::Direction(-0.116648,0.227771,0.966702));
axisNames.push_back("r_thumb_add");
expectedDirectionInRootLink.push_back(iDynTree::Direction(-0.329847,0.160871,0.930227));
axisNames.push_back("r_thumb_prox");
expectedDirectionInRootLink.push_back(iDynTree::Direction(-0.525416,0.838737,-0.143034));
axisNames.push_back("r_thumb_dist");
expectedDirectionInRootLink.push_back(iDynTree::Direction(-0.525416,0.838737,-0.143034));
if (!isergoCub1_1Model) {
axisNames.push_back("r_thumb_prox");
expectedDirectionInRootLink.push_back(iDynTree::Direction(-0.525416,0.838737,-0.143034));
axisNames.push_back("r_thumb_dist");
expectedDirectionInRootLink.push_back(iDynTree::Direction(-0.525416,0.838737,-0.143034));
axisNames.push_back("l_thumb_prox");
expectedDirectionInRootLink.push_back(iDynTree::Direction(0.525416,0.838737,0.143034));
axisNames.push_back("l_thumb_dist");
expectedDirectionInRootLink.push_back(iDynTree::Direction(0.525416,0.838737,0.143034));
}
else {
axisNames.push_back("r_thumb_prox");
expectedDirectionInRootLink.push_back(iDynTree::Direction(-0.439716,0.892571,-0.0998355));
axisNames.push_back("r_thumb_dist");
expectedDirectionInRootLink.push_back(iDynTree::Direction(-0.439716,0.892571,-0.0998355));
axisNames.push_back("l_thumb_prox");
expectedDirectionInRootLink.push_back(iDynTree::Direction(0.439716,0.892571,0.0998355));
axisNames.push_back("l_thumb_dist");
expectedDirectionInRootLink.push_back(iDynTree::Direction(0.439716,0.892571,0.0998355));

}
axisNames.push_back("r_index_add");
expectedDirectionInRootLink.push_back(iDynTree::Direction(0.250563,-0.935113,0.250563));
axisNames.push_back("r_index_prox");
Expand Down Expand Up @@ -323,10 +346,6 @@ bool checkAxisDirections(iDynTree::KinDynComputations & comp)
expectedDirectionInRootLink.push_back(iDynTree::Direction(0.116648,0.227771,-0.966702));
axisNames.push_back("l_thumb_add");
expectedDirectionInRootLink.push_back(iDynTree::Direction(0.329847,0.160871,-0.930227));
axisNames.push_back("l_thumb_prox");
expectedDirectionInRootLink.push_back(iDynTree::Direction(0.525416,0.838737,0.143034));
axisNames.push_back("l_thumb_dist");
expectedDirectionInRootLink.push_back(iDynTree::Direction(0.525416,0.838737,0.143034));
axisNames.push_back("l_index_add");
expectedDirectionInRootLink.push_back(iDynTree::Direction(-0.250563,-0.935113,-0.250563));
axisNames.push_back("l_index_prox");
Expand Down Expand Up @@ -550,11 +569,14 @@ bool checkFTMeasurementFrameGivenBySensorTagsIsCoherentWithMeasurementFrameGiven
return false;
}

//std::cout<<firstLink_H_sensor.toString()<<std::endl;
//std::cout<<firstLinkName<<" "<<sens->getSecondLinkName()<<std::endl;
//std::cout<<root_H_firstLink.toString();

iDynTree::Transform root_H_sensor = root_H_firstLink*firstLink_H_sensor;

// Check that the two transfom are equal equal
if (!checkTransformAreEqual(root_H_frame, root_H_sensor, 1e-6))
if (!checkTransformAreEqual(root_H_frame, root_H_sensor, 1e-5))
{
std::cerr << "ergocub-model-test : transform between root_H_frame and root_H_sensor for " << sensorName << " is not the expected one, test failed." << std::endl;
std::cerr << "ergocub-model-test : root_H_frame :" << root_H_frame.toString() << std::endl;
Expand Down Expand Up @@ -680,7 +702,7 @@ int main(int argc, char ** argv)
comp.setRobotState(qj,dqj,grav);

// Check axis
if( !checkAxisDirections(comp) )
if( !checkAxisDirections(comp, isergoCub1_1Model(modelPath)) )
{
return EXIT_FAILURE;
}
Expand Down
27 changes: 5 additions & 22 deletions urdf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
set(GAZEBO_SUPPORTED_MODELS "")
list(APPEND GAZEBO_SUPPORTED_MODELS "ergoCubGazeboV1")
list(APPEND GAZEBO_SUPPORTED_MODELS "ergoCubGazeboV1_minContacts")
list(APPEND GAZEBO_SUPPORTED_MODELS "ergoCubGazeboV1_1")
list(APPEND GAZEBO_SUPPORTED_MODELS "ergoCubGazeboV1_1_minContacts")


set(INSTALLED_URDF_MODELS "")
Expand All @@ -24,23 +26,8 @@ macro(SUBDIRLIST result curdir)
set(${result} ${dirlist})
endmacro()

if( ERGOCUB_MODEL_GENERATE_SIMMECHANICS )
add_subdirectory(simmechanics)
add_custom_target(generate-models ALL)

if(TARGET generate-models-simmechanics AND ERGOCUB_MODEL_COPY_TO_SRC )
add_dependencies(generate-models generate-models-simmechanics)
add_custom_target(copy-models-to-src ALL)
add_dependencies(copy-models-to-src generate-models)
add_custom_command(TARGET copy-models-to-src
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_BINARY_DIR}/${BUILD_PREFIX}" "${CMAKE_CURRENT_SOURCE_DIR}/${BUILD_PREFIX}"
COMMENT "Copying generated files to ${CMAKE_CURRENT_SOURCE_DIR}/${BUILD_PREFIX}")
endif()
else()
# Copy the ergoCub folder in the build tree
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${BUILD_PREFIX} DESTINATION ${CMAKE_BINARY_DIR})
endif()
# Copy the ergoCub folder in the build tree
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${BUILD_PREFIX} DESTINATION ${CMAKE_BINARY_DIR})

set(ERGOCUB_MODELS_SDF_VERSION "1.7")

Expand All @@ -58,11 +45,7 @@ foreach(ROBOT_DIRNAME ${ROBOTS_NAMES})

list(APPEND INSTALLED_URDF_MODELS \"${ROBOT_NAME}\")
# When copying in sources remove the _fixed models
if(ERGOCUB_MODEL_COPY_TO_SRC)
file(REMOVE ${ROBOT_MODEL_CONFIG_FILE})
file(REMOVE_RECURSE ${ROBOT_FIXED_MODEL_FOLDER})
file(REMOVE_RECURSE ${ROBOT_FEET_FIXED_MODEL_FOLDER})
elseif(ROBOT_NAME IN_LIST GAZEBO_SUPPORTED_MODELS)
if(ROBOT_NAME IN_LIST GAZEBO_SUPPORTED_MODELS)

set(ROBOT_NAME_CONFIG "${ROBOT_NAME}")
set(ROBOT_MODEL_CONFIG "model.urdf")
Expand Down
Loading

0 comments on commit d82ce6a

Please sign in to comment.