Grabbing an object (simulating pliers)

lvezzaro
Posts: 10
Joined: Tue Jun 07, 2011 10:25 am

Grabbing an object (simulating pliers)

Post by lvezzaro »

I'll try to work on a demo to see how this should be done, but I was wondering: has anyone managed to simulate a plier-like system, using bullet constraints to implement opening-closing?
In my current implementation the object slips by, no matter how much friction I set for the plier and the object. What am I doing wrong?
I don't really know how to get this to work without adding ad-hoc constraints between the plier and the object each time the object is grabbed, or using custom contact callbacks. And even in that case, I have no clue how to do that to get a realistic behavior...
Any help will be appreciated, thanks.
jbiggs
Posts: 3
Joined: Mon Sep 14, 2009 6:12 pm

Re: Grabbing an object (simulating pliers)

Post by jbiggs »

I recommend ensuring that your solver mode includes SOLVER_USE_2_FRICTION_DIRECTIONS

// for example:

discreteWorld->getSolverInfo().m_solverMode |=
SOLVER_SIMD |
SOLVER_USE_WARMSTARTING |
SOLVER_CACHE_FRIENDLY |
SOLVER_RANDMIZE_ORDER |
SOLVER_USE_2_FRICTION_DIRECTIONS;


jeff
lvezzaro
Posts: 10
Joined: Tue Jun 07, 2011 10:25 am

Re: Grabbing an object (simulating pliers)

Post by lvezzaro »

Thanks, that helped!
Can you please also explain what SOLVER_USE_2_FRICTION_DIRECTIONS does exactly? I'd like to know why I'm using it, and not just "because it works"! :wink:

Anyway, I've written a small demo (attached) using constraints and motors to simulate some kind of mechanic plier, but tuning the various parameters was tricky, especially the max motor impulses (a ton of friction was needed to get the desired result, too).
I also had some problems getting a smooth movement from the motors, especially the sliding one.
So as a result, I can't get the nice results I was having yesterday, but the grabbing is still quite decent right now.

Still, it isn't over. When I try to plug in realistic masses everything becomes quite unstable, because the max impulses need to be way higher.
Do you think it could be possible to get the same results using higher masses and/or a downscaled world (using centimeters as units)? (which is in fact what I really need)
You do not have the required permissions to view the files attached to this post.
lvezzaro
Posts: 10
Joined: Tue Jun 07, 2011 10:25 am

Re: Grabbing an object (simulating pliers)

Post by lvezzaro »

Well, after spending a good amount of time I was able to tune the parameters adequately. SOLVER_USE_2_FRICTION_DIRECTIONS really changes the way friction works, it's much better now :) .

What I'd like to do now is to be able to have only the inner part of the plier to have high friction, to avoid unrealistic behavior when interating with objects that are not being grabbed. To see what I mean, try opening the plier while it's in the initial position, standing on the ground.
It won't open because the friction is too high for the motors to move the arms.
(I have attached an improved version of the demo).

I've thought about the possible approaches, and I found at least 4 of them:
  • Do a brute-force check of contact points in a tick callback and change the btManifoldPoint::m_combinedFriction appropriately.
  • Similarly to the above, but use gContactAddedCallback to avoid processing contacts that aren't relevant.
  • Use two ghost objects, one per plier arm, to detect when something is being grabbed and change the btManifoldPoint::m_combinedFriction as above. These ghost object will more or less represent the saw-like area in a typical plier.
  • Use a multi-material mesh.
The latter seems to be the best approach, but it'll require a bit of changes in my code, as I'm using simple shapes at the moment for collision detection (and it's not a bad idea for a performance standpoint, I guess).

What approach do you think will work better? Are there other alternatives?
You do not have the required permissions to view the files attached to this post.