I need to be able to control how much bounce is produced by a constraint when it reaches its limit. I have used other physics libraries like cm-labs Vortex, and they allow you to specify stiffness, damping, and restitution for each limit. I looked in the code for the various constraints and found some params that looked like they might allow me to control this. For instance, In the slider joint it has softness, damping, and restitution. I setup a test simulation that has a slider joint that allows a box part to fall straight down and hit the limit. I wanted to try and control the bounce in that part so it would hit the limit and bounce up a couple of times before coming to rest. Damping appears to be at 0 by default, and restitution is 0.7. I played around with both restitution and damping, but it did not seem to make any real differences to my simulation. It still had the same bounce regardless of what I set these values to use. Can someone explain a little more about these params and what I need to do to be able to control the reaction of a body as it hits my constraint limit? Are these the correct params to be using? Would I use the same method for the other constraints like a hinge? There is no documentation on this that I can see. Is there some out there and I have just missed it?
Thanks for you help,
David
Controlling constraint limit bounce
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Controlling constraint limit bounce
There is no way to control the 'bounce' / restitution for a joint limit at the moment, and that should be fixed.
I create an issue for it here:https://code.google.com/p/bullet/issues/detail?id=759
Can you explain what the 'damping' and 'stiffness' of a joint limit needs to be?
Another issue is that there is no proper control how to deal with joint limit error: it should be dealt with in a same way as the contact collision error: either through a Baumgarte term (using the 'error reduction parameter') or using 'split impulse'. Split impulse solves 2 separate LCPs, so that the error correction doesn't have any influence on the resulting velocity. At the moment, Bullet uses some 'fudge factor' when a constraint needs error correction, which was taken from the open dynamics engine. Once we have 'split impulse' we don't need that fudge factor anymore.
I create an issue for it here:https://code.google.com/p/bullet/issues/detail?id=759
Can you explain what the 'damping' and 'stiffness' of a joint limit needs to be?
Another issue is that there is no proper control how to deal with joint limit error: it should be dealt with in a same way as the contact collision error: either through a Baumgarte term (using the 'error reduction parameter') or using 'split impulse'. Split impulse solves 2 separate LCPs, so that the error correction doesn't have any influence on the resulting velocity. At the moment, Bullet uses some 'fudge factor' when a constraint needs error correction, which was taken from the open dynamics engine. Once we have 'split impulse' we don't need that fudge factor anymore.
-
- Posts: 14
- Joined: Mon Feb 18, 2013 3:38 pm
Re: Controlling constraint limit bounce
That is disappointing. In vortex all limits are treated as damped springs, so for a slider joint it is as if you have a bar attached to a spring with a stiffness and damping at each end. You can control the behavior of the limit by altering the stiffness and damping settings. This lets you have precise control over how much the parts are going to rebound once they hit the limit. All of their constraint limits are treated this way. Also, they essentially treat the constraint of each axis of a joint in the same way and allow you to control their stiffness and damping as well so you can have a relaxation on the constraint. I assume there is also not currently a method for doing this in Bullet either, correct? That was the next thing i was going to look into.
Thanks for the info. I have subscribed to your other post so I can follow it see if this ever gets fixed.
Thanks for the info. I have subscribed to your other post so I can follow it see if this ever gets fixed.
-
- Posts: 26
- Joined: Thu Oct 04, 2012 1:58 pm
Re: Controlling constraint limit bounce
I believe this is what you're looking for. Take a look at Claude Lacoursiere's thesis if you have the time for a very thorough overview of the physical meaning of the cfm parameter and how it relates to stiffness especially.
-
- Posts: 14
- Joined: Mon Feb 18, 2013 3:38 pm
Re: Controlling constraint limit bounce
That was very helpful. I was able to use the code below to adjust the ERP and CFM params so I could set the springiness of the limit. However, one odd thing I ran into is that when I use those formulas as written it did not produce useful results. When I used h (integration time step) it produced values that were so small that ERP and CFM were close to zero. However, if I made h=1 then I got something that did not exactly match the results I could get from vortex, but that made sense. When I increased the stiffness and decreased the damping I was able to get the body to bounce on the limit several times before settling down. Does anyone have any idea why this is not working when I use time step in the equation? Is it a difference between the way ODE and Bullet work? Or am I misunderstanding what h actually is?
Code: Select all
float fltErp = (fltH*fltKp)/((fltH*fltKp) + fltKd);
float fltCfm = 1/((fltH*fltKp) + fltKd);
m_btPrismatic->setParam(BT_CONSTRAINT_STOP_CFM, fltCfm, -1);
m_btPrismatic->setParam(BT_CONSTRAINT_STOP_ERP, fltErp, -1);
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Controlling constraint limit bounce
CFM and ERP should behave the same in Bullet as in ODE, but unfortunately many constraints don't use those values properly at the moment.
That should (and will) be fixed, as I mentioned in this issue. I just had a look, and the CFM values is always set to 0, obviously wrong: https://code.google.com/p/bullet/source ... er.cpp#738
Do you mind helping out, and (re)create or modify a basic Bullet demo, so we have some test case to implement/fix the cfm/erp feature?
That should (and will) be fixed, as I mentioned in this issue. I just had a look, and the CFM values is always set to 0, obviously wrong: https://code.google.com/p/bullet/source ... er.cpp#738
Do you mind helping out, and (re)create or modify a basic Bullet demo, so we have some test case to implement/fix the cfm/erp feature?
-
- Posts: 14
- Joined: Mon Feb 18, 2013 3:38 pm
Re: Controlling constraint limit bounce
Sure. I will modify one of the existing demo's and get back with you.
-
- Posts: 14
- Joined: Mon Feb 18, 2013 3:38 pm
Re: Controlling constraint limit bounce
I modified the constraintdemo so we could play around with setting these parameters and see the behavior for the slider and hinge joints. When I did my initial tests I was using the btSliderConstraint. However, the constraint demo uses the btGeneric6dofConstraint. When I attempted to modify the cfm and erp params on it then it did not work anymore. It seems like no matter what I set the values to it behaves the exact same way. The btHingeConstraint is the same way. As if it is ignoring the params even though I have set them. Also, even for the btSliderConstraint, I played around with it some more and found some very odd behavior. In my initial tests I had a mass of 5 Kg and I got it to bounce 3 times when it reached the limit. Later though, I adjusted the mass down to 1 Kg and the bouncing went away completely. I upped the mass in small increments and suddenly between 4.5 and 4.7 Kg it went from no bounce to 3 bounces. So something is definitely wonky with this one as well. I have attached the modified version of the constraint demo. I have labeled all of my modifications with comments that have DWC.
You do not have the required permissions to view the files attached to this post.