Home › Forum › SOFA › Using SOFA › [SOLVED] Objects with triangular collision model overlapping
Tagged: MacOS, SOFA_2106, XML collision
- This topic has 8 replies, 2 voices, and was last updated 3 years, 2 months ago by jane.l.
-
AuthorPosts
-
9 August 2021 at 15:40 #20146jane.lBlocked
Hello all,
I am new to the framework and I am trying to simulate the lumbar spine. Since the vertebrae are rigid bodies I would not like them to overlap at all, but that is not the case in my case with the XML script… Could you please help me? here is the code:
NOTE: I put … where the points indexes or springs should be because they are quite a lot I did not want to spam. If you want to try the code here is the full script with the files on GitHub: https://github.com/lameski123/sofa_framework<?xml version="1.0" ?> <Node name="root" dt="0.01"> <RequiredPlugin name="SofaLoader"/> <RequiredPlugin name="SofaDeformable"/> <RequiredPlugin name="SofaMeshCollision"/> <RequiredPlugin name="SofaEngine"/> <RequiredPlugin name="SofaRigid"/> <RequiredPlugin name="SofaBoundaryCondition"/> <RequiredPlugin name="SofaImplicitOdeSolver"/> <RequiredPlugin name="SofaConstraint"/> <RequiredPlugin name="SofaOpenglVisual"/> <RequiredPlugin name="SofaExporter"/> <VisualStyle displayFlags="showVisual showForceFields showCollisionModels" /> <DefaultPipeline depth="0" verbose="0" draw="0"/> <BruteForceBroadPhase/> <BVHNarrowPhase/> <LocalMinDistance name="Proximity" alarmDistance="0.05" contactDistance="0.000001" angleCone="0.0"/> <DefaultContactManager name="Response" response="FrictionContact"/> <Node name="Together"> <EulerImplicitSolver name="cg_odesolver" printLog="0" rayleighStiffness="0.09" rayleighMass="1" /> <CGLinearSolver name="linear solver" iterations="1000" tolerance="1e-09" threshold="1e-15" /> <Node name="vert1"> <!-- center of mass --> <MechanicalObject name="center_mass1" template="Rigid3d"/> <RestShapeSpringsForceField name="fixedPoints1" stiffness="5000" angularStiffness="500"/> <!-- surface mesh --> <Node name="mecha_node1"> <MeshSTLLoader name="STLLoader1" filename="mesh/v1.stl" printLog="true" flipNormals="0" /> <MeshTopology name = "v1_topology" src="@STLLoader1"/> <MechanicalObject name="points1" template="Vec3d" src = "@v1_topology" /> <TriangleCollisionModel/> <!-- <Node name="VisualModel1">--> <!-- <OglModel name="Visual" src="@../STLLoader1" color="white" translation="0 0 0" />--> <!-- <IdentityMapping />--> <!-- </Node>--> <RigidMapping input="@.." output="@."/> <VTKExporter filename="vert1" listening="true" edges="0" triangles="1" quads="0" tetras="0" pointsDataFields="points1.position" exportEveryNumberOfSteps="30"/> </Node> <TriangleCollisionModel/> </Node> <Node name="vert2"> <!-- center of mass --> <MechanicalObject name="center_mass2" template="Rigid3d"/> <RestShapeSpringsForceField name="fixedPoints2" stiffness="500" angularStiffness="50"/> <!-- surface mesh --> <Node name="mecha_node2"> <MeshSTLLoader name="STLLoader2" filename="mesh/v2.stl" printLog="true" flipNormals="0" /> <MeshTopology name = "v2_topology" src="@STLLoader2"/> <MechanicalObject name="points2" template="Vec3d" src = "@v2_topology" /> <TriangleCollisionModel/> <!-- <Node name="VisualModel2">--> <!-- <OglModel name="Visual" src="@../STLLoader2" color="white" translation="0 0 0" />--> <!-- <IdentityMapping />--> <!-- </Node>--> <!-- <ConstantForceField force="-0.005 0 0"/>--> <RigidMapping input="@.." output="@."/> <VTKExporter filename="vert2" listening="true" edges="0" triangles="1" quads="0" tetras="0" pointsDataFields="points2.position" exportEveryNumberOfSteps="30"/> </Node> <TriangleCollisionModel/> </Node> <Node name="vert3"> <!-- center of mass --> <MechanicalObject name="center_mass3" template="Rigid3d"/> <RestShapeSpringsForceField name="fixedPoints3" stiffness="500" angularStiffness="50"/> <!-- surface mesh --> <Node name="mecha_node3"> <MeshSTLLoader name="STLLoader3" filename="mesh/v3.stl" printLog="true" flipNormals="0" /> <MeshTopology name = "v3_topology" src="@STLLoader3"/> <MechanicalObject name="points3" template="Vec3d" src = "@v3_topology" /> <TriangleCollisionModel/> <!-- <Node name="VisualModel3">--> <!-- <OglModel name="Visual" src="@../STLLoader3" color="white" translation="0 0 0" />--> <!-- <IdentityMapping />--> <!-- </Node>--> <RigidMapping input="@.." output="@."/> <!-- <ConstantForceField force="0.01 0 0"/>--> <ConstantForceField force="0.05 0 0"/> <VTKExporter filename="vert3" listening="true" edges="0" triangles="1" quads="0" tetras="0" pointsDataFields="points3.position" exportEveryNumberOfSteps="30"/> </Node> <TriangleCollisionModel/> </Node> <Node name="vert4"> <!-- center of mass --> <MechanicalObject name="center_mass4" template="Rigid3d"/> <RestShapeSpringsForceField name="fixedPoints4" stiffness="500" angularStiffness="50"/> <!-- surface mesh --> <Node name="mecha_node4"> <MeshSTLLoader name="STLLoader4" filename="mesh/v4.stl" printLog="true" flipNormals="0" /> <MeshTopology name = "v4_topology" src="@STLLoader4"/> <MechanicalObject name="points4" template="Vec3d" src = "@v4_topology" /> <TriangleCollisionModel/> <!-- <Node name="VisualModel4">--> <!-- <OglModel name="Visual" src="@../STLLoader4" color="white" translation="0 0 0" />--> <!-- <IdentityMapping />--> <!-- </Node>--> <!-- <ConstantForceField force="0.005 0 0"/>--> <RigidMapping input="@.." output="@."/> <VTKExporter filename="vert4" listening="true" edges="0" triangles="1" quads="0" tetras="0" pointsDataFields="points4.position" exportEveryNumberOfSteps="30"/> </Node> <TriangleCollisionModel/> </Node> <Node name="vert5"> <!-- center of mass --> <MechanicalObject name="center_mass5" template="Rigid3d"/> <RestShapeSpringsForceField name="fixedPoints5" stiffness="5000" angularStiffness="500"/> <!-- surface mesh --> <Node name="mecha_node5"> <MeshSTLLoader name="STLLoader5" filename="mesh/v5.stl" printLog="true" flipNormals="0" /> <MeshTopology name = "v5_topology" src="@STLLoader5"/> <MechanicalObject name="points5" template="Vec3d" src = "@v5_topology" /> <TriangleCollisionModel/> <!-- <Node name="VisualModel5">--> <!-- <OglModel name="Visual5" src="@../STLLoader5" color="white" translation="0 0 0" />--> <!-- <IdentityMapping />--> <!-- </Node>--> <RigidMapping input="@.." output="@."/> <VTKExporter filename="vert5" listening="true" edges="0" triangles="1" quads="0" tetras="0" pointsDataFields="points5.position" exportEveryNumberOfSteps="30"/> </Node> <TriangleCollisionModel/> </Node> <!--FIXED--> <Node name="fixed_points1"> <MechanicalObject name="Particles1" template="Vec3d" position=" ... "/> <MeshTopology name="Topology" hexas=" ... "/> <UniformMass name="Mass" vertexMass="1" /> <FixedConstraint template="Vec3d" name="fixedConstraint1" indices="... "/> </Node> <Node name="fixed_points5"> <MechanicalObject name="Particles5" template="Vec3d" position="... "/> <MeshTopology name="Topology" hexas="... "/> <UniformMass name="Mass" vertexMass="1" /> <FixedConstraint template="Vec3d" name="fixedConstraint5" indices="... "/> </Node> <StiffSpringForceField template="Vec3d" name="points_fixed1" object1="@fixed_points1/Particles1" object2="@vert1/mecha_node1/points1" spring=" ... "/> <StiffSpringForceField template="Vec3d" name="points_fixed5" object1="@fixed_points5/Particles5" object2="@vert5/mecha_node5/points5" spring="... "/> <!-- BETWEEN VERTEBRA--> <StiffSpringForceField template="Vec3d" name="box_springs1" object1="@vert1/mecha_node1/points1" object2="@vert2/mecha_node2/points2" spring=" ..."/> <StiffSpringForceField template="Vec3d" name="box_springs2" object1="@vert2/mecha_node2/points2" object2="@vert3/mecha_node3/points3" spring=" ... "/> <StiffSpringForceField template="Vec3d" name="box_springs3" object1="@vert3/mecha_node3/points3" object2="@vert4/mecha_node4/points4" spring=" ... "/> <StiffSpringForceField template="Vec3d" name="box_springs4" object1="@vert4/mecha_node4/points4" object2="@vert5/mecha_node5/points5" spring=" ... "/> </Node> </Node>
9 August 2021 at 16:25 #20147Alex BilgerBlockedHi,
have you played with the LocalMinDistance parameters? Also, try adding line and point collision models along with the triangle collision models.
Alex
9 August 2021 at 18:05 #20148jane.lBlockedHi Alex,
Thank you for the reply.
With the current parameters and the adding of line and point collision, the SOFA framework freezes(because of point collision), and after some time I get(because of linear collision):
[WARNING] [LocalMinDistance(Proximity)] Determinant is nullI played around with the LocalMinDistance parameters but they did not help me, unfortunately.
Best,
Jane9 August 2021 at 18:14 #20149Alex BilgerBlockedHaving triangle/line/point collision models is the usual practice when dealing with collision. It is weird that it freezes.
The warning you get is not necessarily a big deal. It happens when 2 edges are parallel.
Have you noticed that you have two TriangleCollisionModel for each object? I don’t know exactly what the consequences are, but I would not put a TriangleCollisionModel in the main node. Only one one the surface mesh node.Can you be more precise on the result you get with the scene you posted? Do you have collision response? Or it is just that you want better precision in the collision detection?
9 August 2021 at 18:25 #20150jane.lBlockedHere is an example image of what i get.
What I would like to have is non overleaping parts of the bones.
I agree with you the TriangleCollisionModel in the main node is redundant, i got a bit frustrated and started trying things out.9 August 2021 at 18:27 #201519 August 2021 at 18:41 #20152Alex BilgerBlockedOk, but do you get any collision response right now?
One thing I would check is ifresponse="FrictionContact"
is compatible with aDefaultAnimationLoop
. I suspect that you need a constraint-compatible animation loop (with a constraint solver), like in the scene https://github.com/sofa-framework/sofa/blob/master/examples/Components/constraint/FrictionContact.scn. Otherwise, you would need to use penalities. Someone else can probably better explain than me.10 August 2021 at 01:07 #20153jane.lBlockedI do not quite understand what collision response is, if that are the green/red lines that appear when the objects are at alarmingDistance/contactDistance than no I could not see any.
Although I tried to go with the proposed scene, I could still not solve the problem with the collision (may be a problem of high scale computation when the solver is solving big amount of points, the mesh per single vertebra is ~20000 points).
I added StiffSpringForceField at the problematic parts with which did not allow them to move enough so that they can overlap.
Thanks for your time Alex, I really appreciate it!
Best,
Jane.21 August 2021 at 11:46 #20188 -
AuthorPosts
- You must be logged in to reply to this topic.