Skip to content

Commit

Permalink
merge master to update_python_prefabs branch
Browse files Browse the repository at this point in the history
  • Loading branch information
adagolodjo committed Oct 4, 2024
2 parents 49bf1c5 + ca025cd commit b0cf1a2
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 30 deletions.
28 changes: 20 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,28 @@ jobs:
ccache -s
fi
- name: Sanitize artifact name
id: sanitize
# This step removes special characters from the artifact name to ensure compatibility with upload-artifact
# Characters removed: " : < > | * ? \r \n \ /
# Spaces are replaced with underscores
# This sanitization prevents errors in artifact creation and retrieval
shell: pwsh
run: |
$originalName = "Cosserat_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}"
$artifact_name = $originalName -replace '[":;<>|*?\r\n\\/]', '' -replace ' ', '_'
echo "artifact_name=$artifact_name" >> $env:GITHUB_OUTPUT
- name: Create artifact
uses: actions/upload-artifact@v2.2.4
uses: actions/upload-artifact@v4.4.0
with:
name: CosseratPlugin_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}
name: ${{ steps.sanitize.outputs.artifact_name }}
path: ${{ env.WORKSPACE_INSTALL_PATH }}

- name: Install artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4.1.7
with:
name: CosseratPlugin_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}
name: ${{ steps.sanitize.outputs.artifact_name }}
path: ${{ env.WORKSPACE_ARTIFACT_PATH }}

# - name: Set env vars for tests
Expand Down Expand Up @@ -119,7 +131,7 @@ jobs:
continue-on-error: true
steps:
- name: Get artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4.1.7
with:
path: artifacts

Expand All @@ -138,6 +150,6 @@ jobs:
fail_on_unmatched_files: false
target_commitish: ${{ github.sha }}
files: |
artifacts/CosseratPlugin_*_Linux.zip
artifacts/CosseratPlugin_*_Windows.zip
artifacts/CosseratPlugin_*_macOS.zip
artifacts/Cosserat_*_Linux.zip
artifacts/Cosserat_*_Windows.zip
artifacts/Cosserat_*_macOS.zip
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ In contrast, many other models in continuum media mechanics tend to treat materi
When modeling linear structures, this framework enables the creation of a structure closely resembling articulated solids, consisting of a series of rigid bodies whose relative positions are defined by their strain states.
Consequently, this model serves as a versatile tool for modeling and controlling a variety of systems, including concentric tube robots, continuum robots driven by cables, or pneumatic soft robots with constant cross-sections.

Go into theorotical part of the plugin [Theory](docs/text/Theory.md)
Go into theorotical part of the plugin [Theory](examples/python3/tutorial/Writerside/topics/Theory.mdexamples/python3/tutorial/Writerside/topics/Theory.md)

Follow the tutorial : [cosserat_tutorial](docs/text/cosserat_tutorial.md)
Follow the tutorial : [cosserat_tutorial](tutorial/text/cosserat_tutorial.md)
## Some use cases


Expand All @@ -40,27 +40,27 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor i

| View 1 | View 2 | View 3 |
|----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|
| ![333](docs/images/multiSectionWithColorMap1.png) | ![333](docs/images/multiSectionWithColorMap2.png) | ![333](docs/images/multiSectionWithColorMap3.png) |
| ![333](tutorial/images/multiSectionWithColorMap1.png) | ![333](tutorial/images/multiSectionWithColorMap2.png) | ![333](tutorial/images/multiSectionWithColorMap3.png) |


## Utilizing the Discrete Cosserat Model for Cable Modeling in Deformable Robot Control:


| Direct simulation of a soft gripper | The study of the model convergence |
|-------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|
| ![400](docs/images/cosseratgripper_2.png) | ![400](../../../../Templater/images/tenCossseratSections.png.md) |
| ![400](tutorial/images/cosseratgripper_2.png) | ![400](tutorial/images/tenCossseratSections.png) |


---

<strong> Actuation </strong>

