soft body and kinematic rigid body - penetration issue

gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

soft body and kinematic rigid body - penetration issue

Post by gjaegy »

Hi,

I have spend the past few days trying to solve my issue, but I could not find a solution. Our production deadline is end of December, therefore I need to find a solution before Christmas - in other words I am quite in a rush :?

Basically, what I am trying to achieve is to have a kinematic rigid body (convex decomposition shape) colliding with a soft body patch. The rigid body will move forward, and will stop some time after it has collided with the soft body (let's say the final distance will be about 3x or 4x the aircraft length).

On each side of the patch, there is a static stick (capsule shape), and each vertex on the left and right side of the patch are anchored to their respective stick.

The behavior I want is that the patch should extend until the aircraft stops...

However, what happens is that the soft body doesn't extend enough, and the aircraft pierces into the patch:
soft_hi.gif
I have tried all I could: clusters/no clusters (no cluster seems to behave better), with or without bending constraints generation, increasing all iteration types, stiffness coefficients, etc...

Bellow are the settings that I currently use (I wrapped bullet to abstract it, so variable names are a bit different, but my wrapper has the same properties and the same default values as the Bullet ones):

Code: Select all

	// create physic object
	imPhysicControllerSoftBody* pSoftBodyCtrl = new imPhysicControllerSoftBody(imCOLLISIONGROUP_WORLD, imCOLLISIONGROUP_ENTITIES);
	pSoftBodyCtrl->SetMass(100.0f);
	// mass of 1.0 for each node
	pSoftBodyCtrl->SetNodesMass(arrNodesMass); 
	// this will call btSoftBody::setPose() or not
	pSoftBodyCtrl->GetProperties().m_bPoseMatching = imFALSE;
	// this will call btSoftBody::generateBendingConstraints()
	pSoftBodyCtrl->GetProperties().m_bGenerateBendingConstraints = imTRUE;
	pSoftBodyCtrl->GetProperties().m_iBendingConstraintDistance = 2;		
	// Positions solver iterations
	pSoftBodyCtrl->GetProperties().m_ipiterations = 12;			
	// Cluster solver iterations
	pSoftBodyCtrl->GetProperties().m_iciterations = 12;		
	// Anchors hardness [0,1]
	pSoftBodyCtrl->GetProperties().m_fkAHR = 0.7f;
	pSoftBodyCtrl->GetProperties().m_bRandomizeConstraints = imTRUE;
	// this will call btSoftBody::generateClusters() or not
	pSoftBodyCtrl->GetProperties().m_bGenerateClusters = imFALSE;	
	pSoftBodyCtrl->GetProperties().m_nClusterCount = 0;//64;
	// material used for standard links
	pSoftBodyCtrl->GetProperties().m_fMaterialkLST = 0.4f;
	pSoftBodyCtrl->GetProperties().m_fMaterialkAST = 0.4f;
	// material used for bending constraints generation
	pSoftBodyCtrl->GetProperties().m_fBendingMaterialkLST = 0.4f;
	pSoftBodyCtrl->GetProperties().m_fBendingMaterialkAST = 0.4f;
	// Rigid contacts hardness [0,1]					1.0
	pSoftBodyCtrl->GetProperties().m_fkCHR = 1.0f;		
	// Kinetic contacts hardness [0,1]					0.1
	pSoftBodyCtrl->GetProperties().m_fkKHR = 0.1f;		
	// Soft contacts hardness [0,1]						1.0
	pSoftBodyCtrl->GetProperties().m_fkSHR = 1.0f;		
	// Soft vs rigid hardness [0,1] (cluster only)		0.1
	pSoftBodyCtrl->GetProperties().m_fkSRHR_CL = 0.1f;	
	// Soft vs kinetic hardness [0,1] (cluster only)	1.0
	pSoftBodyCtrl->GetProperties().m_fkSKHR_CL= 1.0f;	
What else could I try ?

Really, this is very important for us, so, any help would be really, really, welcome !!

Thanks,
Greg
You do not have the required permissions to view the files attached to this post.
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: soft body and kinematic rigid body - penetration issue

Post by gjaegy »

By replacing the patch shape by another shape, I get similar issue (notice how the stripes go through the wings):
net.gif
When I generate clusters, the soft body exploses.

Generating bending constaint makes the soft body even stiffer.

Below the settings I use for this mesh.

Code: Select all

	// total mass
	pSoftBodyCtrl->SetMass(0.1f);
	// mass of 1.0 for each node
	pSoftBodyCtrl->SetNodesMass(arrNodesMass); 
	// this will call btSoftBody::setPose() or not
	pSoftBodyCtrl->GetProperties().m_bPoseMatching = imFALSE;
	// this will call btSoftBody::generateBendingConstraints()
	pSoftBodyCtrl->GetProperties().m_bGenerateBendingConstraints = imFALSE;
	pSoftBodyCtrl->GetProperties().m_iBendingConstraintDistance = 2;	
	// Positions solver iterations
	pSoftBodyCtrl->GetProperties().m_ipiterations = 12;		
	// Anchors hardness [0,1]
	pSoftBodyCtrl->GetProperties().m_fkAHR = 0.1f;
	pSoftBodyCtrl->GetProperties().m_bRandomizeConstraints = imTRUE;

	// this will call btSoftBody::generateClusters() or not
	pSoftBodyCtrl->GetProperties().m_bGenerateClusters = imFALSE;	

	// material used for standard links
	pSoftBodyCtrl->GetProperties().m_fMaterialkLST = 0.1f;
	// material used for bending constraints generation
	pSoftBodyCtrl->GetProperties().m_fBendingMaterialkLST = 0.1f;

	// Rigid contacts hardness [0,1]					1.0
	pSoftBodyCtrl->GetProperties().m_fkCHR = 1.0f;		
	// Kinetic contacts hardness [0,1]					0.1
	pSoftBodyCtrl->GetProperties().m_fkKHR = 0.1f;		
	// Soft contacts hardness [0,1]						1.0
	pSoftBodyCtrl->GetProperties().m_fkSHR = 1.0f;	
Really, I need help on this one :(
You do not have the required permissions to view the files attached to this post.
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: soft body and kinematic rigid body - penetration issue

Post by Flix »

Not many hints for you (but since nobody answers... :? )

You may try:
1) tuning all kind of elastic constants at runtime, while the airplane is touching the net by using a sensor to detect their collision (I guess you already made it: probably there's an upper limit to the link elasticity...)
2) As a last resource you an try using a net made of rigid body capsules and changing the length at runtime (http://bulletphysics.org/Bullet/phpBB3/ ... th+of+rope). You don't need a sensor since you can detect which capsule collides with the airplane directly (you can even think of using different shapes per rigid body, so that you can extend only the capsules that are in touch with the airplane, but this is just a refinement).
3) From the above link there's a suggestion of how to change the rest length of a soft body rope (softbody->m_links.m_rl). You can try modifying it at runtime like in point 1.
4) If the airplane excessive speed is a problem, you can try increasing the Bullet timestep.

