sofa-framework / sofa

Real-time multi-physics simulation with an emphasis on medical simulation.
https://www.sofa-framework.org
GNU Lesser General Public License v2.1
908 stars 310 forks source link

I imitated and compiled the code of the conduit in pycharm, and found that it could not be opened. There was no error, and the system crashed and shut down. #3483

Open beamadapter opened 1 year ago

beamadapter commented 1 year ago

import sys import Sofa

def createScene(rootNode): rootNode.addObject('RequiredPlugin', pluginName='BeamAdapter SofaDeformable SofaImplicitOdeSolver SofaGeneralLinearSolver SofaLoader SofaOpenglVisual SofaTopologyMapping SofaBoundaryCondition SofaConstraint ') rootNode.addObject('VisualStyle', displayFlags='showVisualModels showBehaviorModels showCollisionModels hideMappings hideForceFields')

rootNode.addObject('DefaultAnimationLoop')
rootNode.addObject('DefaultVisualManagerLoop')

topoLines_cath = rootNode.addChild('EdgeTopology')
topoLines_cath.addObject('WireRestShape',name='catheterRestShape',
                         straightLength=600.0, length=1000.0,
                         numEdges=200, youngModulus=12000,
                         spireDiameter=1000, numEdgesCollis=[50, 10],
                         printLog=True, template='Rigid3d', spireHeight=0.0,
                         densityOfBeams=[30, 10], youngModulusExtremity=12000)
topoLines_cath.addObject('EdgeSetTopologyContainer', name='meshLinesCath')
topoLines_cath.addObject('EdgeSetTopologyModifier', name='meshLinesModifier')
topoLines_cath.addObject('EdgeSetGeometryAlgorithms', name='GeomAlgo', template='Rigid3d')
topoLines_cath.addObject('MechanicalObject', template='Rigid3d', name='dofTopo')

CatheterMechanics = rootNode.addChild('CatheterModel')
CatheterMechanics.addObject('EulerImplicitSolver',rayleighStiffness=0.2,rayleighMass=0.1,printLog='false')
CatheterMechanics.addObject('BTDLinearSolver',subpartSolve='0',verification='0',verbose='0')
CatheterMechanics.addObject('RegularGridTopology',name='meshLines',nx=60,ny=1,nz=1,xmin=0.0,xmax=1.0,ymin=0, ymax=0,zmin=1,zmax=1)
CatheterMechanics.addObject('MechanicalObject',template='Rigid3d',name='DOFs',showIndices=0,ry=-90)
CatheterMechanics.addObject('WireBeamInterpolation',name='InterpolCatheter',WireRestShape='@../topoLines_cath/catheterRestShape',radius=1,printLog='0')
CatheterMechanics.addObject('AdaptiveBeamForceFieldAndMass',name='CatheterForceField', interpolation='@InterpolCatheter', massDensity=0.00000155)
CatheterMechanics.addObject('InterventionalRadiologyController',template='Rigid3d',name='m_ircontroller',printLog='0',xtip=[1, 0 ,0], step=3,rotationInstrument=[0, 0 ,0],controlledInstrument='0',startingPos=[0 ,0 ,0 ,0, -0.7071068, 0, 0.7071068],speed=2,instruments='InterpolCatheter')
CatheterMechanics.addObject('FixedConstraint',name='FixedConstraint',indices=0)
CatheterMechanics.addObject('RestShapeSpringsForceField',points='@m_ircontroller.indexFirstNode',stiffness=1e8,angularStiffness=1e8)

