Acceleration-level contact complementarity (source code)

= Acceleration-level contact complementarity
{title2=$\ddot d\ge0,\quad N\ge0,\quad N\ddot d=0$}

<Acceleration-level contact complementarity> decides whether a smooth, closed contact with zero normal <velocity> must carry a compressive reaction or begin to separate. At $d=0$ and $\dot d=0$, the normal conditions are
$$
\ddot d\ge0,\qquad N\ge0,\qquad N\ddot d=0.
$$
They do not constrain the sign of <acceleration> at a positive gap, and they do not resolve an impact with negative incoming normal <velocity>. The distinction between smooth constrained dynamics and time-stepped contact/impact models is explicit in the primary dynamics treatment.<Underactuated Robotics by Russ Tedrake>[Multi-Body Dynamics, constrained equations and Time-stepping LCP: Normal force]{ref}

For a frictionless multibody model with generalized <velocity> $v$, invertible <mass> matrix $M$ and contact Jacobian $J$ defined by $\dot d=Jv$, write
$$
M\dot v=f+J^{\mathsf T}N,\qquad
\ddot d=J\dot v+\dot Jv=b+WN,
$$
where $b=JM^{-1}f+\dot Jv$ is the free normal <acceleration> and $W=JM^{-1}J^{\mathsf T}$. The normal reactions then solve the <linear complementarity problem>
$$
N\ge0,\qquad b+WN\ge0,\qquad N^{\mathsf T}(b+WN)=0.
$$
The matrix couples contacts: choosing each reaction from a separate scalar formula generally fails when it changes <acceleration> at the other contacts. This formulation assumes the displayed velocity-coordinate kinematics and active closed contacts; additional friction <forces> modify the dynamics.

For an original coupled example, take free normal acceleration $b=(-3,-3)^{\mathsf T}\,\mathrm{m\,s^{-2}}$ and
$$
W=\begin{pmatrix}2&1\\1&2\end{pmatrix}\,\mathrm{kg^{-1}}.
$$
The reaction $N=(1,1)^{\mathsf T}\,\mathrm N$ gives zero normal acceleration at both contacts. Ignoring the off-diagonal coupling would instead choose $1.5\,\mathrm N$ at each; inserted into the full system, that produces $1.5\,\mathrm{m\,s^{-2}}$ of outward acceleration at both loaded contacts and violates complementarity. Positive reaction and positive separating acceleration cannot coexist in this smooth active-contact model.

Because these are acceleration-level conditions, a numerical trajectory can still accumulate position or <velocity> drift. They must be paired with an integration/contact-update procedure that maintains the assumed state. During separated free flight, a negative <acceleration> can be perfectly admissible until the next contact event. At impact, an impulse and an appropriate velocity-level law are needed instead of applying the smooth equations across a discontinuity.