7 February 2017 at 08:02 #8511jlefleyBlocked
We’re interested in modeling interactions between soft tissue and rigid bones in a human model. We found the anatomy modeling tutorial in the source code and made some changes to get it to compile and then ported it to Python for more rapid development.
We enhanced the anatomy modeling example by making the bones act as collidable bodies (using TTriangleModel), which seems to work as expected. We want to have the muscle, which is currently a deformable body through the flexible plugin, interact with the bones. We used the same TTriangeModel in conjunction with a LinearMapping to attempt to make the colliding bones deform the muscle model. After making these changes, we do not see collisions occurring between the muscle and bones.
Can anyone point us to an example scene that demonstrates how to have a collision between a flexible body and a rigid body so that the rigid body deforms the flexible body as it collides? We looked at the compliant plugin and it seems it may provide an avenue for modeling and solving this scenario but I haven’t found any examples that demonstrate clearly how to use it in this fashion. Perhaps someone could describe at a conceptual level how this would work in SOFA? We are not really sure what components to use or how to structure the scene graph.
We can post our Python code if it would be useful. As mentioned, we ported anatomyModelling.cpp to Python and then added the collision detection.
Thanks9 February 2017 at 10:56 #8533
Indeed, it would help if you could provide us your scene (xml+python).
Maybe both muscle and bone do not collide because they belong to the same collision group.
Hugo10 February 2017 at 15:59 #8561maxBlocked
As Hugo said, having your scene file would help but here are some general considerations.
For collisions to happen you need to:
1. setup the collision pipeline
2. have collision models on the objects you want to collide, e.g. for meshes, add a TriangleModel next to the topology describing your mesh
3. use a numerical solver that can handle contacts, depending on the contact response chosen in 1.
For 1, you need to add:
– DefaultPipeline, that tells the animation loop to enable collision detection,
– BruteForceDetection, that setup a naive O(n2) collision detection pass between collision models,
– NewProximityIntersection that computes the intersections, distances and contact points based on member data alarmDistance and contactDistance
– DefaultContactManager, which is responsible for creating the response graph sections in case of a collision (mapping a point from its parent dofs, putting forcefields/constraints, etc). The contact manager has a ‘response’ attribute describing which response class to use, and a ‘responseParams’ string that sets attributes for the response class (yes I know this is complicated!)
Some of the examples in the core SOFA repository have penalty force constraints, but the general idea should be the same. The default SOFA scene (the snake) is a deformable object with frictional contacts IIRC, so my advice is to study this scene to see how things are setup.
Best,15 February 2017 at 18:16 #8589jlefleyBlocked
Thanks for the tips. We are not exactly sure what defines a collision group. Perhaps you could provide a brief explanation?
I think we have the collision system set up as Max described however we use MinProximityIntersection currently. How does that differ from NewProximityIntersection?
Here’s our python code: https://gist.github.com/jlefley/92b32c8a7a156f5e1ea07bdb01c6cf62 We started by reworking the rigid body skeleton from anatomyModelling.cpp slightly to gain a better understanding of how to assemble components in sofa. The end result seems to be the same as the skeleton in the original C++ code. We then brought in the muscle code from the C++ code, pretty much by directly translating it to the corresponding python. We did need to make some slight modifications to accommodate the python API. We left in some comments from the porting process. Everything seems to work correctly up to this point.
We added collision nodes for all the rigid bodies, which seem to provide the expected results for the most part. Occasionally the bones intersect one another. I imagine there are ways to tune the collision pipeline for improvement?
The deformable muscle appears as a collidable object (it is highlighted when collision model visualization is enabled in runSofa) but it does not seem to collide as expected with the bones.
We are also curious about the compliant plugin and if it is applicable to this situation. We looked through many examples but haven’t found anything that demonstrates what we want to accomplish: a flexible object colliding with a rigid object.15 February 2017 at 21:49 #8590octotodBlocked
Jason and I have been working together on this model. An update: adding a DefaultContactManager (with response=’distanceLMConstraint’) and a DefaultCollisionGroupManager on the root node, and then EulerImplicit / CGLinearSolver / LMConstraintSolver solvers on the muscle node, seems to have helped. The muscle does still interpenetrate the bones, but I think it is colliding some of the time.
1) What do we need to tune to get better collision detection?
2) What does the DefaultCollisionGroupManager do, and do we need to tell it which objects should be colliding?16 February 2017 at 09:22 #8592
Dear Jason and octotod,
The difference between the intersection methods is given in the documentation here.
When collision is working, but interpenetration persists:
- you can check the time step of your simulation, it could be due to a fast collision not detected due to a too-large time step,
- you can tune the proximity alarm distance and contact distance (increase it a bit),
- refine and smooth your mesh used for collision
About the DefaultCollisionGroupManager, I am no expert but from the code it looks responsible for gathering colliding objects in the same group, for consistent time integration.
Hope this helps. Best regards,
Hugo20 February 2017 at 15:06 #8639
Did my reply help you? I did not receive feedback about it.
Hugo18 March 2017 at 08:20 #8804octotodBlocked
Hi Hugo, thank you for your response(s)! I tried the following, but am still not getting collisions:
– reducing the vertex count of the collision meshes
– reducing the time step
– increasing the contact/alarm distance
My gut feeling is the AnatomyModelling example application is written for an older style of SOFA programming. I’m now trying to build up a less complex scene with the features I need.7 April 2017 at 11:35 #8891
Any good news on your side ?
- You must be logged in to reply to this topic.