Wrong restitution behaviour with timesteps smaller than 1/60

Post Reply
zbuffer
Posts: 8
Joined: Sat Jan 05, 2013 11:13 am

Wrong restitution behaviour with timesteps smaller than 1/60

Post by zbuffer »

Hello!
I am building a simulation framework based on Bullet. It is focused on the accuracy. I am using the Dantzig solver for the calculations and need a frequency of 500 Hz or even more to be able to simulate sensors and control systems.

I have created some simple tests to check the correctness of friction and restitution. I implemented my own ContactAddedCallback to handle friction and restitution in a reallistic manner.
The friction part works really good for a box sliding down a slope.
The problem is the restitution. I test it by dropping a sphere on a plane.

1. With a frequency of 60 Hz (Bullet standard) the restitution works pretty well. The only problem is that after a dozen of collisions the ball suddenly starts to lower although the restitution is set to 1.0. It is not a big deal as normally only the first few jumps matter and these are ok.
2. With a frequency of more than 60 Hz the restitution doesn't work at all! To be more precise it behaves strange - with some frequencies ball jumps to much with others to little and when the frequency is more than about 150 Hz it stops jumping at all.

This is my configuration at the moment:

Code: Select all

    dynamicsWorld->getSolverInfo().m_solverMode = SOLVER_USE_WARMSTARTING | SOLVER_SIMD | SOLVER_USE_2_FRICTION_DIRECTIONS | SOLVER_ENABLE_FRICTION_DIRECTION_CACHING;
    dynamicsWorld->getSolverInfo().m_warmstartingFactor = 1.0;
    dynamicsWorld->getSolverInfo().m_minimumSolverBatchSize = 1;

    //Quality/stability
    dynamicsWorld->getSolverInfo().m_tau = 1.0;  //mass factor
    dynamicsWorld->getSolverInfo().m_erp = 0.5;  //constraint error reduction in one step
    dynamicsWorld->getSolverInfo().m_erp2 = 1.0; //constraint error reduction in one step for split impulse
    dynamicsWorld->getSolverInfo().m_numIterations = 1000; //number of constraint iterations
    dynamicsWorld->getSolverInfo().m_sor = 1.0; //not used
    dynamicsWorld->getSolverInfo().m_maxErrorReduction = 0; //not used
    
    //Collision
    dynamicsWorld->getSolverInfo().m_splitImpulse = true; //avoid adding energy to the system
    dynamicsWorld->getSolverInfo().m_splitImpulsePenetrationThreshold = -0.000001; //low value needed for accurate friction
    dynamicsWorld->getSolverInfo().m_splitImpulseTurnErp = 1.0; //error reduction for rigid body angular velocity
    dynamicsWorld->getDispatchInfo().m_useContinuous = false;
    dynamicsWorld->getDispatchInfo().m_allowedCcdPenetration = -0.001;
    dynamicsWorld->setApplySpeculativeContactRestitution(true);
    dynamicsWorld->getSolverInfo().m_restingContactRestitutionThreshold = 1e30; //not used
    
    //Special forces
    dynamicsWorld->getSolverInfo().m_maxGyroscopicForce = 1e30; //gyroscopic effect
    
    //Unrealistic components
    dynamicsWorld->getSolverInfo().m_globalCfm = 0.0; //global constraint force mixing factor
    dynamicsWorld->getSolverInfo().m_damping = 0.0; //global damping
    dynamicsWorld->getSolverInfo().m_friction = 0.0; //global friction
    dynamicsWorld->getSolverInfo().m_singleAxisRollingFrictionThreshold = 1e30; //single axis rolling velocity threshold
    dynamicsWorld->getSolverInfo().m_linearSlop = 0.0; //position bias
I also set the CFM of Dantzig to 0.0. I tried with CCD but there is no difference. Maybe I am doing something wrong.

Have you got any idea how to fix the behaviour for high frequencies?
What is causing it?

Best,
Patryk
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Wrong restitution behaviour with timesteps smaller than

Post by Basroil »

Sometimes penetration correction can be confused for restitution, and as timesteps shrink penetration also shrinks. Have you tried linearly increasing the impact velocity as you increase the framerate? (making sure to add some distance noise between trials to avoid non-penetrating collisions)
Post Reply