Home › Forum › SOFA › Using SOFA › [SOLVED] Collision detection problem
Tagged: 32_bits, Linux_ubuntu, SOFA_1503
- This topic has 21 replies, 3 voices, and was last updated 7 years, 9 months ago by Hugo.
-
AuthorPosts
-
15 December 2016 at 14:32 #8210luibass92Blocked
Hi everyone,
I have my scene with an anthropomorphic hand and a deformable sphere that should collide with it.
What happens is that when the sphere touches the hand’s palm everything goes fine and the collision is detected (the sphere changes its shape and rolls to the fingers).
When the sphere arrives to the fingers the collision is not longer recognized and the sphere falls down.
The only difference between the palm and the finger is that the palm’s mesh is linked to a fixed frame (the origin) of the articulated chain while the fingers’ meshes are linked to not fixed frames of the articulate chain, I move them in real-time through external data. In the example the external data are always “0” so the fingers don’t move from their zero position (at each time step I send “0” for each joint of the fingers).
Someone knows how to solve this issue?
Cheers,
Luigi15 December 2016 at 23:49 #8211HugoKeymasterHi Luigi,
This hand reminds me another topic 😉
Simple question: have you checked the normals of your finger meshes?
Did you make sure the sphere and the fingers weren’t in the same collision group?Cheers,
Hugo
16 December 2016 at 10:34 #8212luibass92BlockedHi Hugo,
Yes, the hand is always the same 🙂
I’ve already checked the normals of the fingers and they seem OK (they go outside of the mesh).
I’ve also put the sphere and the fingers in different groups: all the hand’s meshes are group 1 and the sphere is group 2…If it can help I post a portion of the code:
<Node name="articulationHand"> <MechanicalObject name="Articulations" template="Vec1d" position="0 0 0 0" /> <Node> <EulerImplicit name="cg odesolver" printLog="false" /> <CGLinearSolver iterations="100" name="linear solver" threshold="1e-20" tolerance="1e-20" /> <MechanicalObject template="Rigid" name="DOFs" position="0 0 0 0 0 0 1 0 11 -0.6 0 0 0 1 0 16.004 -0.6 0 0 0 1 . . . <!--The same for each frame of the hand--> ." /> <UniformMass template="Rigid" name="mass" mass="0.1 0.1 [1 0 0,0 1 0,0 0 1]" /> <FixedConstraint template="Rigid" name="fixOrigin" indices="0" /> <ArticulatedSystemMapping input1="@../Articulations" output="@DOFs" /> <!--######################### PALM #########################--> <Node name="Collision" activated="1"> <MeshObjLoader name="MeshLoader" filename="mesh/h10d.obj" scale="100" translation="0 0 0.7" rotation="0 180 0" /> <Mesh src="@MeshLoader" /> <MechanicalObject template="Vec3d" src="@MeshLoader" /> <TriangleModel group="1"/> <LineModel group="1"/> <RigidMapping input="@.." index="0"/> </Node> <Node name="Visu" activated="1"> <OglModel name="Visual" filename="mesh/h10s.obj" scale="100" translation="0 0 0.7" rotation="0 180 0"/> <RigidMapping template="Rigid3d,ExtVec3f" input="@.." index="0" output="@Visual" /> </Node> . . . <!-- The same for each mesh of the hand --> . . </Node> <ArticulatedHierarchyContainer filename="BehaviorModels/schunkHand3.bvh"/> <!--MIDDLE: J1~J3 INDEX: J4~J7 PALM(two identical joints): J8 = J8_2 RING: J9~J12 LITTLE: J13~J16 THUMB J17~J20 (Jdummy used for the thumb orientation)--> <ArticulatedHierarchyModifier J1="0" J2="0" . . .<!--The same for each Joint (sent through socket)--> . . /> <ArticulatedHierarchyBVHController /> </Node> <!--articulationHand--> <!--################# SPHERE ########################--> <Node name= "sphere"> <EulerImplicit name="cg odesolver" printLog="false" /> <CGLinearSolver iterations="100" name="linear solver" threshold="1e-20" tolerance="1e-20" /> <MeshVTKLoader name="MeshLoader" filename="mesh/sphere10.vtu" /> <Mesh src="@MeshLoader" /> <TetrahedronSetTopologyContainer name="topo" src="@MeshLoader" /> <TetrahedronSetGeometryAlgorithms drawEdges="0" /> <MechanicalObject name="dofs" src="@MeshLoader" rotation="45 0 0" translation="0.0 10 7.5" scale = "100"/> <UniformMass mass="0.2"/> <TetrahedronFEMForceField name="FEM" youngModulus="5000" poissonRatio="0.3" method="large" /> <Node name="sourceSurface"> <MeshObjLoader name="Surface" filename="mesh/sphere.obj" /> <Mesh src="@Surface" /> <MechanicalObject name="surf" position = "@[-1].position" template="Vec3d" rotation="45 0 0" translation="0.0 10 7.5" scale = "100" /> <TriangleSetGeometryAlgorithms template="Vec3d" name="Geometry Algorithms"/> <TriangleModel group="2"/> <BarycentricMapping /> </Node> </Node>
“ArticulatedHierarchyModifier” is a component created by me that just modifies the joints value of the articulated chain step-by-step reading them from socket (it works good).
I have the suspect that the issue is due to the fact that I pass the joints values through socket and SOFA refreshes them at each time step, in this case SOFA refreshes always “0”, so the hand apparently doesn’t move, but virtually it changes its position from “0” to “0” (again) at each time step and this causes some problems to the collision detection…
EDIT
This is a short gif animation that shows the issue:Cheers,
Luigi10 January 2017 at 16:18 #8317luibass92BlockedI have not found a solution yet…
Does anyone have figured out something ?Cheers,
Luigi10 January 2017 at 16:52 #8318HugoKeymasterHi Luigi,
You said, the GIF you provided shows the issue?
But it seems that the collision is detected.Isn’t it an issue of time steps / stability ? alarm and contact distance ?
Could you tell us more about your collision pipeline?
what is the collision detection method you are using? what contact manager ? etc.Cheers,
Hugo
10 January 2017 at 17:01 #8319luibass92BlockedHi Hugo,
yes the collision is detected but the problem is that the sphere doesn’t move nor deform, so the finger passes through the sphere as if the interaction doesn’t happen.
I’m pretty sure that alarm and contact distance are correct, I have also tried to change them to different values (higher or lower) but doesn’t change anything.
My collision pipeline and contact manager are the following (in the root node):
<CollisionPipeline verbose="0" draw="0"/> <BruteForceDetection name="N2" /> <NewProximityIntersection name="Proximity" alarmDistance="0.5" contactDistance="0.3" /> <CollisionResponse name="Response" response="default" /> <CollisionGroup name="Group" /> <LCPConstraintSolver tolerance="0.001" maxIterations="1000"/>
Then I have in the node of the hand and in the node of the sphere the following solvers:
<EulerImplicit name="cg odesolver" printLog="false" /> <CGLinearSolver iterations="100" name="linear solver" threshold="1e-20" tolerance="1e-20" />
(I have tried also putting these solvers in the root node, but it’s the same).
I don’t know if it’s an issue of time steps / stability, it could be… But I have no idea how to solve this kind of issues.
Thanks for your replies!
Cheers,
Luigi23 January 2017 at 15:39 #8412HugoKeymasterHi Luigi,
How is it doing with your problem? Did you investigate as mentioned the time step and stability of your simulation?
Did you find any further hints?
Did you solve your issue ?Best,
Hugo
27 January 2017 at 11:19 #8446luibass92BlockedHi Hugo,
I’m still in troubles, I would like to try a different
<CollisionResponse />
method.
In my scene I’m using<CollisionResponse name="response" response="default" />
but I think I would have better results if I use<CollisionResponse name="response" response="FrictionContact" />
(I’ve seen this in some default SOFA’s scenes).
Unfortunately when I try this solution my scene crashes as soon as the hand collides with the sphere…
Do you know if it’s normal that FrictionContact makes the scene crash?Cheers,
Luigi8 February 2017 at 14:38 #8523EulalieBlockedHi Luigi,
Try to use this for both palm and fingers:
<TriangleModel group=”1″/> <LineModel group=”1″/> <PointModel group=”1″/>
I think it is required to use the three components together.
For the FrictionContact response, I started from the example MultipleObjectsTwoCubes.scn provided with Sofa. I tried to change the scene to add friction. It looks like there is a problem with the LCPConstraintSolver. Try to use FreeMotionAnimationLoop and GenericConstraintSolver instead. We’ll have a look at the failing component. The friction coef can be changed in the DefaultContactManager, responseParams=”mu=…”. Use also a SparseLDLSolver (instead of the CG) and add a LinearSolverConstraintCorrection. I don’t know if it is the best/simplest solution… But it works 😉
Here’s an example:<?xml version=”1.0″ ?> <!– See http://wiki.sofa-framework.org/wiki/TutorialCollisionCubeObstacle.scn –> <Node name=”root” dt=”0.01″ gravity=”0 -9.81 0″> <!– Basic Components to perform the collision detection –> <VisualStyle displayFlags=”showBehavior showCollisionModels” /> <CollisionPipeline /> <BruteForceDetection /> <FreeMotionAnimationLoop/> <GenericConstraintSolver maxIterations=”1000″ tolerance=”0.001″/> <DefaultContactManager response=”FrictionContact” responseParams=”mu=0.6″/> <MinProximityIntersection alarmDistance=”1″ contactDistance=”0.5″/> <!– Using a deformable cube using collision spheres –> <Node name=”Cube1″> <EulerImplicitSolver name=”EulerImplicit Cube1″ /> <SparseLDLSolver name=”Solver Cube1″ /> <MechanicalObject name=”Particles Cube1″ template=”Vec3d” position=”0 0 1 1 0 1 0 1 1 1 1 1 0 0 2 1 0 2 0 1 2 1 1 2″ translation=”0.5 2 0″ /> <MeshTopology name=”Topology Cube1″ hexas=”0 4 6 2 1 5 7 3″ /> <UniformMass name=”Mass Cube1″ totalmass=”1″ /> <MeshSpringForceField name=”Springs Cube1″ stiffness=”100″ damping=”1″ /> <!– Collision Models –> <SphereModel name=”Spheres For Collision Cube1″ radius=”0.2″ /> <LinearSolverConstraintCorrection/> </Node> <!– Using a deformable cube using collision triangles, lines and points –> <Node name=”Cube2″> <EulerImplicitSolver name=”EulerImplicit Cube2″ /> <SparseLDLSolver name=”Solver Cube2″ /> <MechanicalObject name=”Particles Cube2″ template=”Vec3d” position=”0 0 1 1 0 1 0 1 1 1 1 1 0 0 2 1 0 2 0 1 2 1 1 2″ /> <MeshTopology name=”Topology Cube2″ hexas=”0 4 6 2 1 5 7 3″ /> <UniformMass name=”Mass Cube2″ totalmass=”1″ /> <MeshSpringForceField name=”Springs Cube2″ stiffness=”15″ damping=”1″ /> <!– Collision Models –> <TriangleModel name=”Triangles For Collision” /> <LineModel name=”Lines For Collision” /> <PointModel name=”Points For Collision” /> <LinearSolverConstraintCorrection/> </Node> <Node name=”Floor”> <MeshTopology name=”Topology Floor” filename=”mesh/floor.obj” /> <MechanicalObject name=”Particles Floor” /> <TriangleModel name=”Triangle For Collision Floor” moving=”0″ simulated=”0″ /> </Node> </Node>
14 February 2017 at 15:33 #8574luibass92BlockedHi Eulalie and thanks for your reply!
I’ve already used the three model together (Triangle, Line and Point)…
I’m trying to run the scene that you posted but I get the following errors:
WARNING[Cube1(GNode)]: Object type "SparseLDLSolver" creation Failed WARNING[Cube2(GNode)]: Object type "SparseLDLSolver" creation Failed LOAD ERROR: Node initialization failed. WARNING[Cube1(GNode)]: ERROR: requires a LinearSolver. WARNING[Cube1(GNode)]: ERROR: requires a LinearSolver. WARNING[Cube1(GNode)]: ERROR: requires a LinearSolver. WARNING[Cube1(GNode)]: ERROR: requires a LinearSolver. WARNING[Cube2(GNode)]: ERROR: requires a LinearSolver. WARNING[Cube2(GNode)]: ERROR: requires a LinearSolver. WARNING[Cube2(GNode)]: ERROR: requires a LinearSolver. WARNING[Cube2(GNode)]: ERROR: requires a LinearSolver.
I don’t know why but it fails to create the “SparseLDLSolver” 🙁 .
Cheers,
Luigi14 February 2017 at 16:01 #8576EulalieBlockedHi,
Sorry I forgot that the SparseLDLSolver isn’t built by default. You need to enable the SOFA_BUILD_METIS option from the Cmake GUI to use it.
Use the SparseLUSolver instead.14 February 2017 at 16:05 #8577luibass92BlockedI still get the errors:
WARNING[Cube1(GNode)]: Object type "SparseLUSolver" creation Failed WARNING[Cube2(GNode)]: Object type "SparseLUSolver" creation Failed LOAD ERROR: Node initialization failed. WARNING[Cube1(GNode)]: ERROR: requires a LinearSolver. WARNING[Cube1(GNode)]: ERROR: requires a LinearSolver. WARNING[Cube1(GNode)]: ERROR: requires a LinearSolver. WARNING[Cube1(GNode)]: ERROR: requires a LinearSolver. WARNING[Cube2(GNode)]: ERROR: requires a LinearSolver. WARNING[Cube2(GNode)]: ERROR: requires a LinearSolver. WARNING[Cube2(GNode)]: ERROR: requires a LinearSolver. WARNING[Cube2(GNode)]: ERROR: requires a LinearSolver.
14 February 2017 at 16:18 #8578luibass92BlockedAdding the SOFA_LIB_COMPONENT_SPARSE_SOLVER in the configurations it doesn’t crash anymore, but I don’t visualize anything in the scene…
14 February 2017 at 17:40 #8581HugoKeymasterHey Luigi,
Do you have any OglModel in your scene ?
If not then, it’s normal that no visual model appears.
Did you activate the Collision>Collision Models in the SOFA gui ?Best,
Hugo
15 February 2017 at 13:03 #8587luibass92BlockedHey Hugo,
No, I don’t have any OglModel in the scene, but as you said I should see at least the collision models (yes, I’ve activated the Collision>Collision Models in the SOFA gui).
Cheers,
Luigi15 February 2017 at 15:53 #8588HugoKeymasterHi Luigi,
Then, it can be due to the fact no BoundingBox is computed in the scene.
Two solutions:- set the option showObject=”1″ in any of your MechanicalObject(s)
- or simply create an OglModel allowing for visualization of your object: it will compute the Bbox and should solve the problem
Let us know if it solves your issue.
Best,Hugo
21 February 2017 at 12:13 #8648luibass92BlockedHey Hugo,
with your tip
showObject="1"
it works fine, thanks!
In next days I will try to modify my scene with these components and I will let you know what happens.Cheers,
Luigi21 February 2017 at 13:50 #8651HugoKeymasterOk nice to hear!
I mark this topic as solved. Do not hesitate to ask/answer further threads on the forum.
Best regards,Hugo
21 February 2017 at 19:59 #8662luibass92BlockedActually my original question was different, so this topic is not solved… Your tip helped me to soolve a sub-issue of my problem 🙂
Best,
Luigi22 February 2017 at 08:52 #8665HugoKeymasterOk keep us updated about your issues, so that we can help.
Cheers,Hugo
14 March 2017 at 11:26 #8778luibass92BlockedHi everyone,
In these days I’ve been a visitor at INRIA Lille!!
It has been a really great experience and the guys there, in particular Christian and Eulalie, helped me a lot with my project.The problem of the wrong collision detection was due to the fact that I’m using a global approach instead of a local one.
So the solution, as Eulalie suggested is to use the following classes in the root node:<FreeMotionAnimationLoop /> <CollisionPipeline draw ="0" verbose ="0"/> <BruteForceDetection name ="N2"/> <LocalMinDistance name ="Proximity" contactDistance ="0.05" alarmDistance ="0.5"/> <CollisionResponse name ="Response" response ="FrictionContact"/> <CollisionGroup name ="Group"/> <LCPConstraintSolver maxIt ="1000" tolerance ="0.000001"/> <!-- Note that you will need the SOFA_BUILD_METIS option in the configuration for using these sparse solvers -->
And then, when the articulation node is opened:
<Node name =" articulationHand "> <EulerImplicit name ="cg odesolver" printLog ="false"/> <CGLinearSolver name ="linear solver" tolerance ="1e -20" threshold ="1e -20" iterations="10"/> <MechanicalObject name ="Articulations" position ="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.2617 0 0 0 0" template ="Vec1d"/> <RestShapeSpringsForceField points ="0 1 2 3 4 5" stiffness ="100000000000"/> <RestShapeSpringsForceField stiffness ="100000"/> <UncoupledConstraintCorrection compliance ="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"/>
In this way everything goes fine and the collision is done correctly!
Cheers and thanks a lot everyone for helping me!
I’ll finally mark this topic as solved 🙂Luigi
16 March 2017 at 18:07 #8789HugoKeymasterHi Luigi,
Yeah people in Lille are awesome!
Thank you very much for sharing your solution with us !Best wishes, and do not hesitate to share your future results !
Your assistance on the forum is also more than welcome.Cheers,
Hugo
-
AuthorPosts
- You must be logged in to reply to this topic.