Slider properties

tomhhh
Posts: 17
Joined: Tue Jan 19, 2016 10:44 pm

Slider properties

Post by tomhhh »

Hi there,

I am trying to configure a slider constraint to be completely rigid (limit movement to only the slider axis) but cannot seem to find the right configuration of properties.

At the moment the upper and lower limit are working correctly but one of the rigid bodies (the one that is not static) still wobbles about on the axis. I have tried a number of combinations of values for the Restitution, Softness, Damping and Constraint CFM properties but still haven't had much luck. I would be very grateful if someone could explain the expected range for these functions and what values to use to get a completely rigid slider.

Thank you very much for your time!


Tom
amatic
Posts: 13
Joined: Sun Oct 25, 2015 10:17 am

Re: Slider properties

Post by amatic »

Do you need to restrict rotation of the bodies?
Or is it just wobbly?
tomhhh
Posts: 17
Joined: Tue Jan 19, 2016 10:44 pm

Re: Slider properties

Post by tomhhh »

Hi!

I do not need to restrict the rotation of the bodies, I just want to eliminate all wobble from the axis.

In the docs where an image is presented for the slider constraint, I basically want to replicate the behaviour you would expect from that joint. I would like only movement in that axis. At the moment there is a certain amount of wobble/springiness which I'm not sure how to remove. I assume it is possible with a certain combination of values from Restitution, Softness, Damping and Constraint CFM.

Thank you for your help!


Tom
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Slider properties

Post by Flix »

It might be the usual problem with mass differences: try to increase the local inertia of the two bodies (or of the dynamic one if one is static) of a factor of 100 -> 10000 or so and see if something changes.

Another approach would be to increase the number of step of the constraint (or the number of step of the whole application) and see.
tomhhh
Posts: 17
Joined: Tue Jan 19, 2016 10:44 pm

Re: Slider properties

Post by tomhhh »

Hi Flix,

Ah I did read something about that (the mass difference problem) and it had crossed my mind that this could be something to do with it.

So are you saying I need to modify the rigid body not the constraint? Should I call setInvInertiaDiagLocal(...) on the dynamic rigid body? How exactly implementation wise would I achieve what you suggest? I apologise I am quite new to Bullet.

Thanks!
tomhhh
Posts: 17
Joined: Tue Jan 19, 2016 10:44 pm

Re: Slider properties

Post by tomhhh »

So in looking into this it does seem like it is exactly the problem with the mass difference issue.

If I make both rigid bodies dynamic, the joint works as expected, however if one is static (infinite mass) and the other is dynamic, I get the weird springiness/wobble.

Could someone please tell me if their is a solved solution to this? Even if it's a total hack or whatever :)

Thanks!


Tom
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Slider properties

Post by Flix »

