pendulum inestability

Post Reply
gdlk
Posts: 62
Joined: Fri Oct 24, 2014 7:01 pm

pendulum inestability

Post by gdlk »

Hi!

I have a pendulum made it with two spheres joined with a btGeneric6DofSpring2Constraint. I set the limits so it has a initial length/sphere separation. The pendulum works fine after creation (is stable and has a right oscillation). If after creation constantly modify the constraint limits so more length is added, works fine. However, if modify the constraint limits so the length is reduce below the initial length, an instability happens (pendulum start an uncontrollable and fast oscillation). I try several things to fixed, but didn't work. Why this could be happen? and how could be solved? (the target is reduce the length of the pendulum when is in use)

Thanks!

PS: The transforms I am using in the constraint are:
- for the first sphere:
- traslation: the local position to the second sphere
- rotation: align X axis to direction to second sphere
- for the second sphere:
- traslation: 0
- rotation: align X axis to negative direction to first sphere
gdlk
Posts: 62
Joined: Fri Oct 24, 2014 7:01 pm

Re: pendulum inestability

Post by gdlk »

Any idea? I could upload an example to reproduce the problem if needed
hyyou
Posts: 96
Joined: Wed Mar 16, 2016 10:11 am

Re: pendulum inestability

Post by hyyou »

Can you try this?...
constraint->setParam(BT_CONSTRAINT_STOP_CFM, cfm, 1 );
constraint->setParam(BT_CONSTRAINT_STOP_ERP, erp, 0);
Disclaimer:
I have never used it, some custom values may have to be adjusted.
If it helps, please tell how you solve. :D
gdlk
Posts: 62
Joined: Fri Oct 24, 2014 7:01 pm

Re: pendulum inestability

Post by gdlk »

hyyou wrote:Can you try this?...
constraint->setParam(BT_CONSTRAINT_STOP_CFM, cfm, 1 );
constraint->setParam(BT_CONSTRAINT_STOP_ERP, erp, 0);
Disclaimer:
I have never used it, some custom values may have to be adjusted.
If it helps, please tell how you solve. :D
Thanks! but I don't think the solution go by that way (it sees like the system is getting more energy and explode by that (or something like that); while modify the cfm and erp will rectify faster or slower the constraint error in the step). I will try it anyways.

Any other clue? Or someone could reproduce it?
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: pendulum inestability

Post by benelot »

Upload an example and describe what you do to cause the problem.
gdlk
Posts: 62
Joined: Fri Oct 24, 2014 7:01 pm

Re: pendulum inestability

Post by gdlk »

benelot wrote:Upload an example and describe what you do to cause the problem.
I attach the file. Is just the bullet basic demo example modify to show the issue (the only file modify was BasicExample.cpp, so just replace that in the bullet example folder). There is 2 spheres constrained between them. Also the upper sphere is constrained to the world. With the keys 1 and 2 you can modify the constraint limit. With key 1 you give more distance between spheres, with key 2 you make you short the distance. The key 3 is just a little force to push the sphere to a side to show the issue.

The issue is:
- if you give more distance (press key 1), wait a moment and then press a few times the key 3, all works fine (sphere oscilate in the expected way).
- if you short the distance (press key 2), wait a moment and then press a few times the key 3, the sphere start like the normal oscilation. However, quickly the oscilation begin to be bigger and finally start an uncontrollable spin.

Thanks!
Attachments
BasicExample.cpp
(7.46 KiB) Downloaded 414 times
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: pendulum inestability

Post by benelot »

I am going to look into it this evening if I have time. Several things come to my mind. Is it necessary that take the generic6Dofspring constraint? Because since you probably do not need the springs for your simulation and also you do not need the linear displacements (3DoF), it could he that the simulation gets much more stable as soon as you use another, more simple constraint. You could probably use a point to point and a slider for your distance. So you would attach your top element to the world with point to point and then connect the top and bottom element of your pendulum with the slider.

Just my two cents before looking into the actual simulation. The issue might be in the timestep in the end.
gdlk
Posts: 62
Joined: Fri Oct 24, 2014 7:01 pm

Re: pendulum inestability

Post by gdlk »

benelot wrote:I am going to look into it this evening if I have time. Several things come to my mind. Is it necessary that take the generic6Dofspring constraint? Because since you probably do not need the springs for your simulation and also you do not need the linear displacements (3DoF), it could he that the simulation gets much more stable as soon as you use another, more simple constraint. You could probably use a point to point and a slider for your distance. So you would attach your top element to the world with point to point and then connect the top and bottom element of your pendulum with the slider.

Just my two cents before looking into the actual simulation. The issue might be in the timestep in the end.
Ideally I need a distance constraint. I understand a little the math behind that (and there are several docs explaining the equations), however I miss the part how write the constraint in bullet.

I tried with a timestep in 1/240, however didn't improve the situation. Also I tried your suggest (point to point with slider) but didn't work. I will try again with that approach, maybe I set something bad before.

Thanks!!
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: pendulum inestability

Post by benelot »

I found some time to look into your issue.

What you might need is a SliderConstraint for one of your constraint, which is basically your distance constraint.

Have a look at the possible constraints:
http://bulletphysics.org/mediawiki-1.5. ... onstraints

The slider additionally has an angular degree of freedom, but that can be locked to 0. I implemented what I meant in the attached basic example. I you have to hit the ball with key 3 first to make it move to the correct length (some activation issue probably), but from then on, it swings very stabily for all lengths.
Attachments
BasicExample.cpp
(7.02 KiB) Downloaded 419 times
gdlk
Posts: 62
Joined: Fri Oct 24, 2014 7:01 pm

Re: pendulum inestability

Post by gdlk »

benelot wrote:I found some time to look into your issue.

What you might need is a SliderConstraint for one of your constraint, which is basically your distance constraint.

Have a look at the possible constraints:
http://bulletphysics.org/mediawiki-1.5. ... onstraints

The slider additionally has an angular degree of freedom, but that can be locked to 0. I implemented what I meant in the attached basic example. I you have to hit the ball with key 3 first to make it move to the correct length (some activation issue probably), but from then on, it swings very stabily for all lengths.
Really thanks for your time!

I test your code, but the issue is still there =(. The pendulum works fine if the constraint limits has the initial length or bigger, however if I try to reduce the limits below the initial values, again has problems (in this case never recover the length when try to increase again. I had to modify a little your code to shorter the length below the initial value because the constraint change)
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: pendulum inestability

Post by benelot »

I am working on an example browser demo based on your code and what I do not face the problem anymore. Probably I missed something, I will check again later.
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: pendulum inestability

Post by benelot »

Here is my newtonian pendulum example. You can use 1 and 2 to increase and decrease the length of the pendulum. 3 to push. The sliders do a lot of other things. The main problem was that the slider was not vertical, but horizontal. You can turn the number of pendula to 1 and you get your desired example.
Attachments
NewtonianPendulum.cpp
(10.75 KiB) Downloaded 418 times
Post Reply