Sticky on purpose

Slist
Posts: 3
Joined: Thu Sep 18, 2008 9:46 am

Sticky on purpose

Post by Slist »

Hello,
I am working on a project in which I simulate cells in a physical environment. I would like to make them sticky so that other cells (spheres for now) can attach to each other. That could in theory be achieved by joints. What I need now is that, if there is a force is big enough (something pulling the cells apart), they should also detach...

I would be thankful if someone could broadly point me into the right direction. I actually try to use forces but the effect is either to weak or there are explosive effects.

Thanks for any advice or idea
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Sticky on purpose

Post by Erwin Coumans »

You can make objects sticky, by allowing contact resolution to apply negative/attractive impulses.

You could modify the constraint solver, as a proof of concept. Check out resolveSingleCollisionCombinedCacheFriendly around line 238 of btSequentialImpulseConstraintSolver.cpp

Code: Select all

contactConstraint.m_appliedImpulse = btScalar(0.) > sum ? btScalar(0.): sum;
And change the 0. to some negative value as a test.

Hope this helps,
Erwin
mreuvers
Posts: 69
Joined: Sat May 10, 2008 8:39 am

Re: Sticky on purpose

Post by mreuvers »

Hey Slist,

Did you have any luck with that? We're interested in those results as well. Our approach was to simply add a p2p constraint whenever two rigidbodies collide. And remove the p2p constraint if the stress (applied impulse) is too high.

But if this can be handled 'inside' bullet, I'm all for it.
mreuvers
Posts: 69
Joined: Sat May 10, 2008 8:39 am

Re: Sticky on purpose

Post by mreuvers »

Apparently things have changed drastically in the btSequentialImpulseConstraintSolver.cpp. However I'm guessing that the contact constraints are now solved using the resolveSingleConstraintRowLowerLimit method.

In this method we see this code:

Code: Select all

	if (sum < c.m_lowerLimit)
	{
		deltaImpulse = c.m_lowerLimit-c.m_appliedImpulse;
		c.m_appliedImpulse = c.m_lowerLimit;
	}
	else
	{
		c.m_appliedImpulse = sum;
	}
So if I'm not mistaken, we need to change the c.m_lowerLimit from 0 to a negative value. The thing is, when I change that lower limit to a negative value and have two objects that lie on eachother, the result after an explosion seems to be the same. Whereas I would expect that the two objects would fly away together because they're stuck. I.e., it doesn't seem to work.

Erwin, I got some questions for you about this:

First of all, where can the user set this m_lowerLimit? Is it modifyable at all?

Second, where do you set this value? I've searched everywhere but cannot seem to find a line of code that initialized this to 0. Did I overlook it, do you use a memset(0) perhaps, or is it uninitialized?

Perhaps it's an idea to introduce some stickyness parameter in rigidbody (kinda like friction, restitution etc)? That way we can easily make an object 'stick' to the ceiling, without having to go through the trouble of adding/removing/managing p2p constraints etc or worse, hacking into the btSequentialImpulseConstraintSolver.cpp ;-) If you could point me in the right direction, I'd be happy to add it for you.

Cheers
Slist
Posts: 3
Joined: Thu Sep 18, 2008 9:46 am

Re: Sticky on purpose

Post by Slist »

Well, we theorised a solution and are implementing it. I will post how this works. It's a little cumbersome but should work for what we need.
Here an outline of the algorithm:

At every simulation step:

1) Take all pairs of objects so close together that they can be considered "at contact"
2) Apply a force on both these objects so that they attract themselves.
3) Apply a slider joint between those objects. This slider has infinite length.

4) Compute one physics step

5) Delete all joints

The joints are there to have also "angular stickyness". Without them, the objects would be sticky bout would slide on each other freely. The infinite length of the joint is done to allow the physics to detach an object only perpendicularly.

Ok, pardon me if you don't understand. Nevertheless I will inform you as soon as I know this approach works.
mreuvers
Posts: 69
Joined: Sat May 10, 2008 8:39 am

Re: Sticky on purpose

Post by mreuvers »

Slist wrote: At every simulation step:

1) Take all pairs of objects so close together that they can be considered "at contact"
You use the contactmanifolds for this one? I.e., you process all objects that report a collision? Or do you perform some manual distance check?
2) Apply a force on both these objects so that they attract themselves.
Why is this required? I mean they're already at contact right? Also how do you do this exactly?
3) Apply a slider joint between those objects. This slider has infinite length.
Why do you use a slider and not for instance a point-2-point constraint?
4) Compute one physics step
5) Delete all joints
Why are the joints removed each frame? Can't you simply keep them and measure their applied impulse. Once it's over a certain threshold it snaps. keeping them will probably save you a bunch of allocations/deallocations and other overhead each frame.
The joints are there to have also "angular stickyness". Without them, the objects would be sticky bout would slide on each other freely. The infinite length of the joint is done to allow the physics to detach an object only perpendicularly.
Angular stickyness? I assume you use the slider constraint for that. What property do you use to control this? And if you use the p2p constraint, is this still required?
Nevertheless I will inform you as soon as I know this approach works.
Cool ;-)

Well bottom line is, Erwin mentioned a method (using the lowerlimit in the sequentialcontraintsolver) that seems much simpler. However that didn't seem to work. Erwin if you read this, please help ;-)

Thanks Slist!

Cheers,


Martijn
Slist
Posts: 3
Joined: Thu Sep 18, 2008 9:46 am

Re: Sticky on purpose

Post by Slist »

1) Take all pairs of objects so close together that they can be considered "at contact"
Due to project specific issues I compute that outside of bullet. I have a list of all objects and their neighbours. I use that.
2) Apply a force on both these objects so that they attract themselves.
Since I want to simulate a stickyness which allows objects to be removed if they have a force big enough pulling on them, I stick objects together using a force. If another, bigger and opposed force counteracts it, both objects should detach.
3) Apply a slider joint between those objects. This slider has infinite length.
As in point 2 above: I want to simulate "breakable" joints/stickyness. If I would do a point-2-point joint, the objects stuck together could not be pulled apart.

I know this approach is weird but it can be sintethysed as:
-I use forces to model the "breakable" sticking together
-I use the joints to model the fact that there is "friction" that prohibits the two objects to slide on their respective surfaces. The length of the slider is big (or infinite) in order to allow the objects to detach in a simulation step and not force the objects forever at contact.
4) Compute one physics step
5) Delete all joints
As soon as a force is big enough to pull two objects apart (the simulation in step 4 would move them along the slider axis and increasing distance), the joint would have to be deleted. Due to some architectural reasons I do this for all objects, but if you have some smart check, this is not necessary. You could indeed only delete those where the objects are not touching anymore.

Now, I'm not sure what I did wrong but exactly this last step causes me some instability at the moment. Probably it is bad for bullet to keep deleting and reattaching a joint between two objects. In my case they start behaving funnily. Anyways, I'll keep you posted. I am investigating it and HAVE to find a solution soon :)
mreuvers
Posts: 69
Joined: Sat May 10, 2008 8:39 am

Re: Sticky on purpose

Post by mreuvers »

Hi Slist,

Thanks for all your answers. I started a new topic on breakable objects here: http://www.bulletphysics.com/Bullet/php ... f=9&t=2976 It's very related to the problem you're having right now.

Cheers