Accurate simulation of complex mechanical system

Post Reply
random
Posts: 5
Joined: Fri Jan 25, 2019 12:28 pm

Accurate simulation of complex mechanical system

Post by random »

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 real-time)

Regards,R.
Attachments
shapshot.png
shapshot.png (56 KiB) Viewed 2813 times
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Accurate simulation of complex mechanical system

Post by drleviathan »

(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 shape-vs-shape 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 non-physical manner so it tends to wander from correctness.

Alternatively you could leave the margin as-is 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 sub-parts. Watch the aforementioned video.

(5) Some general advice:
(5a) Configure Bullet to use double precision.
(5b) Use fixed-length substeps.
(5c) Step at least 240Hz, but know: rumor has it somewhere around 1000Hz strange bugs start to show up.
Post Reply