Hello,
I'd like to simlate a complex mechanical system (a kind of clockwork automaton, lots of gears, cams and levers).
I already have some code to generate shapes for 3D printing using constructive geometry (OpenCascade/PyOCC). Ideally I would like to take the output of that and feed it into simulation to see how the parts fit together and operate (see pic for a small example). The goal for it to be as generic as possible, that is, to avoid adding explicit kinematinc constraints and rely on collision shape interaction whenever possible.
I have some questions:
1. Is it possible?
2. What are the practical limits on the number of interacting parts, number of collision shapes per part, size/mass ratios of individual parts?
3. I understand default collision margin is 0.04. If that refers to 4% of linear size of the object, that is way too much. Is there a way to reduce it significantly?
4. What is the "proper" way of representing complex concave collision shapes such as involute gears?
5. What parameters/design choices are there to improve reliability at the expense of performance? (I can live with it being non realtime)
Regards,R.
Accurate simulation of complex mechanical system
Accurate simulation of complex mechanical system
 Attachments

 shapshot.png (56 KiB) Viewed 734 times
 drleviathan
 Posts: 581
 Joined: Tue Sep 30, 2014 6:03 pm
 Location: San Francisco
Re: Accurate simulation of complex mechanical system
(1) Yes it is possible.
(2) I don't know the boundaries for all of your variables. You're just going to have to explore. Start conservatively then push the envelope.
(3) The default collision margin is 0.04 "distance units". If you're using meters then that would correspond to 4cm. The margin really represents the smoothing around the edges of the convex shapes, but the margin does not necessarily apply in all shapevsshape cases. For more info I recommend you watch this overview of shapes and margin for Bullet running in Blender. You can reduce the margin in exchange for performance and "accuracy"  with a lower margin you might end up in penetration more often and then the penetration resolution code will kick in  it will push the shapes apart but does so in a nonphysical manner so it tends to wander from correctness.
Alternatively you could leave the margin asis but choose your units to be centimeters instead of meters, however you'd have to compensate the meaning of your timestep, mass properties, and maybe also think about how to modify tune friction and restitution. Another way to think about this is: you're scaling your contraption's dimensions up by some factor (2x, 5x, 10x) and reducing the effective flow of time by a corresponding inverse factor.
(4) You probably want to compute a convex decomposition of your concave shapes and then use a btCompoundShape of convex subparts. Watch the aforementioned video.
(5) Some general advice:
(5a) Configure Bullet to use double precision.
(5b) Use fixedlength substeps.
(5c) Step at least 240Hz, but know: rumor has it somewhere around 1000Hz strange bugs start to show up.
(2) I don't know the boundaries for all of your variables. You're just going to have to explore. Start conservatively then push the envelope.
(3) The default collision margin is 0.04 "distance units". If you're using meters then that would correspond to 4cm. The margin really represents the smoothing around the edges of the convex shapes, but the margin does not necessarily apply in all shapevsshape cases. For more info I recommend you watch this overview of shapes and margin for Bullet running in Blender. You can reduce the margin in exchange for performance and "accuracy"  with a lower margin you might end up in penetration more often and then the penetration resolution code will kick in  it will push the shapes apart but does so in a nonphysical manner so it tends to wander from correctness.
Alternatively you could leave the margin asis but choose your units to be centimeters instead of meters, however you'd have to compensate the meaning of your timestep, mass properties, and maybe also think about how to modify tune friction and restitution. Another way to think about this is: you're scaling your contraption's dimensions up by some factor (2x, 5x, 10x) and reducing the effective flow of time by a corresponding inverse factor.
(4) You probably want to compute a convex decomposition of your concave shapes and then use a btCompoundShape of convex subparts. Watch the aforementioned video.
(5) Some general advice:
(5a) Configure Bullet to use double precision.
(5b) Use fixedlength substeps.
(5c) Step at least 240Hz, but know: rumor has it somewhere around 1000Hz strange bugs start to show up.