| <img src="/docs/images/actuationConstraint_2.png" width="300" title="DCM Beam actuation using a given cable"> | <img src="docs/images/circleActuationConstraint.png" width="300" title="DCM Beam actuation using a given cable"> | <img src="/docs/images/actuationConstraint_1.png" width="300" title="DCM Beam actuation using a cable"> |
| <img src="/tutorial/images/actuationConstraint_2.png" width="300" title="DCM Beam actuation using a given cable"> | <img src="tutorial/images/circleActuationConstraint.png" width="300" title="DCM Beam actuation using a given cable"> | <img src="/tutorial/images/actuationConstraint_1.png" width="300" title="DCM Beam actuation using a cable"> |
|---------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------:|--------------------------------------------------------------------------------------------------------:|
| DCM Beam actuation using a cable ```d =``` | DCM Beam actuation using a cable ```d =``` | Beam actuation using a cable ```d =``` |


| <img src="/docs/images/example1.gif" width="300" title="PCS_Example1.py "> | <img src="./docs/images/example2.gif" widt="300" title="PCS_Example2.py"> | <img src="./docs/images/example2.gif" width="300" title="PCS_Example3.PCS"> |
| <img src="/tutorial/images/example1.gif" width="300" title="PCS_Example1.py "> | <img src="./tutorial/images/example2.gif" widt="300" title="PCS_Example2.py"> | <img src="./tutorial/images/example2.gif" width="300" title="PCS_Example3.PCS"> |
|----------------------------------------------------------------------------|:-------------------------------------------------------------------------:|----------------------------------------------------------------------------:|
| DCM Beam actuation using a cable ```d =``` | DCM Beam actuation using a cable ```d =``` | Beam actuation using a cable ```d =``` |

Expand Down Expand Up @@ -124,21 +124,21 @@ with a constant cross-section.

| View 1 | View 2 | View 3 |
|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
| <img src="/doc/images/multiSectionWithColorMap1.png" width="300" title="DCM as an implant"> | <img src="/doc/images/multiSectionWithColorMap2.png" width="300" title="DCM as an implant"> | <img src="/doc/images/multiSectionWithColorMap3.png" width="300" title="DCM as an implant"> |
| <img src="/tutorial/images/multiSectionWithColorMap1.png" width="300" title="DCM as an implant"> | <img src="/tutorial/images/multiSectionWithColorMap2.png" width="300" title="DCM as an implant"> | <img src="/tutorial/images/multiSectionWithColorMap3.png" width="300" title="DCM as an implant"> |

### DCM for cable modeling to control deformable robots:
| Direct simulation of a soft gripper | The study the model convergence |
|------------------------------------------------------------------------------------------| --- |
| <img src="/doc/images/cosseratgripper_2.png" width="400" title="DCM for cable modeling"> | <img src="/doc/images/tenCossseratSections.png" width="400" title="DCM for cable modeling ">|
| <img src="/tutorial/images/cosseratgripper_2.png" width="400" title="DCM for cable modeling"> | <img src="/tutorial/images/tenCossseratSections.png" width="400" title="DCM for cable modeling ">|

### Some use cases

| <img src="/doc/images/actuationConstraint_2.png" width="300" title="DCM Beam actuation using a given cable"> | <img src="doc/images/circleActuationConstraint.png" width="300" title="DCM Beam actuation using a given cable"> | <img src="/doc/images/actuationConstraint_1.png" width="300" title="DCM Beam actuation using a cable"> |
| <img src="/tutorial/images/actuationConstraint_2.png" width="300" title="DCM Beam actuation using a given cable"> | <img src="tutorial/images/circleActuationConstraint.png" width="300" title="DCM Beam actuation using a given cable"> | <img src="/tutorial/images/actuationConstraint_1.png" width="300" title="DCM Beam actuation using a cable"> |
| ------------- |:-------------:| -----:|
| DCM Beam actuation using a cable ```d =``` | DCM Beam actuation using a cable ```d =```| Beam actuation using a cable ```d =```|


