Cannot successfully run gravity simulation #4937
-
|
Hi all, I recently just went through the SOFA tutorial and trying SofaPython3 to try to align a titanium implant to orbital floor as an early stage of development for orbital surgery simulation. I adapted python script I converted from the XML tutorial, which dropped a sphere to a liver, to my case. I added a tetrahedron model of the orbital floor and use a gravity. However, the same script worked for the liver case did not work for anymore. The titanium plate (only visual and collision models but no tetrahedron model) can still drop by gravity, but the orbital floor could not. The tetrahedron model, visual model, and the collision model were both loaded. I used the SOFA binary for Windows. Here is the script I loaded the orbital floor model. meshLoaderCoarse = root.addObject('MeshGmshLoader', name='meshLoaderCoarse', filename='mesh/1048_orbit_floor_recon.msh', scale=10.0)
meshLoaderFine = root.addObject('MeshOBJLoader', name='meshLoaderFine', filename='mesh/1048_orbit_floor_recon.obj', scale=10.0)
# Creating the orbit object
orbitNode = root.addChild("Orbit")
orbitNode.addObject('EulerImplicitSolver', name='odesolver')
orbitNode.addObject('CGLinearSolver', name='Solver', iterations=25, tolerance=1e-05, threshold=1e-05)
#tetrahedron topology
orbitNode.addObject('TetrahedronSetTopologyContainer', name='topo', src=meshLoaderCoarse.getLinkPath())
orbitNode.addObject('TetrahedronSetGeometryAlgorithms', template='Vec3d', name='GeomAlgo')
orbitNode.addObject('MechanicalObject', template='Vec3d', name='MechanicalModel', showObject=True)
orbitNode.addObject('TetrahedronFEMForceField', name='FEM', youngModulus=1000, poissonRatio=0.4, method='large')
orbitNode.addObject('MeshMatrixMass', massDensity=10, topology='@topo')
#### Collision subnode
orbitCollis = orbitNode.addChild('collision_orbit')
orbitCollis.addObject('MeshTopology', src=meshLoaderFine.getLinkPath())
orbitCollis.addObject('MechanicalObject', name='CollisionMO')
orbitCollis.addObject('TriangleCollisionModel', name='CollisionModel', contactStiffness=30)
orbitCollis.addObject('BarycentricMapping', name='CollisionMapping', input='@../MechanicalModel', output='@CollisionMO')
# Fine visual model
orbitVisu = orbitNode.addChild('FineVisualModel')
orbitVisu.addObject('OglModel', name='VisualModel', src=meshLoaderFine.getLinkPath())
orbitVisu.addObject('BarycentricMapping', name='Mapping', input='@../MechanicalModel', output='@VisualModel')The terminal did not report an error. Could you please give me some hint? The full script is here. The python script I converted for the liver and sphere obj and msh from the binary is here . The sample data I used are in this folder: https://drive.google.com/drive/folders/1rkiRIhkvv-WCIQUBEulIsCsJ1jhDZ06s?usp=sharing Thank you very much! Chi |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hello ! I can see two major issues with your script :
Hope this works for you ! And by the way, congrat' for trying and keeping up with SOFA ! I know it is sometimes difficult for newcomers and people out of the simulation field. But you are on the right path ! |
Beta Was this translation helpful? Give feedback.
Hello !
I can see two major issues with your script :
FreeMotionAnimationLoopyou need to have aConstraintCorrectionin every simulated object. Such component is missing in yourorbitNodeadding one will enable it to move. You can either use aUncoupledConstraintCorrectionfirst to see if it works. But know that using this component will generate instabilities and not very good contact response/correction. The best one to use is theLinearSolverConstraintCorrectionbut it will take way m…