Skip to content

Commit

Permalink
merge the Master branch into the Main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
adagolodjo committed Oct 21, 2023
2 parents d39af29 + 635c963 commit 2590b3a
Show file tree
Hide file tree
Showing 99 changed files with 313 additions and 246 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
# If you wish to fail your job when the Quality Gate is red, uncomment the
# following lines. This would typically be used to fail a deployment.
# We do not recommend to use this in a pull request. Prefer using pull request
# decoration instead.
# - uses: sonarsource/sonarqube-quality-gate-action@master
# timeout-minutes: 5
# env:
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
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-master-nightly/SofaPython3_master-nightly_python-${{ matrix.python_version }}_for-SOFA-${{ matrix.sofa_branch }}_${{ runner.os }}.zip"
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"
Expand Down Expand Up @@ -168,7 +168,9 @@ jobs:
with:
name: ${{ github.ref_name }}
tag_name: release-${{ github.ref_name }}
fail_on_unmatched_files: true
fail_on_unmatched_files: false
target_commitish: ${{ github.ref_name }}
files: |
artifacts/CosseratPlugin_*_Linux.zip
artifacts/CosseratPlugin_*_Windows.zip
artifacts/CosseratPlugin_*_macOS.zip
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.12)
project(CosseratPlugin VERSION 21.12.0)
project(Cosserat VERSION 21.12.0)

include(cmake/environment.cmake)