VisuCatheter = CatheterModel.addChild('VisuCatheter')
VisuCatheter.activated = True
VisuCatheter.addObject('MechanicalObject',name='Quads')
VisuCatheter.addObject('QuadSetTopologyContainer',name='ContainerCath')
VisuCatheter.addObject('QuadSetTopologyModifier',name='Modifier')
VisuCatheter.addObject('QuadSetGeometryAlgorithms',name='GeomAlgo', template='Vec3d')
VisuCatheter.addObject('Edge2QuadTopologicalMapping',nbPointsOnEachCircle='10',radius='2',input='@../../topoLines_cath/meshLinesCath',output='@ContainerCath',flipNormals='true')
VisuCatheter.addObject('AdaptiveBeamMapping', name='VisuMapCath',useCurvAbs='1',printLog='0',interpolation='@../InterpolCatheter',input='@../DOFs',output='@Quads', isMechanical='false' )

VisuOgl = VisuCatheter.addChild('VisuOgl')
VisuOgl.addObject('OglModel',name='Visual',color='0.7 0.7 0.7', quads='@../ContainerCath.quads',material='texture Ambient 1 0.2 0.2 0.2 0.0 Diffuse 1 1.0 1.0 1.0 1.0 Specular 1 1.0 1.0 1.0 1.0 Emissive 0 0.15 0.05 0.05 0.0 Shininess 1 20')
VisuOgl.addObject('IdentityMapping',input='@../Quads',output='@Visual')

return rootNode

######### SIG 11 - SIGSEGV: segfault ########## sofa::helper::BackTrace::dump sofa::helper::BackTrace::sig seh_filter_exe seh_filter_exe _C_specific_handler _chkstk RtlRaiseException KiUserExceptionDispatcher sofa::component::engine::wirerestshape::WireRestShape<sofa::defaulttype::StdRigidTypes<3,double> >::getClass sofa::component::fem::wirebeaminterpolation::WireBeamInterpolation<sofa::defaulttype::StdRigidTypes<3,double> >::bwdInit sofa::core::ObjectFactory::createObject sofa::core::ObjectFactory::createObject sofa::core::ObjectFactory::createObject sofa::core::ObjectFactory::createObject PyCFunction_Call PyObject_MakeTpCall Py_gitversion PyFunction_Vectorcall PyVectorcall_Call PyObject_Call I need your help

epernod commented 1 year ago

Hi, thank you for your report. Could you please specify your setup: OS, SOFA version and BeamAdapter plugin version and if it is compiled in or out of tree?

Does the crash happened at start?

beamadapter commented 1 year ago

I use the Windows system, sofa22.06 version. I don't know whether you mean compile in tree or compile out of tree. I compile on pychar, and the crash occurs at the beginning.

beamadapter commented 1 year ago

Hello, I copied the 3 instruments on the Beam Adapter plug-in_ collis. The scn xml format is converted to the python format, and then it can be opened normally through SOFA, but it is stuck when you click animate. What is the reason? import sys import Sofa

def createScene(rootNode): rootNode.addObject('RequiredPlugin', pluginName='BeamAdapter SofaMeshCollision SofaBoundaryCondition SofaConstraint SofaMiscCollision SofaDeformable SofaGeneralLinearSolver SofaImplicitOdeSolver SofaLoader SofaOpenglVisual SofaTopologyMapping') rootNode.addObject('VisualStyle', displayFlags='showVisualModels showBehaviorModels showCollisionModels hideMappings hideForceFields')

rootNode.addObject('DefaultVisualManagerLoop')
rootNode.addObject('FreeMotionAnimationLoop')

rootNode.addObject('LCPConstraintSolver',mu='0.1',tolerance='1e-10',maxIt='1000',build_lcp='false')
rootNode.addObject('DefaultPipeline', draw='0', depth='6', verbose='1')
rootNode.addObject('BruteForceBroadPhase')
rootNode.addObject('BVHNarrowPhase')
rootNode.addObject('LocalMinDistance',name='localmindistance',alarmDistance='2',contactDistance='1',angleCone='0.8',coneFactor='0.8')
rootNode.addObject('DefaultContactManager',name='Response',response='FrictionContact')
rootNode.addObject('DefaultCollisionGroupManager',name='Group')

