Skip to content

mju_springDamper damping regime depends on time units #3521

Description

@Vedangalle

Description

mju_springDamper selects the overdamped, critically damped, or underdamped solution using a fixed absolute tolerance on the characteristic discriminant. This makes the returned trajectory depend on the chosen time units.

For the system

x'' + Kv*x' + Kp*x = 0,

rescaling time by a positive factor s transforms the inputs as follows while preserving the same position trajectory:

  • vel0 -> s*vel0
  • Kp -> s^2*Kp
  • Kv -> s*Kv
  • dt -> dt/s

Reproduction

With pos0=1 and vel0=0, these two calls describe the same system under different time units:

  • Kp=0.025, Kv=1, dt=10 returns 0.7946142382307649.
  • With s=1e-8, Kp=2.5e-18, Kv=1e-8, dt=1e9 returns 0.0404276819945128.

Both should return 0.7946142382307650, the analytical overdamped solution.

Cause

The scaled discriminant is Kv^2 - 4*Kp = 9e-17. The current fixed comparison against +/- mjMINVAL classifies it as critically damped even though the equivalent unscaled system is overdamped.

Expected behavior

Damping-regime selection and the returned position should be invariant to a consistent change of time units. A relative tolerance scaled by the discriminant terms preserves the existing near-critical safeguard without changing the public API.

I have a small patch with analytical coverage for all three damping regimes and a regression test for the time-scaling property.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions