Page 1 of 1

Implementing a scissor model using constraints

Posted: Sun Nov 03, 2019 11:42 am
by jhasketan
Dear All,

I am building a surgery scissor simulator. I have implemented a scissor using bullet physics. Basically this scissor is consist of 4 meshes 1) base, 2) connector, 3) left tip and 4) right tip. Scissor can move left or right or top or bottom. Also both tip can open and close. So, I have a hinge constraint between base and connector and implemented two other hinge constraints(using generic6DOFConstraints) between left tip and connector, right tip and connector. I am manipulating scissor tip position using a touch 3D device and constraint shall apply inverse kinematics to move to position. All meshes dynamic rigid body. My problem is when I move the tip slowly it is somewhat working but when I move tip very fast, constraints and rigid bodies are falling apart. Both code and video are attached. I checked RoggDoll implementation and my implementation is very similar. But don't know why it is not behaving same. Any help would be greatly appreciated.

Below is the dropbox link for the video : ... z6W6a?dl=0

Re: Implementing a scissor model using constraints

Posted: Thu Nov 07, 2019 5:19 pm
by drleviathan
First thing to try would be to use smaller substeps. Your code does this:

Code: Select all

    _bWorld->stepSimulation(_timeline.previousFrameDuration(), 1);
Which uses the default substep duration: one 1/60th of a second, and you only take one substep per step. What I would recommend is to try this:

Code: Select all

    const btScalar substepFrequency = 240.0;
    const btScalar substepDuration = 1.0 / substepFrequency;
    const btScalar expectedMaximumFrameDuration = 0.05; // 20Hz
    const int32_t maxSubsteps = (int32_t)(expectedMaximumFrameDuration / substepDuration);
    _bWorld->stepSimulation(_timeline.previousFrameDuration(), maxSubsteps, substepDuration);
Play around with the substepFrequency to see how that changes the accuracy of the constraint solver. Note: there have been reports of misbehaviour when the substeps get too small (~ 0.001 sec) but I have not tried it.