topoLines_cath = rootNode.addChild('topoLines_cath')
topoLines_cath.addObject('WireRestShape',name='catheterRestShape',template='Rigid3d',printLog='0',length=1000.0, straightLength=600,spireDiameter=4000.0,spireHeight=0.0,densityOfBeams=[40,10],numEdges=200, numEdgesCollis=[40,20],youngModulus=10000 ,youngModulusExtremity=10000)
topoLines_cath.addObject('EdgeSetTopologyContainer',name='meshLinesCath')
topoLines_cath.addObject('EdgeSetTopologyModifier', name='Modifier')
topoLines_cath.addObject('EdgeSetGeometryAlgorithms',name='GeomAlgo',template='Rigid3d')
topoLines_cath.addObject('MechanicalObject',template='Rigid3d',name='dofTopo1')

topoLines_guide = rootNode.addChild('topoLines_guide')
topoLines_guide.addObject('WireRestShape',name='GuideRestShape',template='Rigid3d',printLog='0',length=1000.0, straightLength=980.0, spireDiameter=25, spireHeight=0.0,densityOfBeams=[30 ,5],numEdges=200,numEdgesCollis=[50, 10], youngModulus=10000,youngModulusExtremity=10000)
topoLines_guide.addObject('EdgeSetTopologyContainer',name='meshLinesGuide')
topoLines_guide.addObject('EdgeSetTopologyModifier',name='Modifier')
topoLines_guide.addObject('EdgeSetGeometryAlgorithms',name='GeomAlgo',template='Rigid3d')
topoLines_guide.addObject('MechanicalObject', template='Rigid3d', name='dofTopo2')

topoLines_coils = rootNode.addChild('topoLines_coils')
topoLines_coils.addObject('WireRestShape',name='CoilRestShape',template='Rigid3d',printLog='0',length=600.0, straightLength=540.0,spireDiameter=7, spireHeight=5.0,densityOfBeams=[40,20], numEdges=400, numEdgesCollis=[30,30],youngModulus=168000, youngModulusExtremity=168000)
topoLines_coils.addObject('EdgeSetTopologyContainer',name='meshLinesCoils')
topoLines_coils.addObject('EdgeSetTopologyModifier',name='Modifier')
topoLines_coils.addObject('EdgeSetGeometryAlgorithms',name='GeomAlgo', template='Rigid3d')
topoLines_coils.addObject('MechanicalObject',template='Rigid3d',name='dofTopo3')

InstrumentCombined = rootNode.addChild('InstrumentCombined')
InstrumentCombined.addObject('EulerImplicitSolver',rayleighStiffness=0.2,rayleighMass=0.1,printLog='false')
InstrumentCombined.addObject('BTDLinearSolver',subpartSolve='0',verification='0',verbose='0')
InstrumentCombined.addObject('RegularGridTopology',name='meshLinesCombined',nx=60, ny=1, nz=1,xmin=0.0, xmax=1.0,ymin=0, ymax=0,zmin=1, zmax=1)
InstrumentCombined.addObject('MechanicalObject',template='Rigid3d',name='DOFs',showIndices='0',ry=-90)
InstrumentCombined.addObject('WireBeamInterpolation',name='InterpolCatheter',WireRestShape='@../topoLines_cath/catheterRestShape',radius=1,printLog='0')
InstrumentCombined.addObject('AdaptiveBeamForceFieldAndMass',name='CatheterForceField',interpolation='@InterpolCatheter',massDensity=0.00000155)
InstrumentCombined.addObject('WireBeamInterpolation', name='InterpolGuide', WireRestShape='@../topoLines_guide/GuideRestShape', radius=0.9, printLog='0')
InstrumentCombined.addObject('AdaptiveBeamForceFieldAndMass',name='GuideForceField',interpolation='@InterpolGuide',massDensity=0.00000155)
InstrumentCombined.addObject('WireBeamInterpolation', name='InterpolCoils', WireRestShape='@../topoLines_coils/CoilRestShape', radius=0.1, printLog='0')
InstrumentCombined.addObject('AdaptiveBeamForceFieldAndMass', name='CoilsForceField', interpolation='@InterpolCoils', massDensity=0.000021)
InstrumentCombined.addObject('InterventionalRadiologyController',name='m_ircontroller',template='Rigid3d',printLog='0',instruments='InterpolCatheter InterpolGuide InterpolCoils',startingPos=[0, 0 ,0 ,0 ,-0.7071068, 0, 0.7071068],xtip=[1 ,0 ,0] ,rotationInstrument=[0, 0, 0 ],controlledInstrument=0,step=3,speed=2 )
InstrumentCombined.addObject('LinearSolverConstraintCorrection',printLog='false',wire_optimization='true')
InstrumentCombined.addObject('FixedConstraint',name='FixedConstraint',indices='0')
InstrumentCombined.addObject('RestShapeSpringsForceField',points='@m_ircontroller.indexFirstNode',stiffness=1e8,angularStiffness=1e8)

