What one should do when simulation explodes?

Post Reply
catchyid
Posts: 15
Joined: Thu Jul 30, 2015 2:12 pm

What one should do when simulation explodes?

Post by catchyid »

Hi,
I know this is a very generic question, I hope someone would just give me some pointers. In summary, I am using Bullet to a simulate a house destruction, there are ~thousands constraints and rigid bodies. Sometimes the simulation goes as expected (very rarely now) and sometimes it explodes (each simulation takes couple minutes to complete).

To troubleshoot the problem I have two options:
(a) blinding change simulation parameters, e.g. friction, damping, constraints limits, forces, etc. OR,
(b) try to find the root cause of the problem (obviously, the solver does not like the dynamical system created, maybe the system is unsolvable under certain conditions)

option (a) helped me couple times, but it's a semi blind guessing game and it does not guarantee a fix. Option (b) requires better understanding of Bullet and its internals which is also time consuming specially that my knowledge in physical simulation is limited (I am a casual user, knows how to program bullet to create constraints, rigidbodies,... but when it comes to how the solver works, I know nothing, maybe some basic principles in numerical algorithms )

My question: for those who have good experience with Bullet, what's the right route to fix these explosions? If I were to pursue option (b) what would be a good time frame for that? Any ideas?

Once more, I know it's a very general question, any feedback would be appreciated.

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

Re: What one should do when simulation explodes?

Post by Basroil »

In general, these are the steps you should use to solve it:
1) Check for programming errors. Perhaps one body is randomly very far from where it should be (relatively), or some constraint is using infinite impulse rather than fixed bounds
2) Increase simulation frequency, but keep ERP in mind. Use more iterations
3) Use a stiff solver like the ones in the MLCP side
4) Use DP

Usually it's something in 1, but if it's not, one of the other three might help
mobeen
Posts: 122
Joined: Thu May 05, 2011 11:47 am

Re: What one should do when simulation explodes?

Post by mobeen »

Normally I would look for division by 0s for most of my simulation explosion errors.
gdlk
Posts: 62
Joined: Fri Oct 24, 2014 7:01 pm

Re: What one should do when simulation explodes?

Post by gdlk »

What is/means DP?
Basroil wrote:In general, these are the steps you should use to solve it:
1) Check for programming errors. Perhaps one body is randomly very far from where it should be (relatively), or some constraint is using infinite impulse rather than fixed bounds
2) Increase simulation frequency, but keep ERP in mind. Use more iterations
3) Use a stiff solver like the ones in the MLCP side
4) Use DP

Usually it's something in 1, but if it's not, one of the other three might help
catchyid
Posts: 15
Joined: Thu Jul 30, 2015 2:12 pm

Re: What one should do when simulation explodes?

Post by catchyid »

@gdlk: I "think" DP stands for double precision, in bullet btScalar is defined as float by default.

@mobeen: how would you look for divisions by 0? meaning, run in debug mode and wait for division by zero exceptions?

@Basroil: thanks. Couple more questions:

-"some constraint is using infinite impulse rather than fixed bounds" -> how do I check for that, I could not find a field/function to set max impulse response, maybe if we user motorized constraints it would be max force applied?

-"Increase simulation frequency, but keep ERP in mind. Use more iterations" -> I know that ERP stands for error reduction parameter, but I am not sure how it relates to simulation frequency?

-I've tested btMLCPSolver + btLemkeSolver, however the application crashed. Not sure why... will investigate if needed

-The things that puzzles me the most now: the following day after posting my question, I ran the same simulation and to my surprise it did NOT explode!!! I have no idea why...
gdlk
Posts: 62
Joined: Fri Oct 24, 2014 7:01 pm

Re: What one should do when simulation explodes?

Post by gdlk »

@gdlk: I "think" DP stands for double precision, in bullet btScalar is defined as float by default.
Oh... right, thanks!
-The things that puzzles me the most now: the following day after posting my question, I ran the same simulation and to my surprise it did NOT explode!!! I have no idea why...
If exploding was a crash, I would tell you that generally that means you are using a variable not initialized or you are using a invalid/deleted memory... maybe is something like that.

Also use the bullet profiler to check what section of bullet is the bottleneck (maybe it could give some hint)
catchyid
Posts: 15
Joined: Thu Jul 30, 2015 2:12 pm

Re: What one should do when simulation explodes?

Post by catchyid »

Unfortunately it's not a crash, it's basically rigid bodies go haywire, i.e they move in random directions very fast breaking all constraints, then eventually they get back together ...

I have not used bullet profiler, is there a sample code that shows how to use it?

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

Re: What one should do when simulation explodes?

Post by gdlk »

Don't know if there is an example, but is simple =). After step the world, just call

Code: Select all

CProfileManager::dumpAll();
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: What one should do when simulation explodes?

Post by Basroil »

catchyid wrote:-"some constraint is using infinite impulse rather than fixed bounds" -> how do I check for that, I could not find a field/function to set max impulse response, maybe if we user motorized constraints it would be max force applied?
Motor constraints would certainly give you control, as would breaking constraints.
catchyid wrote:-"Increase simulation frequency, but keep ERP in mind. Use more iterations" -> I know that ERP stands for error reduction parameter, but I am not sure how it relates to simulation frequency?
ERP is defined in terms of frames until it's resolved (more or less, there are proper ways of describing it but this one works quite well) rather than time. Increase frames per second means effective ERP also increases. If you simulate at 60-300Hz it shouldn't be too much of an issue, but go above 1kHz and it's going to be harder to keep stable
catchyid wrote:-I've tested btMLCPSolver + btLemkeSolver, however the application crashed. Not sure why... will investigate if needed
I've only personally tried the Dantzig solver, when I first used it the lemke one was still slow/possibly incomplete.
catchyid wrote:-The things that puzzles me the most now: the following day after posting my question, I ran the same simulation and to my surprise it did NOT explode!!! I have no idea why...
You probably just recompiled it with different settings. It happens.
Post Reply