gz-physics icon indicating copy to clipboard operation
gz-physics copied to clipboard

DetachableJoint: allow physics constraint properties to be set

Open srmainwaring opened this issue 6 months ago • 3 comments

🎉 New feature

Allow the joint constraint physics parameters constraint force mixing (cfm) and error reduction parameter (erp) to be set via Features. Here the parameters only apply to dynamically created joints in the dartsim engine, although the features are declared generally.

The parameters are not documented in the dartsim manual and must be inspected in the source code. They appear to be defined similarly to the parameters with the same name in ODE https://ode.org/wiki/index.php/Manual#Soft_constraint_and_Constraint_Force_Mixing_(CFM).

The parameters allow finer control over the simulation of the weld joints created using the detachable joint system. This is relevant when creating closed kinematic chains, where in some cases the constraint forces and error reduction iterations must be increased in order for the model to maintain integrity (i.e. prevent joints flying apart).

In dartsim these parameters are declared as class variables for DyanamicJointConstraints, so setting them on one detachable joint affects all others. Other physics engines may treat this differently.

Related:

  • https://github.com/gazebosim/gz-physics/issues/636

Summary

  • Add a new feature SetDynamicJointConstraintPropertiesFeature
  • Like AttachFixedJoint this is a Link feature (the weld constraints belong to the link).

Test it

  • See related PR in gz-sim: https://github.com/gazebosim/gz-sim/pull/2960

Checklist

  • [x] Signed all commits for DCO
  • [ ] Added tests
  • [ ] Added example and/or tutorial
  • [ ] Updated documentation (as needed)
  • [ ] Updated migration guide (as needed)
  • [ ] Consider updating Python bindings (if the library has them)
  • [ ] codecheck passed (See contributing)
  • [ ] All tests passed (See test coverage)
  • [ ] While waiting for a review on your PR, please help review another open pull request to support the maintainers
  • [ ] Was GenAI used to generate this PR? If so, make sure to add "Generated-by" to your commits. (See this policy for more info.)

Generated-by: Remove this if GenAI was not used.

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by and Generated-by messages.

srmainwaring avatar Jun 30 '25 14:06 srmainwaring

cc @scpeters in case you have opinions on these APIs.

There are some merge conflicts that need to be resolved otherwise looks good to me.

iche033 avatar Jul 09 '25 21:07 iche033

There are some merge conflicts that need to be resolved otherwise looks good to me.

Resolved in https://github.com/gazebosim/gz-physics/commit/03b126cd0f2f2c6c102860cc90c8c75e59f3b829

srmainwaring avatar Jul 10 '25 10:07 srmainwaring

@osrf-jenkins run tests please

iche033 avatar Jul 10 '25 18:07 iche033