Collis = InstrumentCombined.addChild('Collis')
Collis.activated= True
Collis.addObject('EdgeSetTopologyContainer', name='collisEdgeSet')
Collis.addObject('EdgeSetTopologyModifier',name='colliseEdgeModifier')
Collis.addObject('MechanicalObject',name='CollisionDOFs')
Collis.addObject('MultiAdaptiveBeamMapping',name='collisMap', controller='../m_ircontroller',useCurvAbs='1',printLog='0')
Collis.addObject('LineCollisionModel',proximity=0.0,group='1')
Collis.addObject('PointCollisionModel', proximity=0.0, group='1')

VisuCatheter = InstrumentCombined.addChild('VisuCatheter')
VisuCatheter.activated= True
VisuCatheter.addObject('MechanicalObject',name='Quads')
VisuCatheter.addObject('QuadSetTopologyContainer',name='ContainerCath')
VisuCatheter.addObject('QuadSetTopologyModifier',name='Modifier')
VisuCatheter.addObject('QuadSetGeometryAlgorithms',name='GeomAlgo', template='Vec3d')
VisuCatheter.addObject('Edge2QuadTopologicalMapping',nbPointsOnEachCircle='10',radius=2,input='@../../topoLines_cath/meshLinesCath',output='@ContainerCath',flipNormals=True)
VisuCatheter.addObject('AdaptiveBeamMapping',name='VisuMapCath',useCurvAbs='1', printLog='0', interpolation='@../InterpolCatheter', input='@../DOFs', output='@Quads', isMechanical=False)
VisuOgl =  VisuCatheter.addChild('VisuOgl')
VisuOgl.activated= True
VisuOgl.addObject('OglModel',name='Visual',color='0.7 0.7 0.7', quads='@../ContainerCath.quads',material='texture Ambient 1 0.2 0.2 0.2 0.0 Diffuse 1 1.0 1.0 1.0 1.0 Specular 1 1.0 1.0 1.0 1.0 Emissive 0 0.15 0.05 0.05 0.0 Shininess 1 20')
VisuOgl.addObject('IdentityMapping',input='@../Quads',output='@Visual')

VisuGuide = InstrumentCombined.addChild('VisuGuide')
VisuGuide.activated= True
VisuGuide.addObject('MechanicalObject',name='Quads')
VisuGuide.addObject('QuadSetTopologyContainer',name='ContainerGuide')
VisuGuide.addObject('QuadSetTopologyModifier',name='Modifier')
VisuGuide.addObject('QuadSetGeometryAlgorithms',name='GeomAlgo', template='Vec3d')
VisuGuide.addObject('Edge2QuadTopologicalMapping',nbPointsOnEachCircle='10',radius=1,input='@../../topoLines_guide/meshLinesGuide',output='@ContainerGuide', flipNormals=True,listening=True)
VisuGuide.addObject('AdaptiveBeamMapping',name='visuMapGuide',useCurvAbs='1',printLog='0',interpolation='@../InterpolGuide',input='@../DOFs',output='@Quads',isMechanical=False)
VisuOgl =  VisuGuide.addChild('VisuOgl')
VisuOgl.activated = True
VisuOgl.addObject('OglModel',name='Visual', color='0.2 0.2 0.8' , material='texture Ambient 1 0.2 0.2 0.2 0.0 Diffuse 1 1.0 1.0 1.0 1.0 Specular 1 1.0 1.0 1.0 1.0 Emissive 0 0.15 0.05 0.05 0.0 Shininess 1 20', quads='@../ContainerGuide.quads')
VisuOgl.addObject('IdentityMapping', input='@../Quads', output='@Visual')