| <img src="/doc/images/example1.gif" width="300" title="PCS_Example1.py "> | <img src="./doc/images/example2.gif" widt="300" title="PCS_Example2.py"> | <img src="./doc/images/example2.gif" width="300" title="PCS_Example3.PCS"> |
| <img src="/tutorial/images/example1.gif" width="300" title="PCS_Example1.py "> | <img src="./tutorial/images/example2.gif" widt="300" title="PCS_Example2.py"> | <img src="./tutorial/images/example2.gif" width="300" title="PCS_Example3.PCS"> |
| ------------- |:-------------:| -------------:|
| DCM Beam actuation using a cable ```d =``` | DCM Beam actuation using a cable ```d =```| Beam actuation using a cable ```d =```|

Expand Down
14 changes: 6 additions & 8 deletions examples/python3/PCS_Example1.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,17 @@ def __init__(self, *args, **kwargs):

def onAnimateEndEvent(self, event):
if self.applyForce:
with self.forceNode.force.writeable() as force:
vec = [0., 0., 0., 0., (self.forceCoeff * 1.) /
sqrt(2), (self.forceCoeff * 1.) / sqrt(2)]
for i, v in enumerate(vec):
force[i] = v
with self.forceNode.forces.writeable() as force:
force[0] = [0., 0., 0., 0., self.forceCoeff/sqrt(2.), self.forceCoeff/sqrt(2.)]


def onKeypressedEvent(self, event):
key = event['key']
if key == "+":
self.forceCoeff += 1
self.forceCoeff += 0.1
print(f' The new force coeff is : {self.forceCoeff}')
elif key == "-":
self.forceCoeff -= 1
self.forceCoeff -= 0.1
print(f' The new force coeff is : {self.forceCoeff}')


Expand Down Expand Up @@ -93,7 +91,7 @@ def createScene(rootNode):

beamFrame = PCS_Cosserat.cosseratFrame
constForce = beamFrame.addObject('ConstantForceField', name='constForce', showArrowSize=1.e-8,
indices=nonLinearConfig['nbFramesF'], force=F1)
indices=nonLinearConfig['nbFramesF'], forces=F1)

solverNode.addObject(ForceController(
parent=solverNode, cosseratFrames=beamFrame.FramesMO, forceNode=constForce))
Expand Down
22 changes: 18 additions & 4 deletions examples/python3/cosserat/cosseratObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import Sofa
from cosserat.usefulFunctions import buildEdges, pluginList, BuildCosseratGeometry
from useful.utils import addEdgeCollision, addPointsCollision
import warnings


cosserat_config = {
"init_pos": [0.0, 0.0, 0.0],
Expand Down Expand Up @@ -133,6 +135,17 @@ def __init__(self, *args, **kwargs):
"radius",
)

print ('===============>DEPRECATED<============================\n')

warnings.warn(
"\n====> DEPRECATED: This prefab CosseratObject class will be removed in a future version. "
"Use CosseratBase instead. For examples and tutorials, please refer to "
"the 'tutorial' folder located at plugin.Cosserat/tutoria/tuto_scenes .\n"
)
print("========================> DEPRECATED<============================\n")



if self.parent.hasObject("EulerImplicitSolver") is False:
print("The code does not have parent EulerImplicite")
self.solverNode = self.addSolverNode()
Expand Down Expand Up @@ -215,10 +228,11 @@ def addRigidBaseNode(self):
rigidBaseNode = self.addChild("rigidBase")

# trans = [t for t in self.translation.value]
trans = list(self.translation.value)
rot = list(self.rotation.value)
trans = self.translation.value
rot = self.rotation.value

# @todo converter
positions = [list(pos) for pos in self.position.value]
positions = [pos for pos in self.position.value]

rigidBaseNode.addObject(
"MechanicalObject",
Expand Down Expand Up @@ -382,7 +396,7 @@ def createScene(rootNode):
name="constForce",
showArrowSize=1.0e-2,
indices=12,
force=[0.0, -100.0, 0.0, 0.0, 0.0, 0.0],
forces=[0.0, -100.0, 0.0, 0.0, 0.0, 0.0],
)

return rootNode

0 comments on commit b0cf1a2

Please sign in to comment.