Skip to content

Conversation

@SonSang
Copy link
Collaborator

@SonSang SonSang commented Dec 5, 2025

Description

This PR aims at stitching differentiable components in the rigid body simulation to make it fully differentiable end-to-end. Also, it will provide a minimal demo to demonstrate the differentiability of the rigid body simulation.

Specifically, this PR would contain:

  • Fully differentiable rigid body simulation
  • Minimal demo for differentiable rigid body simulation (e.g. solving optimization problem)
  • More informative error handlings for differentiable simulation for users

Related Issue

Resolves #2069

Motivation and Context

How Has This Been / Can This Be Tested?

TBD

Screenshots (if appropriate):

TBD

Checklist:

  • I read the CONTRIBUTING document.
  • I followed the Submitting Code Changes section of CONTRIBUTING document.
  • I tagged the title correctly (including BUG FIX/FEATURE/MISC/BREAKING)
  • I updated the documentation accordingly or no change is needed.
  • I tested my changes and added instructions on how to test it for reviewers.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@SonSang SonSang marked this pull request as draft December 5, 2025 21:42
@SonSang SonSang changed the title [FEATURE] Make rigid body simulation fully differentiable with a minimal demo [FEATURE] Make rigid body simulation fully differentiable Dec 5, 2025
@gs.assert_built
def set_dofs_velocity_grad(self, dofs_idx_local, envs_idx, velocity_grad):
dofs_idx = self._get_idx(dofs_idx_local, self.n_dofs, self._dof_start, unsafe=True)
dofs_idx = self._get_global_idx(dofs_idx_local, self.n_dofs, self._dof_start, unsafe=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a unit test for this.

Comment on lines 302 to +307
if getattr(self._options, "noslip_iterations", 0) > 0:
gs.raise_exception("Noslip is not supported yet when requires_grad is True.")

if getattr(self._options, "sparse_solve", False):
gs.raise_exception("Sparse solve is not supported yet when requires_grad is True.")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have unit tests to catch all this forbidden configurations.

@SonSang SonSang changed the title [FEATURE] Make rigid body simulation fully differentiable [FEATURE] WIP: Make rigid body simulation fully differentiable Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: No gradients wrt control force

2 participants