Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: implement a "small-steps" velocity-based constraints solver + joint improvements #579

Merged
merged 3 commits into from Jan 22, 2024

Conversation

sebcrozet
Copy link
Member

@sebcrozet sebcrozet commented Jan 21, 2024

This is a complete rework of Rapier’s constraints solver. This has been cooking for quite a while now and I think it is time to be published, even though the parallel version has not been fully done yet (it will work, but with only island-based parallelism).

The idea is to combine the substep approach to solving constraints, similar to the latest known improvements of XPBD, but applied to Rapier’s velocity-based constraints formulation. In other words, it does not use the PBD formalism, but will solve Rapier’s pre-existing velocity-based constraints by subdividing the timestep into n substeps with 1 force calculation iteration per substep, instead of running n force calculation iteration for the full timestep. This result in a significantly improved convergence of joints, especially in case of large mass ratios due to the more non-linear handling of constraints.

Other changes include:

  • Joint angular motors and limits have been fixed to actually use the user-given angle (instead of its half value).
  • Torque generated by angular motors with a target position are now linear with the angle error (before, it would gradually slown down as the motor reaches its target position).
  • It is now possible to increase the number of solver iteration per-rigid-body (RigidBodyBuilder::additional_solver_iterations, RigidBody::set_additional_solver_iterations). This allows increasing simulation accuracy on a subset of objects instead of having increase the global solver iteration count, increasing computational cost on unrelated objects.
  • SpringJoint has been added. More generally, motors on joints with coupled linear axes are now supported.

The following video shows the stability improvements on a high-mass-ratio pendulum scenario. The large ball is 1000x heavier than the small ones:

  • First video: with 20 iterations of the new solver, the simulation is stable.
  • Second video: even with 4000 iteration of the old solver, the simulation breaks down immediately.
chain-large-mass-ratio-new-solver-20-iterations.mp4
chain-large-mass-ratio-old-solver-4000-iterations.mp4

Here is a video of the new spring joint. The springs, with various damping coefficients, are attached to the balls. The cubes are just object falling freely on top of the balls:

spring-joints.mp4

Fix #241

@sebcrozet sebcrozet added the enhancement New feature or request label Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Spring
1 participant