I'm trying to create a spring using either btGeneric6DofSpring2Constraint or btGeneric6DofSpringConstraint and I'm failing miserably.
In all the examples I could find one body is always static, and that seems to work fine. As soon as I make both bodies dynamic the whole thing just spins like crazy and shoots off to outer space.
In fact I couldn't even get btGeneric6DofConstraint to act like a slider. Eg, this works as expected:
Code: Select all
auto spring = new btSliderConstraint(*disk1, *disk2, t1, t2,true);
spring->setLowerLinLimit(3);
spring->setUpperLinLimit(4);
Code: Select all
auto spring = new btGeneric6DofConstraint(*disk1, *disk2, t1, t2, true);
spring->setLimit(0, 3, 4);
spring->setLimit(1, 0, 0);
spring->setLimit(2, 0, 0);
spring->setLimit(3, 0, 0);
spring->setLimit(4, 0, 0);
spring->setLimit(5, 0, 0);
I must be missing something obvious.Can someone point me to a working example?
Another question is how do I set the parameters? What are the units?
For example I would like to have two disks (say cylinders R=0.5, h = 0.2, mass 1) constrained to move slide in the direction of cylinder axis within the range (say say 2 to 4 between CM) and with the spring between them with equilibrium point at max range and parameters set so that when the bottom disk is laying on the ground the top one sags by 1 under the force of gravity and oscillates with a freq of say 2 Hz and the damping set so that it stops oscillating after 3..5 periods.
Thanks,
R