Skip to content

Conversation

srmainwaring
Copy link
Contributor

@srmainwaring srmainwaring commented Jun 30, 2025

🎉 New feature

Allow joint constraint physics parameters to be set for detachable joints.

Depends on:

Summary

  • Add a parameter block with and sub elements.
  • Update the Physics system to use the feature physics::SetDynamicJointConstraintPropertiesFeature
  • Add optional fields to the detachable joint component.

Test it

Add a SDF parameter block to a model using a detachable joint:

    <plugin name="gz::sim::systems::DetachableJoint"
      filename="libgz-sim-detachable-joint-system.so">
      <parent_link>blade_rod_1a_link</parent_link>
      <child_link>blade_rod_1b_link</child_link>
      <child_model>rotor_head_cw</child_model>
      <joint_type>fixed</joint_type>
      <physics>
        <cfm>1.0e-6</cfm>
        <erp>0.8</erp>
      </physics>
    </plugin>

Inspect the console when running with verbose output:

(2025-06-30 15:16:29.373) [debug] [Physics.cc:1942] Creating detachable joint [318]
(2025-06-30 15:16:29.373) [debug] [Physics.cc:1956] SetConstraintForceMixing: 1e-06
(2025-06-30 15:16:29.373) [debug] [JointFeatures.cc:746] SetConstraintForceMixing: 1e-06
(2025-06-30 15:16:29.373) [debug] [Physics.cc:1964] SetErrorReductionParameter: 0.8
(2025-06-30 15:16:29.373) [debug] [JointFeatures.cc:760] SetErrorReductionParameter: 0.8

The default values of cfm and erp may result in simulation that is unable to constrain joints in a closed kinematic chain - resulting in the model flying apart (often followed by a segmentation fault). Increasing these parameters may result in a stable simulation.

Checklist

  • 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.)

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.

- Add a <physics> parameter block with <cfm> and <erp> sub elements.
- Update the `Physics` system to use the feature physics::SetDynamicJointConstraintPropertiesFeature
- Add optional fields to the detachable joint component.

Signed-off-by: Rhys Mainwaring <[email protected]>
@ntfshard
Copy link
Contributor

ntfshard commented Jul 1, 2025

Proposal: keep sdf structure similar to sdf joint definition http://sdformat.org/spec?ver=1.9&elem=joint
e.g. physics -> ode -> (new fields)
And also possible to use defaults from sdf instead of optional for consistency

@github-project-automation github-project-automation bot moved this from Inbox to In review in Core development Jul 1, 2025
@srmainwaring
Copy link
Contributor Author

Proposal: keep sdf structure similar to sdf joint definition http://sdformat.org/spec?ver=1.9&elem=joint
e.g. physics -> ode -> (new fields)

I thought about this, but decided it was a little overkill adding another 2 or 3 layers of nesting. It's also a little confusing as the engine in use is dartsim not ode, and here and in some other places fields from one engine are used in another. Keeping the fields flat is more in line with the reworked physics libraries strategy of using typelists of features - if a library supports a feature it uses it, otherwise it is ignored.

And also possible to use defaults from sdf instead of optional for consistency

The question then is what defaults to use in SDF, and how to ensure that they are the same as what the physics engine is using? Using optional leaves the definition of defaults in one place - the physics engine, rather than placing them across the system.

@ntfshard
Copy link
Contributor

ntfshard commented Jul 1, 2025

Proposal: keep sdf structure similar to sdf joint definition http://sdformat.org/spec?ver=1.9&elem=joint
e.g. physics -> ode -> (new fields)

I thought about this, but decided it was a little overkill adding another 2 or 3 layers of nesting. It's also a little confusing as the engine in use is dartsim not ode, and here and in some other places fields from one engine are used in another. Keeping the fields flat is more in line with the reworked physics libraries strategy of using typelists of features - if a library supports a feature it uses it, otherwise it is ignored.

And also possible to use defaults from sdf instead of optional for consistency

The question then is what defaults to use in SDF, and how to ensure that they are the same as what the physics engine is using? Using optional leaves the definition of defaults in one place - the physics engine, rather than placing them across the system.

I guess in a perfect way it should be as same as original joint so using the same structure can allow to switch to existing parser(at least potentially). In future I want to add other joints types to this plugin tbh

srmainwaring added a commit to srmainwaring/SITL_Models that referenced this pull request Jul 3, 2025
RotorHead
- Adjust pose of model in world
- Add further links and joints.
- Add lever coupling links and joints.
- Simplify collisions.
- Compose ball joint from 2 revolute joints.
- Simplify collisions for linkages.
- Ensure all ball joints have 3DoF
- Add servo linkage visuals.
- Limit movement of lever joints.
- Lever coupling top joints are revolute, not ball.
- Add guide rod and retainer to prevent lower swashplate rotation.
- Update friction and damping.
- Recompute ball joint inertials.
- Add servos and rods.
- Update joint damping.
- Update link and joint names.
- Align swashplate joints.
- Replace collision guide with joints.
- Add rotor blades.
- Add lift-drag plugins.
- Correct joint orientations.
- Reorient servo links.
- Reduce mass of rotor head.
- Adjust rotor lift-drag.
- Rename rotor head model
- Add ccw version of rotor head.
- Update orientation in ccw rotor head.
- Velocity controllers were not using force and PIDs
- Update PIDs for joint and position controllers.
- Fit lift-drag coefficients to NACA0012 profile.
- Add blade visuals for CW and CCW rotors.
- Move servo2 to be near centre of rotor head.
- Remove debug info.
- Remove debug colours of servo rods and joints.
- Add credit for visuals