Well, I guess it's not a mass-difference problem: it's just that a static object is probably not considered simply as an infinite mass body, but Bullet has some "specialized way" to treat it (actually I'm just guessing: I should see the code to tell it :) ).

For sure the inertia of static bodies is not considered at all (you must set it only for dynamic bodies).

So in short: if it works just by swapping the static body with a big-mass dynamic body , then just keep it this way and be happy :D .

If you needed to change the mass (or inertia) of the other body too, than that could be really a mass-difference issue.
tomhhh
Posts: 17
Joined: Tue Jan 19, 2016 10:44 pm

Re: Slider properties

Post by tomhhh »

Hi again,

Okay sorry so I'm a little confused. Is there specifically a state you can set to cause the object to be static? I think we are just setting an infinite mass, so does the object still count as dynamic even though it is an infinite mass, or is it now implicitly static?

Having one object as seemingly static (infinite mass) and another as dynamic causes this wobble/springiness effect, if both are dynamic (same mass) then I get the behaviour I want, but then they are both free in the world which I don't want. I want one to be fixed/anchored to the world.

Is there some example code you could share or a link to something that already exists?

I found this question from someone having a similar problem with hinges - http://www.bulletphysics.org/Bullet/php ... f=9&t=9673

But I'm not 100% sure if this applies in my case.

Thanks again!


Tom
Xammond
Posts: 15
Joined: Sun Jan 03, 2016 4:22 pm

Re: Slider properties

Post by Xammond »

Hi, I'm attaching vehicle chassis rigids to a single static rigid (for parking anchors), with a prismatic constraint constructed from a btGeneric6DofSpringConstraint.
Linear limits (setLinearLowerLimit...) for the slide are set on the Y axis, to allow for gradients/cambers of the road.
The constraint's axis' are set as (1,0,0), (0,1,0).
All equilibrium points [index 0,1,2] = 0.0
enableSpring is true for indices 0 and 3, false for 1.
stiffness = 2500, damping = 0.01 (these aren't tweaked)
The angular limits axis are not as expected, X seems to be Z, so X prevents roll (lean), z prevents wheelies! For my anchors only Z is set to 0 [this stopped it from acting like a wild animal when anchored and accelerating!].
Hope that helps, there was a time where the above joint was not solid and more like a sponge, now it is perfect.
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Slider properties

Post by Flix »

tomhhh wrote:Okay sorry so I'm a little confused. Is there specifically a state you can set to cause the object to be static? I think we are just setting an infinite mass, so does the object still count as dynamic even though it is an infinite mass, or is it now implicitly static?
In Bullet rigid bodies can be set to be static, kinematic or dynamic when you create them and add them to the world. Every basic Bullet demo can show you this.
Internally static and kinematic bodies are kept in a different list AFAIK.
tomhhh wrote:Is there some example code you could share or a link to something that already exists?
I remember there's one demo specifically made for slider constraints (outside the constraint demo). You might find it useful. I don't know if it is available in the Bullet Github repository, but for sure you can find it in old Bullet releases (2.82 or so).
tomhhh wrote:I found this question from someone having a similar problem with hinges - viewtopic.php?f=9&t=9673
That link is an old post. I used the slider constraint as a hinge (it can be used as a hinge too :)), and solved the problem by increasing the inertia tensor. I think my source code was included in that link.
tomhhh wrote:Having one object as seemingly static (infinite mass) and another as dynamic causes this wobble/springiness effect, if both are dynamic (same mass) then I get the behaviour I want, but then they are both free in the world which I don't want. I want one to be fixed/anchored to the world.
Then try to use one static body and increase the inertia (and/or) the mass of the dynamic one. But I guess that if the two bodies are free, then you don't have mass-ratio problems simply because gravity has nearly zero impact on the bodies!
Another approach is to use two dynamic bodies and to constraint one of them to a static dummy rigid body and see if it works.
tomhhh
Posts: 17
Joined: Tue Jan 19, 2016 10:44 pm

Re: Slider properties

Post by tomhhh »

Hi Flix

Thank you very much for getting back to me and for all your answers, I really appreciate it!

One more stupid question is is it possible to switch a body from dynamic to static? Or do you need to destroy and recreate it?

I'll definitely try and have a look for that slider example you mention!

Also when you say increase the inertia tensor, what function are you calling exactly? And is that on the rigid body or the constraint?

Thanks again and thank you Xammond for the information you presented too, it was helpful.

I really appreciate you all taking the time and sharing your knowledge!

All the best!


Tom
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Slider properties

Post by Flix »

tomhhh wrote:One more stupid question is is it possible to switch a body from dynamic to static? Or do you need to destroy and recreate it?
It's probably better to remove it from the world and reinsert it after modifying all the required flags. I don't remember exactly how to do it, however it should be possible (probably if you start from a dynamic body).
tomhhh wrote:Also when you say increase the inertia tensor, what function are you calling exactly? And is that on the rigid body or the constraint?
Normally you calculate the local inertia form the collision shape and the mass, and then you apply it to the body. You can just multiply it by some factor before applying it.
In Bullet the constraint has no local inertia: you can improve the stability of the constraint by increasing the mass or the local inertia of the bodies (I prefer the local inertia, because it affects gravity only in the rotation part).
Xammond
Posts: 15
Joined: Sun Jan 03, 2016 4:22 pm

Re: Slider properties

Post by Xammond »

Had a strange experience earlier where the constraints were like a sponge again.

It took a while to understand how, and I'm still investigating, but deduced that the vehicles were being spawned at a higher location (110m instead of 10m) which somehow made the constraints loose...that 0.01 constraint damping sure showed up as useless once the joint was loose.

I wonder if this is a bug, but unlikely as games spawn joints all over the place, and we would've noticed before. Must be my end it just seems weird because the joint goes slack just by placing both rigids 100m higher before joint creation.

Also, I've tried using reference frame B instead of A, and setting either/both origins to anything/nothing doesn't seem to help?


EDIT: Changed solver to btDantzigSolver and all is perfect again :)
tomhhh
Posts: 17
Joined: Tue Jan 19, 2016 10:44 pm

Re: Slider properties

Post by tomhhh »

Thank you again Flix for your answers, I'll have a look into what you suggest.

Thank you too Xammond, I am actually curious how/where you change the solver? Would you be able to tell me where that is specified?

Thanks again! Really appreciate all your help!

Cheers!


Tom
Xammond
Posts: 15
Joined: Sun Jan 03, 2016 4:22 pm

Re: Slider properties

Post by Xammond »

Oh, well this should solve :lol: things for you.
If you browse the constraint demos (at least) one of them has optional MLCP solvers (all references remarked out by default). A quick search online revealed that the forklift demo also references some of them. Selecting a desired solver is normally at runtime.
Post Reply