I am simulating two sphere-like agents that move around in a space with 10 boxes at random positions. One of the agents can pull individual boxes using equality constraints that are activated and deactivated. Occasionally, I get warnings such as "Inertia matrix is too close to singular" that I can successfully catch and recover from. However, at other times I get the error "ERROR: Rank-defficient Hessian in HessianDirect" (sic!) which stops the program and is therefore impossible to recover from. From observing the simulation it is non-obvious to me when this error arises. How can it be avoided?