Expand Down Expand Up @@ -47,7 +47,7 @@ set(HEADER_FILES
${SRC_ROOT_DIR}/constraint/CosseratNeedleSlidingConstraint.inl
)
set(SOURCE_FILES
${SRC_ROOT_DIR}/initCosseratPlugin.cpp
${SRC_ROOT_DIR}/initCosserat.cpp
${SRC_ROOT_DIR}/mapping/BaseCosserat.cpp
${SRC_ROOT_DIR}/mapping/DiscreteCosseratMapping.cpp
${SRC_ROOT_DIR}/mapping/DiscreteDynamicCosseratMapping.cpp
Expand Down Expand Up @@ -122,7 +122,7 @@ if(SofaPython3Tools OR SofaPython3_FOUND)
add_subdirectory(${SRC_ROOT_DIR}/Binding)
endif()

#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/CosseratPlugin/Binding)


## Install rules for the library and headers; CMake package configurations files
sofa_create_package_with_targets(
Expand All @@ -131,14 +131,19 @@ sofa_create_package_with_targets(
TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
INCLUDE_SOURCE_DIR "src"
INCLUDE_INSTALL_DIR ${PROJECT_NAME}
EXAMPLE_INSTALL_DIR "examples"
RELOCATABLE "plugins"
)


# Tests
# If SOFA_BUILD_TESTS exists and is OFF, then these tests will be auto-disabled
cmake_dependent_option(COSSERATPLUGIN_BUILD_TESTS "Compile the tests" ON "SOFA_BUILD_TESTS OR NOT DEFINED SOFA_BUILD_TESTS" OFF)
if(COSSERATPLUGIN_BUILD_TESTS)
cmake_dependent_option(COSSERAT_BUILD_TESTS "Compile the tests" ON "SOFA_BUILD_TESTS OR NOT DEFINED SOFA_BUILD_TESTS" OFF)
if(COSSERAT_BUILD_TESTS)
add_subdirectory(Tests)
endif()

# Config files and install rules for pythons scripts
sofa_install_pythonscripts(PLUGIN_NAME ${PROJECT_NAME} PYTHONSCRIPTS_SOURCE_DIR "examples/python3/")

include(cmake/packaging.cmake)
File renamed without changes.
4 changes: 2 additions & 2 deletions Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(This Cosserat_test)

project(${This} C CXX)

#find_package(CosseratPlugin REQUIRED)
#find_package(Cosserat REQUIRED)
find_package(Sofa.Testing REQUIRED)

enable_testing()
Expand All @@ -25,7 +25,7 @@ add_executable(${This} ${SOURCE_FILES} ${HEADER_FILES})

target_link_libraries(${PROJECT_NAME}
Sofa.Testing
CosseratPlugin
Cosserat
)

target_include_directories(${This}
Expand Down
2 changes: 1 addition & 1 deletion Tests/constraint/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ target_link_libraries(${This} PUBLIC
SofaTest
gtest
gtest_main
CosseratPlugin
Cosserat
Example
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct CosseratUnilateralInteractionConstraintTest : public NumericTest<>
x = new int(42);

sofa::simpleapi::importPlugin("Sofa.Component");
sofa::simpleapi::importPlugin("CosseratPlugin");
sofa::simpleapi::importPlugin("Cosserat");

//create the context for
if(simulation==nullptr)
Expand Down
21 changes: 6 additions & 15 deletions Tests/forcefield/BeamHookeLawForceFieldTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Created by younes on 07/06/2021.
//

#include <CosseratPlugin/config.h>
#include <Cosserat/config.h>

#include <gtest/gtest.h>
#include <sofa/testing/BaseTest.h>
Expand All @@ -18,7 +18,7 @@
#include <sofa/core/behavior/ForceField.inl>
#include <sofa/helper/system/PluginManager.h>

#include <CosseratPlugin/forcefield/BeamHookeLawForceField.inl>
#include <Cosserat/forcefield/BeamHookeLawForceField.inl>
#include <sofa/testing/NumericTest.h>

using sofa::testing::BaseTest ;
Expand All @@ -45,11 +45,7 @@ struct BeamHookeLawForceFieldTest : public testing::NumericTest<> {
// initialization or some code to run before each test
fprintf(stderr, "Starting up ! \n");
sofa::simpleapi::importPlugin("Sofa.Component");
sofa::simpleapi::importPlugin("CosseratPlugin");

//create the context for
if(simulation==nullptr)
sofa::simulation::setSimulation(simulation = new sofa::simulation::graph::DAGSimulation());
sofa::simpleapi::importPlugin("Cosserat");
}

// Tears down the test fixture.
Expand All @@ -58,7 +54,7 @@ struct BeamHookeLawForceFieldTest : public testing::NumericTest<> {
// can be used instead of a destructor,
// but exceptions can be handled in this function only
if(root) {
simulation->unload(root);
sofa::simulation::node::unload(root);
}
fprintf(stderr, "Starting down ! \n");
}
Expand Down Expand Up @@ -105,8 +101,6 @@ struct BeamHookeLawForceFieldTest : public testing::NumericTest<> {
protected:
///< Root of the scene graph, created by the constructor an re-used in the tests
simulation::Node::SPtr root;
///< created by the constructor an re-used in the tests
simulation::Simulation* simulation {nullptr};

void testFonctionnel();
};
Expand All @@ -131,10 +125,9 @@ void BeamHookeLawForceFieldTest<defaulttype::Vec3Types>::testFonctionnel() {
EXPECT_NE(root.get(), nullptr) ;
root->init(sofa::core::execparams::defaultInstance()) ;

Simulation* simulation = sofa::simulation::getSimulation() ;
auto total_load = dynamic_cast<sofa::core::objectmodel::Data<double> *>(traction->findData("lengthY"));
for (unsigned int step = 1; step <= 5; ++step) {
simulation->animate(root.get(), 1);
sofa::simulation::node::animate(root.get(), 1);
EXPECT_DOUBLE_EQ(total_load->getValue(), 4*step) << "Total load at time step " << step << " is incorrect.";
}
}
Expand Down Expand Up @@ -176,10 +169,8 @@ void BeamHookeLawForceFieldTest<defaulttype::Vec3Types>::basicAttributesTest(){
<< "Missing attribute with name '"
<< attrname << "'." ;

Simulation* simulation = sofa::simulation::getSimulation() ;
ASSERT_NE(nullptr, simulation) ;
for(int i=0; i<10; i++){
simulation->animate(root.get(),(double)0.01);
sofa::simulation::node::animate(root.get(),(double)0.01);
}
}

Expand Down
24 changes: 24 additions & 0 deletions examples/python3/NeedleInsertion-predefinedPath.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<html>
<head>
<link href="../../../../share/sofa/examples/Objects/sofa_white.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="contenu">
<center><h3>Cosserat plugin: needle insertion </h3></center>
<br>
<div id="orangeText">Instruments control</div>
<br>
<div align="controler">
You can use the keyboard to move the needle (arrow keys):
<ul>
<li>ctrl + up: move up the needle</li>
<li>ctrl + down: move down the needle</li>
<li>ctrl + right: move towards the deformable gel (forward insertion)</li>
<li>ctrl + left: move away from the deformable gel (backward insertion)</li>
</ul>
<br>

</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import sys
sys.path.append('../')
from cosserat.createFemRegularGrid import createFemCube
from cosserat.usefulFunctions import pluginList

__authors__ = "younesssss"
__contact__ = "[email protected], [email protected]"
__version__ = "1.0.0"
Expand All @@ -23,10 +25,6 @@

path = os.path.dirname(os.path.abspath(__file__))+'/../mesh/'

pluginNameList = 'SofaConstraint SofaDeformable SofaImplicitOdeSolver SofaMeshCollision SofaPreconditioner' \
' SofaGeneralTopology SofaOpenglVisual SofaGeneralRigid SoftRobots SofaSparseSolver' \
' CosseratPlugin SofaBoundaryCondition'


class Animation(Sofa.Core.Controller):

Expand Down Expand Up @@ -93,8 +91,7 @@ def onKeypressedEvent(self, event):


def createScene(rootNode):
rootNode.addObject(
'RequiredPlugin', pluginName=pluginNameList, printLog='0')
rootNode.addObject('RequiredPlugin', name='plugins', pluginName=[pluginList])

rootNode.addObject('VisualStyle', displayFlags='showBehaviorModels hideCollisionModels hideBoundingCollisionModels '
'showForceFields hideInteractionForceFields showWireframe')
Expand Down
24 changes: 24 additions & 0 deletions examples/python3/NeedleInsertion.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<html>
<head>
<link href="../../../../share/sofa/examples/Objects/sofa_white.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="contenu">
<center><h3>Cosserat plugin: needle insertion </h3></center>
<br>
<div id="orangeText">Instruments control</div>
<br>
<div align="controler">
You can use the keyboard to move the needle (arrow keys):
<ul>
<li>ctrl + up: move up the needle</li>
<li>ctrl + down: move down the needle</li>
<li>ctrl + right: move towards the deformable gel (forward insertion)</li>
<li>ctrl + left: move away from the deformable gel (backward insertion)</li>
</ul>
<br>

</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

from cosserat.needle.needleController import Animation
from params import NeedleParameters, GeometryParams, PhysicsParams, FemParams, ContactParams
from cosserat.needle.params import NeedleParameters, GeometryParams, PhysicsParams, FemParams, ContactParams
from cosserat.usefulFunctions import pluginList
from cosserat.createFemRegularGrid import createFemCubeWithParams
from cosserat.cosseratObject import Cosserat
Expand All @@ -23,13 +23,13 @@


def createScene(rootNode):
rootNode.addObject(
'RequiredPlugin', pluginName=pluginList, printLog='0')

rootNode.addObject('RequiredPlugin', name='plugins', pluginName=[pluginList])

rootNode.addObject('VisualStyle', displayFlags='showVisualModels showBehaviorModels hideCollisionModels '
'hideBoundingCollisionModels hideForceFields '
'hideInteractionForceFields hideWireframe showMechanicalMappings')
rootNode.addObject('DefaultPipeline')
rootNode.addObject('CollisionPipeline')
rootNode.addObject("DefaultVisualManagerLoop")
rootNode.addObject('RuleBasedContactManager',
responseParams='mu=0.1', response='FrictionContactConstraint')
Expand All @@ -54,8 +54,7 @@ def createScene(rootNode):
solverNode = rootNode.addChild('solverNode')
solverNode.addObject('EulerImplicitSolver',
rayleighStiffness=PhysicsParams.rayleighStiffness)
solverNode.addObject('SparseLDLSolver', name='solver',
template="CompressedRowSparseMatrixd")
solverNode.addObject('SparseLDLSolver', name='solver', template="CompressedRowSparseMatrixd")
solverNode.addObject('GenericConstraintCorrection')

needle = solverNode.addChild(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
firstOrder = 1

EI = 1.e2
coeff = 0
coeff = 1

F1 = [0., 0., 0., 0., (coeff*1.)/sqrt(2), (coeff*1.)/sqrt(2)] # N

Expand All @@ -50,7 +50,6 @@ def __init__(self, *args, **kwargs):
self.size = nonLinearConfig['nbFramesF']
self.applyForce = True
self.forceCoeff = coeff
# self.cosseratGeometry = kwargs['cosseratGeometry']

def onAnimateEndEvent(self, event):
if self.applyForce:
Expand All @@ -59,7 +58,6 @@ def onAnimateEndEvent(self, event):
sqrt(2), (self.forceCoeff * 1.) / sqrt(2)]
for i, v in enumerate(vec):
force[i] = v
# print(f' The new force: {force}')

def onKeypressedEvent(self, event):
key = event['key']
Expand All @@ -72,25 +70,19 @@ def onKeypressedEvent(self, event):


def createScene(rootNode):
rootNode.addObject('RequiredPlugin', name='plugins', pluginName=[pluginList,
['SofaEngine', 'SofaLoader', 'SofaSimpleFem',
'SofaExporter']])
rootNode.addObject('RequiredPlugin', name='plugins', pluginName=[pluginList])
rootNode.addObject('VisualStyle', displayFlags='showVisualModels showBehaviorModels hideCollisionModels '
'hideBoundingCollisionModels hideForceFields '
'hideInteractionForceFields hideWireframe showMechanicalMappings')
rootNode.findData('dt').value = deltaT
# rootNode.findData('gravity').value = [0., -9.81, 0.]
rootNode.findData('gravity').value = [0., 0., 0.]
# rootNode.addObject('BackgroundSetting', color='0 0.168627 0.211765')
# rootNode.addObject('FreeMotionAnimationLoop')
# rootNode.addObject('GenericConstraintSolver', tolerance=1e-5, maxIterations=5e2)
rootNode.dt.value = deltaT
rootNode.gravity.value = [0., 0., 0.]

rootNode.addObject('Camera', position="-35 0 280", lookAt="0 0 0")
rootNode.addObject('DefaultAnimationLoop')

solverNode = rootNode.addChild('solverNode')
solverNode.addObject('EulerImplicitSolver', rayleighStiffness=rayleighStiffness, rayleighMass='0.',
firstOrder=firstOrder)
# solverNode.addObject('SparseLDLSolver', name='solver',
# template="CompressedRowSparseMatrixd")
solverNode.addObject('CGLinearSolver', tolerance=1.e-12, iterations=1000, threshold=1.e-18)

# use this if the collision model if the beam will interact with another object
Expand Down
Loading

0 comments on commit 2590b3a

Please sign in to comment.