Slider Constraint wobbling on second axis - video attached

evandarcy
Posts: 5
Joined: Mon May 27, 2019 10:15 am

Slider Constraint wobbling on second axis - video attached

Post by evandarcy »

Hi, I am building a grabber on a crane type mechanism. My crane has a hinge to pivot and a slider to move the grabber up and down. I am encountering an undesired movement from the slider constraint which is that as I rotate the crane, the slider will "wobble" side to side horizontally.

I have attached a video which demonstrates what I am talking about.

At the moment I am chaining constraints, for example I have a slider constraint attached to a body with a hinge constraint. Perhaps this is not the best way to do things? I have been stuck on this for a while now.

It is worth noting that I am using ammo.js, a JS port of bullet.

Any help is much appreciated!

EDIT - It seems like it has something to do with the distance of the arm. If I bring the slider closer to the origin of the arm then the wobbling is reduced. So maybe a torque thing. I'm still not sure how to resolve that though.
You do not have the required permissions to view the files attached to this post.
User avatar
xissburg
Posts: 46
Joined: Sat May 19, 2007 9:28 pm

Re: Slider Constraint wobbling on second axis - video attached

Post by xissburg »

First thing I'd check are the dimensions and mass of your objects. You gotta make sure they're realistic in size and weight and preferably using metric units. If you're using very large or very small numbers or if you have significant discrepancy in size or mass among the interacting objects, you might have instability.
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Slider Constraint wobbling on second axis - video attached

Post by drleviathan »

Yes, chains of constraints will do that: they can get "soft" at the ends, however usually only two or three constraints should be pretty stiff. The first thing to try, I think, is to reduce the substep duration in your simulation, if ammo.js allows it. The lower the better... although there is such a thing as "too small". There are rumors that bad things start to happen around 1/1000 sec for regular C++ Bullet. Try 1/120 sec and 1/240 sec to see if that improves things.

If that doesn't work I have one more idea... you could try using "fixed constraints" all around, instead of a slider and whatever else: they might be stiffer. You would just update the relative transforms of the fixed constraints over time to get armature animation.
evandarcy
Posts: 5
Joined: Mon May 27, 2019 10:15 am

Re: Slider Constraint wobbling on second axis - video attached

Post by evandarcy »

So I appear to have fixed the issue, I changed this line of code:

Code: Select all

grabberSlider = new Ammo.btSliderConstraint( grabber.userData.physicsBody, arm.userData.physicsBody, localA, localB, true );
to this:

Code: Select all

grabberSlider = new Ammo.btSliderConstraint( arm.userData.physicsBody, grabber.userData.physicsBody, localA, localB, true );
(Notice the first two parameters are swapped)

I also set the mass of "arm" to be 100 and the mass of "grabber" to be 100

Now the constraint is stiff as desired.

I am not sure why either of these worked, if anybody has some insight to that I'd love to hear it!
evandarcy
Posts: 5
Joined: Mon May 27, 2019 10:15 am

Re: Slider Constraint wobbling on second axis - video attached

Post by evandarcy »

drleviathan wrote: Tue May 28, 2019 4:23 pm Yes, chains of constraints will do that: they can get "soft" at the ends, however usually only two or three constraints should be pretty stiff. The first thing to try, I think, is to reduce the substep duration in your simulation, if ammo.js allows it. The lower the better... although there is such a thing as "too small". There are rumors that bad things start to happen around 1/1000 sec for regular C++ Bullet. Try 1/120 sec and 1/240 sec to see if that improves things.
Why would the substep make a difference?
drleviathan wrote: Tue May 28, 2019 4:23 pm If that doesn't work I have one more idea... you could try using "fixed constraints" all around, instead of a slider and whatever else: they might be stiffer. You would just update the relative transforms of the fixed constraints over time to get armature animation.
So in effect I would be transforming fixed rigidbodies to the position I need them? I feel like that is a lot more complex. Have you had experience building something like a robot arm before using bullet, if so, what kind of functions did you use?

Sorry for all the questions, it seems like the forum is the best place to learn! Thanks for the help so far :-)
evandarcy
Posts: 5
Joined: Mon May 27, 2019 10:15 am

Re: Slider Constraint wobbling on second axis - video attached

Post by evandarcy »

xissburg wrote: Mon May 27, 2019 4:22 pm First thing I'd check are the dimensions and mass of your objects. You gotta make sure they're realistic in size and weight and preferably using metric units. If you're using very large or very small numbers or if you have significant discrepancy in size or mass among the interacting objects, you might have instability.
It seems like the weight had something to do with it alright. The horizontal arm is 100x heavier than the vertical arm and this had definitely made an impact.
User avatar
xissburg
Posts: 46
Joined: Sat May 19, 2007 9:28 pm

Re: Slider Constraint wobbling on second axis - video attached

Post by xissburg »

evandarcy wrote: Tue May 28, 2019 6:31 pm It seems like the weight had something to do with it alright. The horizontal arm is 100x heavier than the vertical arm and this had definitely made an impact.
You should look up the issue there is with large "mass ratios" in Sequential Impulses. The relative mass between interacting objects is always something to consider. A 100x weight difference is quite significant.
evandarcy
Posts: 5
Joined: Mon May 27, 2019 10:15 am

Re: Slider Constraint wobbling on second axis - video attached

Post by evandarcy »

xissburg wrote: Tue May 28, 2019 7:40 pm You should look up the issue there is with large "mass ratios" in Sequential Impulses. The relative mass between interacting objects is always something to consider. A 100x weight difference is quite significant.
I will definitely check it out! Do you know if maybe there is a better way to create robot arm type links rather than using constraints?
User avatar
xissburg
Posts: 46
Joined: Sat May 19, 2007 9:28 pm

Re: Slider Constraint wobbling on second axis - video attached

Post by xissburg »

evandarcy wrote: Tue May 28, 2019 7:59 pm I will definitely check it out! Do you know if maybe there is a better way to create robot arm type links rather than using constraints?
Constraints are what you gotta use to "constrain" the motion of one object to another. Are you using btMultiBody (Featherstone method)? If not check out the stuff under examples/MultiBody. That method is more appropriate to simulate robots.