That's all I can say, since I've not faced this kind of simulation problem and I've got no solution ready to suggest you :oops: .
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: soft body and kinematic rigid body - penetration issue

Post by gjaegy »

Thanks a lot for your answers, Flix, really appreciated !

I am not tuning anything at runtime yet, as I thought there should be a hidden setting I have missed ;) Unfortunately this doesn't seem to be the case, so I will try to investigate on this side !

Using capsules don't look to be a very clean solution to me, I really like the way the soft body reacts, so I will first try to solve my issue using this kind of objects (if even possible) !

I think I will have to dig into the source code a bit further. I noticed the rest length (and m_c1 which is the squared length), however I am still unsure about how to use it. As there are not many comments in the source code, it is quite difficult to find out how the soft body nodes positions are computed.

To me, looking at the video, it appears that there is a force that push the node positions to their original position, or, more precisely, that makes the links tend to their "rest length". This seems to happened even though the rigid body is a kinematic body; to me it seems that the reaction of the collision, that normally should apply to both the rigid body and the soft body that collide together, is not applied to the rigid body (as it is a kinematic object), but still applies to the soft body nodes - this would explain why the stripes go slowly through the wings. Could I be right in my assumption ?

Actually, in the case of a kinematic rigid body, I would expect the kinematic to drag the nodes of the soft body until a certain extent, without the nodes going through the rigid body, would that be something achievable ?

Thanks once again for your inputs, very appreciated.
kickvb
Posts: 6
Joined: Wed Dec 09, 2009 5:05 pm

Re: soft body and kinematic rigid body - penetration issue

Post by kickvb »

The scene you are trying to simulate is rather demanding compared to a classical usage of Bullet. The main problem in my opinion is that your plane seems to move very fast compared to the size of the soft body, a scene like that would need to increase some parameters in order to handle it correctly.

First of all, what does it give if you slow down a lot the speed of the plane, can you achieve some good behavior? If that's the case then you are almost over: you simply need to use a smaller time step for the simulation and that should be OK. Another solution to limit the computations would be to have a dynamic world only for your plane and your net, and to apply a slower time scale or time step only on this world.

After that, the parameters of the soft body can probably be tweaked better. Have you some facility to test & try easily new parameter sets? Have you also digged into the Bullet's soft body code to understand better how it works? A start is the comments in the header files, such as http://bulletphysics.com/Bullet/BulletF ... ource.html

Some interesting parameters for your scene are in btSoftBody::Config:
- piterations can bet set higher, the value of 12 that you use is probably too low for you
- viterations and citerations can be tried too
- timescale is probably interesting to increase since your problem is about the speed of the simulation

Finally, the behavior of the Bullet's objects can often be hacked a bit once you understood how it works exactly. The idea reported by Flix to modify dynamically the length of the ropes should help too.
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: soft body and kinematic rigid body - penetration issue

Post by gjaegy »

Hi kickvb, thanks for your answer as well !

