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

[ci] update ci.yml #12

Merged
merged 5 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 9 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ on:

jobs:
build-and-test:
name: Run on ${{ matrix.os }} with SOFA ${{ matrix.sofa_branch }} and python ${{ matrix.python_version }}
name: Run on ${{ matrix.os }} with SOFA ${{ matrix.sofa_branch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-11, windows-2019]
sofa_branch: [master]
python_version: ['3.8']

steps:
- name: (Mac) Workaround for homebrew
Expand All @@ -45,30 +44,15 @@ jobs:
sofa_root: ${{ github.workspace }}/sofa
sofa_version: ${{ matrix.sofa_branch }}
sofa_scope: 'standard'
sofa_with_sofapython3: 'false'
python_version: '${{ matrix.python_version }}'

- name: Install SofaPython3
shell: bash
run: |
SofaPython3_ROOT="$GITHUB_WORKSPACE/SofaPython3"
mkdir -p "${{ runner.temp }}/sp3_tmp/zip" "${{ runner.temp }}/sp3_tmp/binaries" "$SofaPython3_ROOT"
url="https://github.com/sofa-framework/SofaPython3/releases/download"
url="${url}/release-${{ matrix.sofa_branch }}/SofaPython3_${{ matrix.sofa_branch }}_python-${{ matrix.python_version }}_for-SOFA-${{ matrix.sofa_branch }}_${{ runner.os }}.zip"
echo "Getting SofaPython3 from $url"
curl --output "${{ runner.temp }}/sp3_tmp/SofaPython3.zip" -L $url
unzip -qq "${{ runner.temp }}/sp3_tmp/SofaPython3.zip" -d "${{ runner.temp }}/sp3_tmp/binaries"
mv "${{ runner.temp }}"/sp3_tmp/binaries/SofaPython3_*/* "$SofaPython3_ROOT"
echo "SofaPython3_ROOT=$SofaPython3_ROOT" | tee -a $GITHUB_ENV
echo "SofaPython3_DIR=$SofaPython3_ROOT/lib/cmake/SofaPython3" | tee -a $GITHUB_ENV
sofa_with_sofapython3: 'true'

- name: Install SoftRobots
shell: bash
run: |
SoftRobots_ROOT="$GITHUB_WORKSPACE/SoftRobots"
mkdir -p "${{ runner.temp }}/sp3_tmp/zip" "${{ runner.temp }}/sp3_tmp/binaries" "$SoftRobots_ROOT"
url="https://github.com/SofaDefrost/SoftRobots/releases/download"
url="${url}/release-${{ matrix.sofa_branch }}/SoftRobots_${{ matrix.sofa_branch }}_python-${{ matrix.python_version }}_for-SOFA-${{ matrix.sofa_branch }}_${{ runner.os }}.zip"
url="${url}/release-${{ matrix.sofa_branch }}/SoftRobots_${{ matrix.sofa_branch }}_for-SOFA-${{ matrix.sofa_branch }}_${{ runner.os }}.zip"
echo "Getting SoftRobots from $url"
curl --output "${{ runner.temp }}/sp3_tmp/SoftRobots.zip" -L $url
unzip -qq "${{ runner.temp }}/sp3_tmp/SoftRobots.zip" -d "${{ runner.temp }}/sp3_tmp/binaries"
Expand All @@ -88,10 +72,7 @@ jobs:
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \
-DCMAKE_PREFIX_PATH="$SOFA_ROOT/lib/cmake" \
-DSOFTROBOTS_BUILD_TESTS=True \
-DSOFTROBOTS_IGNORE_ERRORS=True \
-DPYTHON_ROOT=$PYTHON_ROOT -DPython_ROOT=$PYTHON_ROOT \
-DPYTHON_EXECUTABLE=$PYTHON_EXE -DPython_EXECUTABLE=$PYTHON_EXE"
"
if [ -e "$(command -v ccache)" ]; then
cmake_options="$cmake_options -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
fi
Expand Down Expand Up @@ -152,6 +133,10 @@ jobs:
ls -la "$WORKSPACE_SRC_PATH"
echo '------ ls -la "$WORKSPACE_BUILD_PATH" ------'
ls -la "$WORKSPACE_BUILD_PATH"
echo '------ ls -la "$WORKSPACE_BUILD_PATH/bin" ------'
ls -la "$WORKSPACE_BUILD_PATH/bin"
echo '------ ls -la "$WORKSPACE_BUILD_PATH/tests" ------'
ls -la "$WORKSPACE_BUILD_PATH/tests"
echo '------ ls -la "$WORKSPACE_INSTALL_PATH" ------'
ls -la "$WORKSPACE_INSTALL_PATH"
echo '------ ls -la "$WORKSPACE_ARTIFACT_PATH" ------'
Expand All @@ -166,7 +151,7 @@ jobs:
shell: bash
run: |
cd $WORKSPACE_BUILD_PATH
./bin/SoftRobots_test${{ steps.sofa.outputs.exe }}
./bin/SoftRobots.Inverse_test${{ steps.sofa.outputs.exe }}

deploy:
name: Deploy artifacts
Expand Down
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,11 @@ sofa_create_package_with_targets(
install(DIRECTORY docs DESTINATION .)
install(FILES "README.md" "LICENSE.AGPLV3.txt" "LICENSE.AGPLV3.Clause11.txt" "CHANGELOG" DESTINATION .)

option(SOFTROBOTSINVERSE_BUILD_TESTS "Build unit tests" ON)
# Tests
# If SOFA_BUILD_TESTS exists and is OFF, then these tests will be auto-disabled
cmake_dependent_option(SOFTROBOTSINVERSE_BUILD_TESTS "Compile the automatic tests" ON "SOFA_BUILD_TESTS OR NOT DEFINED SOFA_BUILD_TESTS" OFF)
if(SOFTROBOTSINVERSE_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()

Expand Down
3 changes: 2 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.5)
cmake_policy(SET CMP0048 NEW)

project(SoftRobots.Inverse_test VERSION 1.0)
find_package(Sofa.Testing REQUIRED)

set(SOURCE_FILES )
set(HEADER_FILES )
Expand All @@ -15,7 +16,7 @@ add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${RC_FILES})
target_include_directories(${PROJECT_NAME} PRIVATE "${SoftRobots_INCLUDE_DIRS}")

target_link_libraries(${PROJECT_NAME} Sofa.Testing SoftRobots.Inverse)
add_definitions("-DSOFTROBOTS_TEST_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\"")
add_definitions("-DSOFTROBOTSINVERSE_TEST_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\"")

add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})

2 changes: 1 addition & 1 deletion tests/component/solver/QPInverseProblemSolverTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct QPInverseProblemSolverTest : public BaseTest,
/// Load the scene
string sceneName = "Finger.scn";

string fileName = string(SOFTROBOTS_TEST_DIR) + "/component/solver/scenes/" + sceneName;
string fileName = string(SOFTROBOTSINVERSE_TEST_DIR) + "/component/solver/scenes/" + sceneName;

m_root = core::objectmodel::SPtr_dynamic_cast<simulation::Node>( sofa::simulation::node::load(fileName.c_str()));

Expand Down
91 changes: 44 additions & 47 deletions tests/component/solver/scenes/CubeOnFloor.pyscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,82 +2,79 @@ import Sofa

def createScene(rootNode):

rootNode.createObject('RequiredPlugin', pluginName='SoftRobots')
rootNode.createObject('RequiredPlugin', pluginName='SofaSparseSolver')
rootNode.createObject('VisualStyle', displayFlags='showWireframe showVisualModels showBehaviorModels showCollisionModels hideBoundingCollisionModels showForceFields showInteractionForceFields')
rootNode.addObject('RequiredPlugin', pluginName='SoftRobots')
rootNode.addObject('RequiredPlugin', pluginName='SoftRobots.Inverse')
rootNode.addObject('RequiredPlugin', pluginName='SofaSparseSolver')
rootNode.addObject('VisualStyle', displayFlags='showWireframe showVisualModels showBehaviorModels showCollisionModels hideBoundingCollisionModels showForceFields showInteractionForceFields')

rootNode.findData('gravity').value = "0 -9180 0"
rootNode.findData('gravity').value = [0, -9180, 0]
rootNode.findData('dt').value = 0.01

rootNode.createObject('FreeMotionAnimationLoop')
rootNode.createObject('QPInverseProblemSolver', printLog='0', epsilon="0", maxIterations="1000", tolerance="1e-5")
rootNode.createObject('DefaultPipeline', verbose="0")
rootNode.createObject('BruteForceBroadPhase', name="N2")
rootNode.createObject('BVHNarrowPhase')
rootNode.createObject('DefaultContactManager', response="FrictionContactConstraint", responseParams="mu=0.6")
rootNode.createObject('LocalMinDistance', name="Proximity", alarmDistance="3", contactDistance="1")
rootNode.addObject('FreeMotionAnimationLoop')
rootNode.addObject('QPInverseProblemSolver', epsilon=0, maxIterations=1000, tolerance=1e-5)
rootNode.addObject('DefaultPipeline')
rootNode.addObject('BruteForceBroadPhase')
rootNode.addObject('BVHNarrowPhase')
rootNode.addObject('DefaultContactManager', response="FrictionContactConstraint", responseParams="mu=0.6")
rootNode.addObject('LocalMinDistance', alarmDistance=3, contactDistance=1)

rootNode.createObject('BackgroundSetting', color='0 0.168627 0.211765')
rootNode.createObject('OglSceneFrame', style="Arrows", alignment="TopRight")
rootNode.addObject('OglSceneFrame', style="Arrows", alignment="TopRight")


##########################################
# Effector goal for interactive control #
##########################################
goal = rootNode.createChild('goal')
goal.createObject('MechanicalObject', name='goalMO', showObject="1", showObjectScale="5", drawMode="1", position = "10 0 0")
goal = rootNode.addChild('goal')
goal.addObject('MechanicalObject', name='goalMO', showObject=True, showObjectScale=5, drawMode=1, position=[10, 0, 0])


##########################################
##########################################
# FEM Model #
##########################################
model = rootNode.createChild('model')
model.createObject('EulerImplicitSolver', name='odesolver')
model.createObject('SparseLDLSolver', name='preconditioner')
model.createObject('RegularGridTopology', name='loader', n="6 6 6", min="-10 -10 -10", max="10 10 10")
model.createObject('MechanicalObject', name='tetras', template='Vec3', showIndices=False, showIndicesScale='4e-5')
model.createObject('UniformMass', totalMass='0.005')
model = rootNode.addChild('model')
model.addObject('EulerImplicitSolver')
model.addObject('SparseLDLSolver')
model.addObject('RegularGridTopology', name='loader', n=[6, 6, 6], min=[-10, -10, -10], max=[10, 10, 10])
model.addObject('MechanicalObject', name='tetras', template='Vec3', showIndices=False, showIndicesScale=4e-5)
model.addObject('UniformMass', totalMass=0.005)

model.createObject('ForcePointActuator', name="act", template='Vec3', showForce="1", visuScale="100", direction="1 0 0", indices="90 126 84 120", minForce="0", maxForce="0.5")
model.addObject('ForcePointActuator', name="act", template='Vec3', showForce=True, visuScale=100, direction=[1, 0, 0], indices=[90, 126, 84, 120], minForce=0, maxForce=0.5)

model.createObject('HexahedronFEMForceField', template='Vec3', name='FEM', method='large', poissonRatio='0.49', youngModulus='600')
model.createObject('LinearSolverConstraintCorrection', solverName='preconditioner')
model.addObject('HexahedronFEMForceField', template='Vec3', name='FEM', method='large', poissonRatio=0.49, youngModulus=600)
model.addObject('LinearSolverConstraintCorrection')


##########################################
# Effector #
##########################################
effector = model.createChild('effector')
effector.createObject('MechanicalObject', name="effectorPoint",
position=("10 0 0"))
effector.createObject('PositionEffector', template='Vec3',
indices="0",
effectorGoal="@../../goal/goalMO.position")
effector.createObject('BarycentricMapping', mapForces=False, mapMasses=False)
effector = model.addChild('effector')
effector.addObject('MechanicalObject', name="effectorPoint", position=[10, 0, 0])
effector.addObject('PositionEffector', template='Vec3', indices=[0], effectorGoal=goal.goalMO.position.linkpath)
effector.addObject('BarycentricMapping', mapForces=False, mapMasses=False)


##########################################
# Contact #
##########################################
modelContact = model.createChild('contact')
modelContact.createObject('MeshObjLoader', name='loader', filename='mesh/cube.obj', scale="10")
modelContact.createObject('MeshTopology', src='@loader', name='topo')
modelContact.createObject('MechanicalObject')
modelContact.createObject('TriangleCollisionModel', group=1)
modelContact.createObject('LineCollisionModel', group=1)
modelContact.createObject('PointCollisionModel', group=1)
modelContact.createObject('BarycentricMapping')
modelContact = model.addChild('contact')
modelContact.addObject('MeshObjLoader', name='loader', filename='mesh/cube.obj', scale=10)
modelContact.addObject('MeshTopology', src='@loader', name='topo')
modelContact.addObject('MechanicalObject')
modelContact.addObject('TriangleCollisionModel', group=1)
modelContact.addObject('LineCollisionModel', group=1)
modelContact.addObject('PointCollisionModel', group=1)
modelContact.addObject('BarycentricMapping')


##########################################
# Contact #
##########################################
floorContact = rootNode.createChild('floorContact')
floorContact.createObject('MeshObjLoader', name='loader', filename='mesh/square1.obj', scale="200", rotation="90 0 180", translation="100 -11 -100")
floorContact.createObject('MeshTopology', src='@loader', name='topo')
floorContact.createObject('MechanicalObject')
floorContact.createObject('TriangleCollisionModel', group=2)
floorContact.createObject('LineCollisionModel', group=2)
floorContact.createObject('PointCollisionModel', group=2)
floorContact = rootNode.addChild('floorContact')
floorContact.addObject('MeshObjLoader', name='loader', filename='mesh/square1.obj', scale=200, rotation=[90, 0, 180], translation=[100, -11, -100])
floorContact.addObject('MeshTopology', src='@loader', name='topo')
floorContact.addObject('MechanicalObject')
floorContact.addObject('TriangleCollisionModel', group=2)
floorContact.addObject('LineCollisionModel', group=2)
floorContact.addObject('PointCollisionModel', group=2)

return rootNode
4 changes: 2 additions & 2 deletions tests/component/solver/scenes/Finger.scn
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
<RequiredPlugin name="Sofa.Component.SolidMechanics.Spring"/> <!-- Needed to use components [RestShapeSpringsForceField] -->
<RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
<RequiredPlugin name="Sofa.Component.Topology.Container.Dynamic"/> <!-- Needed to use components [TetrahedronSetGeometryAlgorithms TetrahedronSetTopologyContainer] -->
<RequiredPlugin name="SoftRobots.Inverse"/> <!-- Needed to use components [PositionEffector] -->
<!--<RequiredPlugin name="SoftRobots.Inverse"/> Needed to use components [PositionEffector] -->

<FreeMotionAnimationLoop/>
<DefaultPipeline verbose='0'/>
<DefaultPipeline />
<BruteForceBroadPhase />
<BVHNarrowPhase />
<DefaultContactManager response='FrictionContactConstraint'/>
Expand Down
Loading