Hard Contacts with Soft Gradients: Refining Differentiable Simulators for Learning and Control

📅 2025-06-17
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
Hard contacts in physics simulation cause inaccurate gradients, hindering sim-to-real transfer in gradient-based robotic optimization. To address this, we propose DiffMJX—the first high-fidelity differentiable simulation framework integrating MuJoCo with XLA compilation and adaptive numerical integration. Its core innovation is the Contacts From Distance (CFD) mechanism, which models contacts via signed distance fields and employs a pass-through gradient estimator; this yields physically plausible and informative backward gradients even in non-contact regions, reconciling the realism of rigid-body contact dynamics with full differentiability. Experiments demonstrate that DiffMJX substantially improves gradient fidelity in hard-contact scenarios. In reinforcement learning and model predictive control tasks, it enables more stable and faster policy convergence, significantly narrowing the performance gap between simulation and reality.

Technology Category

Application Category

📝 Abstract
Contact forces pose a major challenge for gradient-based optimization of robot dynamics as they introduce jumps in the system's velocities. Penalty-based simulators, such as MuJoCo, simplify gradient computation by softening the contact forces. However, realistically simulating hard contacts requires very stiff contact settings, which leads to incorrect gradients when using automatic differentiation. On the other hand, using non-stiff settings strongly increases the sim-to-real gap. We analyze the contact computation of penalty-based simulators to identify the causes of gradient errors. Then, we propose DiffMJX, which combines adaptive integration with MuJoCo XLA, to notably improve gradient quality in the presence of hard contacts. Finally, we address a key limitation of contact gradients: they vanish when objects do not touch. To overcome this, we introduce Contacts From Distance (CFD), a mechanism that enables the simulator to generate informative contact gradients even before objects are in contact. To preserve physical realism, we apply CFD only in the backward pass using a straight-through trick, allowing us to compute useful gradients without modifying the forward simulation.
Problem

Research questions and friction points this paper is trying to address.

Analyzing gradient errors in penalty-based simulators for hard contacts
Improving gradient quality in stiff contact settings with DiffMJX
Generating contact gradients before physical touch using CFD method
Innovation

Methods, ideas, or system contributions that make the work stand out.

Adaptive integration with MuJoCo XLA
Contacts From Distance (CFD) mechanism
Straight-through trick for backward pass
🔎 Similar Papers
No similar papers found.