# Rigid Body Simulation with Joints

I have read the basics of how force based physics simulation works and how you can create joints by enforcing certain constraints on the forces between two rigid bodies. What is unclear to me is what happens during the integration step.

In particular even if you enforce the constraints on the forces - during the integration step the bodies will still move out of alignment. By this I mean the hinge will seperate. What is the next step to address this?

How do you translationally re-align the bodies in a way which is consistent with classical mechanics? If you choose one piece as the "ground truth" and basically re-align all the connected pieces to it, you are biasing the evolution of the system to be around that piece which can't be correct.

• I'm not sure what you mean by "re-align". In a traditional velocity- or force-based constraint solver, the correcting impulse/force is applied at every time step precisely because the other forces on the body break the constraint every time it is updated. So perhaps I'm misunderstanding your question, but why isn't the answer "just impose the constraints again"? Jun 27 at 2:28
• The instantaneous force needed to maintain equality constraint isn't valid over the whole timestep so without correction the next iteration of the algorithm with have rigid body positions violating the constraints, right? The joints come apart? Do you just ignore this fact and allow some error and hope the next iteration will nudge the joints so they always stay approximately correct? Jun 27 at 3:04
• Yes, exactly, it's just the limitation of a discrete time-step. In fact, enforcing the constraints too rigidly will even lead to jittering. Or at least that's what you do for game physics engines, I have no idea what the high-society render physics community does. Jun 27 at 3:12
• When looking at the animations though it doesn't seem like error exists, are the animations decoupled from the physics so equality constraints are maintained exactly? How? Jun 27 at 3:32
• Well, most engines have separate update loops for rendering and physics updates, and presumably there are some interpolation schemes to keep the animation smooth. But a good constraint solver would keep the constraint error minimal anyway. Jun 27 at 3:40

Then you can reduce the system into an ODE in terms of the joint coordinates which you integrate. As a post processing step for each time frame $$t$$, joint positions $$\boldsymbol{q}$$, joint velocities $$\boldsymbol{\dot q}$$ and joint accelerations $$\boldsymbol{\ddot q}$$ can yield the full motion and force description of each body.
Finally is the problem of a free floating system of bodies which may not have a common parent body to define all other body configurations relative to. In this case you have to mix the robotic joint coordinates $$\boldsymbol{q}$$ with a standard rigid body parametrization of position and Euler angles, or quaternions and integrate everything at the same time.