The speed of the aircraft will even be faster in the final product, so this is not something I can get control over :(
I have however tested with a slower movement, and the issue still occurs. So, to me, nothing related to the time step (actually I have already tried with a timestep of 1/1200s before, to check this).

Increasing "piterations" (I tried 120) don't help either :(

From what I understood from the source code, "citerations" is used only in the case clusters are used. In my case, the soft body explodes when I use clusters, after the aircraft has collided a few meters, no idea why (maybe someone has a clue here ?), so I guess this is useless.

I am not sure "viterations" is used either, looking/debugging through the source code.

However, I didn't notice the "timescale", any idea what role does it play ?
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: soft body and kinematic rigid body - penetration issue

Post by gjaegy »

I have spend the last days implementing an adaptive links rest length algorithm.
What I did is:
- detect which soft body nodes are in contacts with the aircraft (using "m_rcontacts")
- according to this, define which "bands" of the net are colliding
- for each colliding band:
- compute the current length of the band
- divide this band length by the number of link (vertical) of this band
- set this value as the rest length of the vertical links for this band
- for each not-colliding band, set the original link rest length
- for each link, update m_c1 (which is the square of the rest length)

This is what I now get:
rest_length6.gif
or a better DivX3 video:http://www.imagine3d.fr/tmp/net.avi

As you can see, this didn't improve the situation at all.

Now, my current theory is that the bands going through the kinematic object could eventually due to the fact that some contacts are missed - this would explain why the bands suddenly go through the wings, by step (remember the aircraft is using a convex decomposition collision shape, therefore the wing is composed by several shape, hence the "steps" behaviour).
I know clusters should normally help if my assumption is right, however, as I said before, using clusters leads to the net "exploding" once the collision has occurred (no link rest length modification at runtime is used):
clusters.gif
So, now I am completely lost, and honestly I am not sure I can achieve this using Bullet :(

Please HELP :cry:

[EDIT] actually this also happens when using a cylindrical shape instead of the aircraft convex decomposition shape.
You do not have the required permissions to view the files attached to this post.
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: soft body and kinematic rigid body - penetration issue

Post by gjaegy »

up...
skeen
Posts: 24
Joined: Wed Dec 08, 2010 11:59 am

Re: soft body and kinematic rigid body - penetration issue

Post by skeen »

Can you get this working using any shape at all? - have you tried using like a simple square or whatever? - Once my physics seems to fail, I like to get it to work with the simplest of objects, and then move up.

I really would love to help, however I havn't used softbodies at all, if your project is opensource. I would love to have a peak at it, at least for my own learning.
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: soft body and kinematic rigid body - penetration issue

Post by gjaegy »

Thanks for your answer.
As I wrote in my last post (edit) I have tried to replace the aircraft convex decomp. shape by a capsule, unfortunately this didn't help...
I guess this is what you suggested, right ?
[EDIT]: unfortunately our product is a commercial product, so I can't release the whole source code :(
skeen
Posts: 24
Joined: Wed Dec 08, 2010 11:59 am

Re: soft body and kinematic rigid body - penetration issue

Post by skeen »

gjaegy wrote: Thanks for your answer.
As I wrote in my last post (edit) I have tried to replace the aircraft convex decomp. shape by a capsule, unfortunately this didn't help...
I guess this is what you suggested, right ?
[EDIT]: unfortunately our product is a commercial product, so I can't release the whole source code :(
Well thats okay, you guys have to earn money ^.^

Really I was just thinking, that it would be easier for you to debug it using some simple shape instead of using your airplane shape. - And once you get it working with a simple shape, then start getting it to work with the advanced one.

- I'm currently implementing bullet physics to our gameengine, here at Aarhus University, and really the approach I'm using is implementing basics first, that is boxes colliding, once thats up, you can move on to spheres, ect., and eventually trimeshes.
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: soft body and kinematic rigid body - penetration issue

Post by gjaegy »

We have been using Bullet for more than a year, and everything has worked fine until today ;)

Now, I guess I would need some help from someone having a deep knowledge on how the soft body solvers works, as I have tried to dig into the source code, but couldn't find out why the net bands always pass through my kinematic rigid body - whatever the rigid body shape is..

Does anybody have an idea, what could happen ? Is it due to the net being anchored to the sticks ?

I have two theories:
- either some contacts are missed, explaining why the bands pass through the rigid body after a while
- or there is a force that applies to the bands, that pushes them back to their original position. This force could either be due to the "link" rest length (but I don't think this is it, as I tried to dynamically adjust the rest length), to the anchors (which I can't really get rid of, otherwise the jet falls on the ground), or something else (no idea why).

Does anybody have a deep-enough knowledge of the btSoftBody class, and could explain my what exactly happens ?
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: soft body and kinematic rigid body - penetration issue

Post by gjaegy »

up :(
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: soft body and kinematic rigid body - penetration issue

Post by gjaegy »

I have found out that increasing the margin for both shape slightly delays the time where the bands pass through, but it doesn't actually solve the issue.

One thing that works: adding an anchor to each soft body node, as soon as it collides with the aircraft (so, looping through "m_rcontacts" and add an anchor to each node in that list, if they are not anchored yet).

However this is really what I would call a *hack*, therefore I would prefer a cleaner solution.

Erwin or Nathanael ? Any hint ?
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: soft body and kinematic rigid body - penetration issue

Post by gjaegy »

really need support, please !