Home › Forum › SOFA › Using SOFA › [SOLVED] Performance issues with haptics and deformable objects
- This topic has 4 replies, 3 voices, and was last updated 8 years, 10 months ago by
Le Gouis.
-
AuthorPosts
-
8 July 2015 at 14:48 #3419
Le Gouis
BlockedHello,
I am trying to have interact with a deformable cylinder using a Phantom haptic device.
I experience important drop in performances while in contact with the cylinder, mainly due to the UncoupledConstraintCorrection element (see full scene below).
Computation time of this element can go up to 1.5s, with as many as 20000 constraints treated in one timestep (the cylinder has 2400 tetrahedra).
Am I doing something wrong in my scene, or is it just not possible to have better performances with the current state of the framework?Thanks
Benoit
as promised, the scene (in Python):
import Sofa
class Scene_haptique(Sofa.PythonScriptController):
def createGraph(self,node):
# =============================================================================================================
node.findData(‘name’).value = ‘Root’
node.findData(‘gravity’).value = [ 0.0, -9.81, 0.0 ]
node.createObject( ‘VisualStyle’, name=’VisualStyle’, displayFlags=”showVisual hideBehavior showCollisionModels hideBoundingCollisionModels hideMapping hideOptions” )
node.createObject( ‘DefaultPipeline’, name=’DefaultCollisionPipeline’ )
node.createObject( ‘BruteForceDetection’, name=’BruteForceDetection’ )
node.createObject( ‘DefaultContactManager’, name=’DefaultContactManager’, response=’FrictionContact’ )
node.createObject( ‘FreeMotionAnimationLoop’, name=’FreeMotionAnimationLoop’ )
node.createObject( ‘GenericConstraintSolver’, name=’GenericConstraintSolver’ )
node.createObject( ‘LocalMinDistance’, name=’LocalMinDistance’, alarmDistance=’0.05′, contactDistance=’0.02′ )# =============================================================================================================
haptic = node.createChild(‘HapticInterface’)
haptic.createObject(‘MechanicalObject’, template=”Rigid”, name=”MechanicalObject”, tags=”Omni”, position=”0 0 0 0 0 0 1″, velocity=”0 0 0 0 0 0″, force=”0 0 0 0 0 0″, externalForce=”0 0 0 0 0 0″, derivX=”0 0 0 0 0 0″, restScale=”1″, translation=”1 1 2″)
haptic.createObject(‘NewOmniDriver’, name=”OmniDriver”, tags=”Omni”, scale=”40″, permanent=”true”, listening=”true”)simulated = node.createChild(‘Simulated’)
simulated.createObject(‘EulerImplicitSolver’, name=”ODE solver” )
simulated.createObject(‘CGLinearSolver’, template=”GraphScattered”, name=”linear solver”)physics = simulated.createChild(“Physics”)
physics.createObject(‘MechanicalObject’, template=”Rigid”, name=”MechanicalObject”, position=”0 0.5 0 0 0 0 1″, velocity=”0 0 0 0 0 0″, force=”0 0 0 0 0 0″, externalForce=”0 0 0 0 0 0″, derivX=”0 0 0 0 0 0″, restScale=”1″, translation=”1 1 2″)
physics.createObject(‘UniformMass’, template=”Rigid”, name=”uniformMass5″, totalmass=”0.05″)
physics.createObject(‘UncoupledConstraintCorrection’, template=”Rigid”, name=”UncoupledConstraintCorrection”, compliance=”0.1″ )
physics.createObject(‘LCPForceFeedback’, activate=”true”, tags=”Omni”, forceCoef=”0.05″)colli = physics.createChild(‘CollisionModel’)
colli.createObject(‘MechanicalObject’, template=”Vec3d”, name=”MechanicalObject”, position=”0 0 0″ )
colli.createObject(‘RigidMapping’, template=”Rigid,Vec3d”, name=”MM-CM Mapping”)
colli.createObject(‘TSphereModel’, template=”Vec3d”, name=”Collision”, radius=”0.05″)physics.createObject(‘RestShapeSpringsForceField’, template=”Rigid”, stiffness=”20000″, angularStiffness=”20000″, external_rest_shape=”../../HapticInterface/MechanicalObject” )
# =============================================================================================================
tetrahedra = node.createChild(‘Tetrahedral Mesh Normal’)
tetrahedra.createObject(‘MeshGmshLoader’, name=’loader’, filename=’mesh/cylinder.msh’, translation=”0 0 0″, tetrahedraGroups=” -1 0 18″)
tetrahedra.createObject(‘MechanicalObject’, template=’Vec3d’, name=’Volume’, position=’@loader.position’, velocity=”0 0 0″, force=”0 0 0″, externalForce=”0 0 0″, restScale=’1′)
tetrahedra.createObject(‘MeshTopology’, src=”@loader”, name=”CylinderCollisionModel”)
tetrahedra.createObject(‘EulerImplicitSolver’, name=’cg_odesolver’, printLog=’0′)
tetrahedra.createObject(‘CGLinearSolver’, template=’GraphScattered’, name=’linear solver’, iterations=’25’, tolerance=’1e-009′, threshold=’1e-009′)
tetrahedra.createObject(‘TetrahedronSetTopologyContainer’, name=’Container’, fileTopology=’mesh/cylinder.msh’, tetrahedra=’@loader.tetrahedra’)
tetrahedra.createObject(‘TetrahedronSetGeometryAlgorithms’, template=’Vec3d’, name=’GeomAlgo’, drawTetrahedra=’0′, drawColorTetrahedra=”1 1 0.3″)
tetrahedra.createObject(‘TetrahedronFEMForceField’, template=’Vec3d’, name=’FEM’, method=’large’, poissonRatio=’0.3′, youngModulus=’360′, computeGlobalMatrix=’0′)
tetrahedra.createObject(‘DiagonalMass’, template=’Vec3d’, name=’diagonalMass1′, massDensity=’2′)
tetrahedra.createObject(‘FixedPlaneConstraint’, template=’Vec3d’, name=’fixedPlaneConstraint1′, direction=”0 0 1″, dmin=’-0.1′, dmax=’0.1′)
tetrahedra.createObject(‘FixedConstraint’, template=’Vec3d’, name=’fixedConstraint1′, indices=ran(0, 50))
tetrahedra.createObject(‘UncoupledConstraintCorrection’, template=”Vec3d”, name=”UncoupledConstraintCorrection”, compliance=”0.1″)# =============================================================================================================
visu = tetrahedra.createChild(‘Visu’)
visu.createObject(‘OglModel’, template=’ExtVec3f’, name=’Visual’, material=”Default Diffuse 1 0 0 1 1 Ambient 1 0 0 0.2 1 Specular 0 0 0 1 1 Emissive 0 0 0 1 1 Shininess 0 45 “, primitiveType=’DEFAULT’, blendEquation=’GL_FUNC_ADD’, sfactor=’GL_SRC_ALPHA’, dfactor=’GL_ONE_MINUS_SRC_ALPHA’)
visu.createObject(‘BarycentricMapping’, name=”Mapping”, input=”@../”, output=”@./”)collision2 = tetrahedra.createChild(‘Collision Model’)
collision2.createObject(‘MeshGmshLoader’, name=’loader’, filename=’mesh/cylinder.msh’)
collision2.createObject(‘MeshTopology’, name=”Collision”, src=”@loader”)
collision2.createObject(‘MechanicalObject’, src=”@loader”, template=”Vec3d”, name=”cylinderCollisionState”, position=”0 0 0″, velocity=”0 0 0″, force=”0 0 0″, derivX=”0 0 0″, free_position=”0 0 0″, free_velocity=”0 0 0″, restScale=”1″, translation=”0 0 0″, rotation=”0 0 0″)
collision2.createObject(‘TTriangleModel’, template=”Vec3d”, name=”cylinder”, contactStiffness=”10″)
collision2.createObject(‘LineModel’, name=”cylinder”, contactStiffness=”10″)
collision2.createObject(‘PointModel’, name=”cylinder”, contactStiffness=”10″)
collision2.createObject(‘BarycentricMapping’, template=”Vec3d,Vec3d”, name=”Mapping”)return 0
29 September 2015 at 20:03 #3702Duriez
BlockedDear Benoit,
I think the problem is not coming from the UncoupledConstraintCorrection but on the fact that SOFA has to treat 20000 constraints in real-time ;-))
Something must be wrong with the collision detection method. You have too much constraints.. but I don’t know where the problem comes from…
What is the size of your models ? In the “localMinDistance” you set a “contact Distance” of 0.05. If distance are in meter in your scene and that the typical sizes of your object are 10 mm long, it means that you will detect many contact, and it is no more a proximity…
Try also to remove the TSphereModel and replace it with a PointModel (and put proximty= the radius) ? Is it the same behavior ?
Christian
2 October 2015 at 16:13 #3729Le Gouis
BlockedHello Christian,
Thanks for the answer.
For now, I only have the cylinder model from the tutorials, with a 0.25 base radius and a length of 1.
I interact with this cylinder through a material point (I changed the TSphereModel to a PointModel).
I have set the alarm distance to 0.02 and the contact distance to 0.01, and it seems that any value below these result in my setup results in the point going inside the cylinder.
These changes have led to a significant improvement, since the extreme interaction cases only create 4000-5000 constraints now, and average mean computation time is about 15-20ms, for a light touch on the surface, which is not optimal for haptic interaction, but still much better than before.Thanks,
Benoît
21 October 2015 at 08:25 #3784Hugo
KeymasterDear Benoit,
It seems that your issue has been solved. Would you need further help before I set the topic as “solved” ?
Best,
Hugo
24 October 2015 at 16:46 #3871Le Gouis
BlockedHello Hugo,
You can set the topic as solved, the answer greatly helped.
Thanks,
Benoît
-
AuthorPosts
- You must be logged in to reply to this topic.