Odd behaviors with Friction and Restitution

Post Reply
Mako_energy02
Posts: 171
Joined: Sun Jan 17, 2010 4:47 am

Odd behaviors with Friction and Restitution

Post by Mako_energy02 »

I'm having two completely separate minor problems, one with friction, and one with restitution, that I could work around, but I'd rather understand bullet more deeply and get my simulation setup just right, so I hope some other people out there that have used friction and restitution can enlighten me.

My issue with friction:
I have a box rigid body on top of a sloped bvhTriangleMeshShape, which increases it's slope in increments(20 units of the slope is ~6 degree grade, next 20 units is ~14 degree, etc.). The friction on the box is set to 0.8, and the friction on the terrain is 1.0. When I throw the box to the top of the slope, I'd expect it to come to a rest at the top of the slope, but instead it jitters, a lot. It also gradually shakes it's way down the slope, sometimes coming to a rest briefly before jittering again. My goal is to eliminate sliding without having to set a preposterous friction setting, and to eliminate the jitter. Are there any other parameters I can set to help how friction is handled in my simulation?

My issue with restitution:
In another simulation I have a ball that I through at another bvhTriangleMeshShape downward and to the right(camera perspective). I have restitution value set to 0.8 on the ball(imagining a rubber ball) and the terrain's restitution value set to 1.0(imagining something excessively bouncy). When the ball is thrown at the terrain at a ~45 degree angle down and to the right I expect it to bounce back up to ~90+/-5% of the height it started but to keep moving to the right. Instead, more often then not, it will bounce back in the direction it came from. Rarely depending on the rotation of the ball(since I'm throwing with click and drag using a P2P constraint) it will do as I expect, but of the ~40 test throws I've done so far I've accomplished this only once. I do understand the direction after impact can be influenced by rotation, a basketball is a good example when you spin it as you throw it to the ground. But this seems excessive. Like my question with friction, are there any other parameters I can set anywhere to help control how restitution behaves in Bullet? Ideally to tone back this behavior?
Mako_energy02
Posts: 171
Joined: Sun Jan 17, 2010 4:47 am

Re: Odd behaviors with Friction and Restitution

Post by Mako_energy02 »

A little bit more information about my restitution issue, I forget to mention that I am using a btSphereShape for my ball, and I have it's friction set to 0.1. The spin on the ball should be a factor, but not enough for it to bounce back in the exact direction it came from. I've also started using different search terms when looking for more information on this issue, and found a few posts with similar/identical issues as mine:

http://bulletphysics.org/Bullet/phpBB3/ ... f=9&t=7248
http://bulletphysics.org/Bullet/phpBB3/ ... f=4&t=6202
http://bulletphysics.org/Bullet/phpBB3/ ... f=9&t=3811

After reading that last one, I too tried to enable split impulse and it didn't make any difference at all. I'm still getting quite unrealistic bounces.
Mako_energy02
Posts: 171
Joined: Sun Jan 17, 2010 4:47 am

Re: Odd behaviors with Friction and Restitution

Post by Mako_energy02 »

Another small update. I tried enabling CCD, figuring the normals for the collision may be more accurate that way. I followed all the code that was used in the CCD demo and not only did it not change anything, but it seems my objects still tend to tunnel through the terrain if I throw fast enough. So maybe that isn't conclusive as CCD may not be working.

Things I copied from the Demo:
Set iterations on the solver to 20.
Enabled split impulse on the solver.
Enabled continuous on the dispatcher.
Set the motion threshold and swept sphere radius on the body appropriately.

I may need to start splitting this into multiple threads... =\
shomy2k11
Posts: 24
Joined: Thu Sep 08, 2011 1:59 am

Re: Odd behaviors with Friction and Restitution

Post by shomy2k11 »

Hi,
saw your post and i too am having a similar problem. I get my ball sticking on walls and not rebounding as it should.
I also want to introduce softbodies into my game but just by including "#include "btSoftBody.h" i get errors such as
"error: expected identifier before numeric constant ..line 94". I'm using codeblocks under linux 32-bit as my platform.

Any help would be greatly appreciated

here is my game so far http://www.bulletphysics.org/Bullet/php ... =17&t=7416
Mako_energy02
Posts: 171
Joined: Sun Jan 17, 2010 4:47 am

Re: Odd behaviors with Friction and Restitution

Post by Mako_energy02 »

I managed to resolve the balls getting stuck to the wall by reducing the swept sphere radius I was setting for my objects when enabling CCD. I don't know if you are enabling CCD or not, if not then my fix isn't applicable to you. If you are using CCD, then you probably just need to do as I did. I originally assumed I just needed an sphere that would barely fully embed inside my collision shape, but it turns out you need to take that radius and then multiply it by 0.2. Then you'll get working CCD.

Not sure if you are having any of the other same issues I was having, but I also managed to solve my restitution issue by switching from a bvhTriangleMeshShape to a compound shape of box's. Seems bvhTriangleMeshShapes don't interact well with restitution. My friction issue however, still remains.
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York
Contact:

Re: Odd behaviors with Friction and Restitution

Post by sparkprime »

I found CCD sphere sweeping to be very unreliable when I tried it a few years ago and no-longer use it
Mako_energy02
Posts: 171
Joined: Sun Jan 17, 2010 4:47 am

Re: Odd behaviors with Friction and Restitution

Post by Mako_energy02 »

I'm noticing the same thing in my simulations. Occasionally objects will tunnel despite it, even at lower speeds where you wouldn't expect it. But overall I'm getting a little less tunneling and since my simulations are based on mouse thrown objects, it's pretty easy to get fast moving objects if the user felt like it. So I need to minimize tunneling as much as I can.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Odd behaviors with Friction and Restitution

Post by Erwin Coumans »

but it seems my objects still tend to tunnel through the terrain if I throw fast enough. So maybe that isn't conclusive as CCD may not be working.
and
sparkprime wrote:I found CCD sphere sweeping to be very unreliable when I tried it a few years ago and no-longer use it
Try using CCD, and if it is not reliable, help creating a reproduction case in a Bullet demo, so someone can fix it. We need to create more unit tests.
Thanks,
Erwin
Post Reply