Helicopter
- Add helicopter model in world.
- Add tail rotor.
- Add stabiliser bars and wheels.
- Add ArduPilot plugin.
- Swap servo_1 and servo_3 to be consistent with AP ordering.
- Adjust CoG.
- Adjust IMU position to main rotor.
- Add separate model and config files.
- Use standalone model for helicopter.
- Place on runway model.
- Rename helicopter world
- Update to SDF version 1.11
- Add intermeshing dual rotor example.
- Add meshes.
- Increase friction on stabilizers.
- Correct orientation of tail rotor blade visual and collision.
- Correct dual heli control elements.
- Increase mass of base link for dual heli.
- Add params for dual transverse helicopter.
- Add gimbal for testing attitude control.
- Allow blades to flap on rotor heads
- This is essential for correct operation.
- Blades hinge at blade grips with range +/- 8 deg.
- Adjust blade flapping damping and spring constant.
- Remove oscillation / resonance when rolling at higher collective.
- Reduce blade hinge spring stiffness.
- Set ball joint properties
- Use gazebosim/gz-physics#753
- Set physics params in detachable joints
- Use gazebosim/gz-physics#754
- Use gazebosim/gz-sim#2960
- Adjust flapping hinge position
- Move hinge towards rotor hub.
- This position gives a flapping lag of about 80 deg behind the blade pitch.
- Retune ATC_RAT PIDs for flapping blades.
- Add visuals for frame and rotors
- Add mesh visuals based on TRex-450.
- Remove stabilising links and wheels.
- Reposition tail rotor to match rescaled model.
- Update rotor velocity command topic.
- Add config for the ros_gz bridge
- Retune model for adjusted CoM and tail position
- Add credit for visuals

Signed-off-by: Rhys Mainwaring <[email protected]>
srmainwaring added a commit to srmainwaring/SITL_Models that referenced this pull request Jul 3, 2025
RotorHead
- Adjust pose of model in world
- Add further links and joints.
- Add lever coupling links and joints.
- Simplify collisions.
- Compose ball joint from 2 revolute joints.
- Simplify collisions for linkages.
- Ensure all ball joints have 3DoF
- Add servo linkage visuals.
- Limit movement of lever joints.
- Lever coupling top joints are revolute, not ball.
- Add guide rod and retainer to prevent lower swashplate rotation.
- Update friction and damping.
- Recompute ball joint inertials.
- Add servos and rods.
- Update joint damping.
- Update link and joint names.
- Align swashplate joints.
- Replace collision guide with joints.
- Add rotor blades.
- Add lift-drag plugins.
- Correct joint orientations.
- Reorient servo links.
- Reduce mass of rotor head.
- Adjust rotor lift-drag.
- Rename rotor head model
- Add ccw version of rotor head.
- Update orientation in ccw rotor head.
- Velocity controllers were not using force and PIDs
- Update PIDs for joint and position controllers.
- Fit lift-drag coefficients to NACA0012 profile.
- Add blade visuals for CW and CCW rotors.
- Move servo2 to be near centre of rotor head.
- Remove debug info.
- Remove debug colours of servo rods and joints.
- Add credit for visuals

Helicopter
- Add helicopter model in world.
- Add tail rotor.
- Add stabiliser bars and wheels.
- Add ArduPilot plugin.
- Swap servo_1 and servo_3 to be consistent with AP ordering.
- Adjust CoG.
- Adjust IMU position to main rotor.
- Add separate model and config files.
- Use standalone model for helicopter.
- Place on runway model.
- Rename helicopter world
- Update to SDF version 1.11
- Add intermeshing dual rotor example.
- Add meshes.
- Increase friction on stabilizers.
- Correct orientation of tail rotor blade visual and collision.
- Correct dual heli control elements.
- Increase mass of base link for dual heli.
- Add params for dual transverse helicopter.
- Add gimbal for testing attitude control.
- Allow blades to flap on rotor heads
- This is essential for correct operation.
- Blades hinge at blade grips with range +/- 8 deg.
- Adjust blade flapping damping and spring constant.
- Remove oscillation / resonance when rolling at higher collective.
- Reduce blade hinge spring stiffness.
- Set ball joint properties
- Use gazebosim/gz-physics#753
- Set physics params in detachable joints
- Use gazebosim/gz-physics#754
- Use gazebosim/gz-sim#2960
- Adjust flapping hinge position
- Move hinge towards rotor hub.
- This position gives a flapping lag of about 80 deg behind the blade pitch.
- Retune ATC_RAT PIDs for flapping blades.
- Add visuals for frame and rotors
- Add mesh visuals based on TRex-450.
- Remove stabilising links and wheels.
- Reposition tail rotor to match rescaled model.
- Update rotor velocity command topic.
- Add config for the ros_gz bridge
- Retune model for adjusted CoM and tail position
- Add credit for visuals

Signed-off-by: Rhys Mainwaring <[email protected]>
srmainwaring added a commit to srmainwaring/SITL_Models that referenced this pull request Jul 3, 2025
srmainwaring added a commit to srmainwaring/SITL_Models that referenced this pull request Jul 3, 2025
@iche033
Copy link
Contributor

iche033 commented Jul 10, 2025

I thought about this, but decided it was a little overkill adding another 2 or 3 layers of nesting. It's also a little confusing as the engine in use is dartsim not ode, and here and in some other places fields from one engine are used in another. Keeping the fields flat is more in line with the reworked physics libraries strategy of using typelists of features - if a library supports a feature it uses it, otherwise it is ignored.

there was a proposal related to this in gazebosim/sdformat#508, which proposes that we move away from engine-specific tags.

@azeey azeey added this to the Jetty Release milestone Jul 28, 2025
@azeey azeey removed this from the Jetty Release milestone Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏛️ ionic Gazebo Ionic
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

5 participants