Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Bug Articulation Bodies appear to be broken with 0 damping?

Discussion in 'Physics Previews' started by ArunasProk, Nov 24, 2021.

  1. ArunasProk

    ArunasProk

    Joined:
    Mar 21, 2020
    Posts:
    13
    Either I'm missing something obvious (which I find more likely), or articulation bodies are fundamentally broken.

    Use case:
    We are simulating robotics in space, so articulation bodies sound appealing, but they fail even the most elementary tests.

    Specifically, suppose you have an object with a non-uniform (!(x==y==z)) tensor and try to apply torque on more than one axis. In that case, the simulation breaks apart as the object starts to accelerate endlessly. Damping can counter this, of course, but this is very iffy since we need high precision.

    The easiest way to reproduce this is to create two cubes:
    1. Immovable cube that acts as a root.
    2. Add a child cube scaled on one axis (to modify the tensor) and has 0 damping.
    + Attach it at an angle with a spherical joint, so it starts swinging on more than one axis.

    With 0 damping/friction, I'd expect the swinging to stabilize. Instead, it keeps accelerating until one of the values reach angular velocity limits (way more evident after increasing the limit in project settings):

    Animation.gif

    We observed similar behaviour when adding a free-floating (no gravity, no damping) and briefly applying torque on two axes. Instead of just spinning in place, it keeps accelerating and eventually flies offscreen.
     
    ClementVirat likes this.
  2. AlanMattano

    AlanMattano

    Joined:
    Aug 22, 2013
    Posts:
    1,501
    Is not good becuse presition is low. For performance
    Esperiment with adding more presition for the RB. This will be less perfomant but more accurate.
    Play with RB options

    "Interpolation" allows you to smooth out the effect of running physics at a fixed frame rate.

    In the joint
    For example actually Collition is discret. What happened if you add other option?

    Also too little or too much mass has destructive consecuences.

    CONCLUTION
    Play with "Collision Detection" and "Interpolate"

    Link: https://docs.unity3d.com/Manual/class-Rigidbody.html
     
    Last edited: Nov 24, 2021
  3. JuozasK

    JuozasK

    Unity Technologies

    Joined:
    Mar 23, 2017
    Posts:
    84
    Spherical joints are a well of problems that keeps on giving. Currently, they suffer from issues like what you have seen, cases where it should work, reach a balance, end up springing out of control with no apparent reason. And this instability comes from within PhysX itself. What we recommend in these situations is to use multiple Revolute joints per axis instead of a single spherical joint. This should vastly increase stability, albeit it requires a little more setup
     
    Edy likes this.
  4. ArunasProk

    ArunasProk

    Joined:
    Mar 21, 2020
    Posts:
    13
    If it was just the joints, we could work around it, but the issue appears to be the articulation body itself.

    Take a simple cube scaled to 1:1:5 (to get uneven tensors), disable gravity/damping, apply some velocity or torque on two axes and it starts accelerating:

    Test.gif

    Test script:
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class ArticulationTest : MonoBehaviour {
    4.     [SerializeField] private float angularVelocity;
    5.     [SerializeField] private bool applyAsTorque;
    6.  
    7.     private ArticulationBody _body;
    8.  
    9.     private void Start() {
    10.         _body = GetComponent<ArticulationBody>();
    11.      
    12.         // same behaviour with lower limit/values, just less obvious.
    13.         _body.maxAngularVelocity = 20;
    14.      
    15.         if (applyAsTorque)
    16.             _body.AddTorque(new Vector3(0, 150, 30));
    17.         else
    18.             _body.angularVelocity = new Vector3(0, 3, 3);
    19.     }
    20.  
    21.     private void Update() => angularVelocity = _body.angularVelocity.magnitude;
    22. }
     
  5. JuozasK

    JuozasK

    Unity Technologies

    Joined:
    Mar 23, 2017
    Posts:
    84
    Hmm, could you report a bug on this and attach the repro project? We'll take a deeper look at it then.

    Thanks for taking the time to notify us! :)
     
  6. ArunasProk

    ArunasProk

    Joined:
    Mar 21, 2020
    Posts:
    13
    Done.
    (Attaching the repro project here too, just in case anyone else wants to poke around at some point.)
     

    Attached Files:

    JuozasK likes this.
  7. MalekMC

    MalekMC

    Joined:
    Nov 25, 2016
    Posts:
    13
    Damping also seems to be broken, I have a game object with has linear and angular damping. When starting the game the damping is basically non existent, if I change these values in the editor by let's say 0.01%, then they start affecting the game object behavior, as if there was no damping before this change.
     
    ClementVirat likes this.