VisuCoils = InstrumentCombined.addChild('VisuCoils')
VisuCoils.activated= True
VisuCoils.addObject('MechanicalObject',name='Quads')
VisuCoils.addObject('QuadSetTopologyContainer',name='ContainerCoils')
VisuCoils.addObject('QuadSetTopologyModifier',name='Modifier' )
VisuCoils.addObject('QuadSetGeometryAlgorithms', name='GeomAlgo',template='Vec3d')
VisuCoils.addObject('Edge2QuadTopologicalMapping',nbPointsOnEachCircle='10',radius=0.3, input='@../../topoLines_coils/meshLinesCoils',output='@ContainerCoils', flipNormals=True,listening=True)
VisuCoils.addObject('AdaptiveBeamMapping', name='visuMapCoils',useCurvAbs='1',printLog='0',interpolation='@../InterpolCoils',input='@../DOFs',output='@Quads',isMechanical='false')
VisuOgl = VisuCoils.addChild('VisuOgl')
VisuOgl.activated = True
VisuOgl.addObject('OglModel',name='Visual', color='0.2 0.8 0.2',  material='texture Ambient 1 0.2 0.2 0.2 0.0 Diffuse 1 1.0 1.0 1.0 1.0 Specular 1 1.0 1.0 1.0 1.0 Emissive 0 0.15 0.05 0.05 0.0 Shininess 1 20',quads='@../ContainerCoils.quads')
VisuOgl.addObject('IdentityMapping',input='@../Quads',output='@Visual')

CollisionModel = InstrumentCombined.addChild('CollisionModel')
CollisionModel.addObject('MeshObjLoader',name='meshLoader',filename='D:/DefrostSofaBundle_win64_python3.8_v22.06.00-beta4/DefrostSofaBundle_win64_python3.8_v22.06.00-beta4/plugins/BeamAdapter/examples/mesh/phantom.obj',triangulate='true',flipNormals='1')
CollisionModel.addObject('MeshTopology', position='@meshLoader.position',  triangles='@meshLoader.triangles')
CollisionModel.addObject('MechanicalObject', name='DOFs1', position=[0, 0 ,400], scale='3',ry='90')
CollisionModel.addObject('TriangleCollisionModel', simulated='0', moving='0')
CollisionModel.addObject('LineCollisionModel', simulated='0', moving='0')
CollisionModel.addObject('PointCollisionModel', simulated='0', moving='0')
CollisionModel.addObject('OglModel',name='Visual',src='@meshLoader',color='1 0 0 0.3',scale='3',ry='90')

return rootNode
zhanglepy commented 2 weeks ago

I use the Windows system, sofa22.06 version. I don't know whether you mean compile in tree or compile out of tree. I compile on pychar, and the crash occurs at the beginning.我使用的是 Windows 系统,sofa22.06 版本。我不知道你的意思是 compile in tree 还是 compile out of tree。我在 pychar 上编译,崩溃发生在开始时。

How to use PyCharm to run programs directly on an uncompiled version of Sofa Do you know how to use PyCharm to run programs on Sofa compiled by yourself in Ubuntu/Windows system? Because previously I used already compiled versions of Sofa, now I need to use a plugin Optimus (the official website only has self compiled methods).Thank you!