Search Unity

Bug multi hinge joint disorientation during large angular impulse

Discussion in 'DOTS Physics' started by Sab_Rango, Apr 1, 2021.

  1. Sab_Rango

    Sab_Rango

    Joined:
    Aug 30, 2019
    Posts:
    100
    Case _1326044

    In DOTS physics from the second hinge joint, any applied large angular impulse brakes the the joint's limited rotation angle and transformation.



    In the 4a.Joints parade scene, I showed those buggy hinge joints with red material. Also, in the attached video, I demonstrated how this bug happens when I add torque via clicking "Space button".



    Interestingly, in some cases, there no such bug condition with the joints.
    I marked these objects with green material. Specifically, I debugged this condition with physics settings' Gizmos, and I noticed that when a collision trigger event happens between hinge joint and its parent collider, the bug does not appear even they do not collide with each other .



    So, I think this joint bug's main issue is that there is no any "narrow phase" solver in the joint solver. Since, when they overreach their limited angle, the solver cannot find when the joint reached its limit.
    As a result, it miscalculates the limitovercross deltatime response.



    I am making this decision, because this bug is not happening when there is a collision trigger between hinge joint and its parent collider before the joint reaches its angular limit.

     
  2. milos85miki

    milos85miki

    Joined:
    Nov 29, 2019
    Posts:
    197
    Hi @Sab_Rango , could you please create a minimal repro project (probably a single robot body with 1 leg that's problematic) and attach it to the case?
    It's very useful to have a minimal set of objects to reproduce the problem and be able to concentrate on them while debugging. I cannot check the case you opened at the moment, sorry if you already did that.
     
  3. Sab_Rango

    Sab_Rango

    Joined:
    Aug 30, 2019
    Posts:
    100
    Hello!

    here the asset folder of the project with 4 root bodies.

    the scene is "4a.Joints parade"


    here the video



    I was just learning joint system, and faced this condition.
    But my main aim is to create muscle joint system for ML agents.
    And what I noticed after observing animal anatomy physics is that we need different torque physics smth like Inverse Kinematics .




    In picture, the animal leg 1) " floats in the air" vs 2)" touches the ground " which corresponds like FK and IK solver for physics engine IkwithDk.png


    This is quite interesting situation :). When the animal legs touches the ground with gravity force, the red muscle force should be not be added via usual Toque by parent of the leg. Since body weight completely blocks the the angle and changes the direction of muscle force to revered direction (works like IK).


    Anyway, this is what I explored so far. I just noticed this buggy case with angular impulse. However, I am alot more curious to create new ways of solving physics for animal muscle interactions.
     
  4. milos85miki

    milos85miki

    Joined:
    Nov 29, 2019
    Posts:
    197
    The case with angular impulse and joint going nuts is because the body gets angular velocity along axes y/z and then applying new impulse makes the constraint violated so much that it can't recover.
    We're investigating further to see if we can recommend something that would make this more stable (maybe not having bodies in a hierarchy or similar).
     
  5. milos85miki

    milos85miki

    Joined:
    Nov 29, 2019
    Posts:
    197
    Hi @Sab_Rango , could you please try with a slightly different LimitedHinge setup (0-180 deg, perpendicular axis Y), like this:
    limited_hinge_setup.png

    Please note that lower limbs may collide with static "torso" and get the inconvenient angular movement leading to constraint violation on next angular impulse. So, it'd be good to make sure they don't collide with "torso" via filters.

    Big thanks to @steveeHavok for help on this!
     
  6. Sab_Rango

    Sab_Rango

    Joined:
    Aug 30, 2019
    Posts:
    100
    Hello!
    I have tried, still whenever the joint collides while large torque applied, joints position breaks the rules.
    I mean I can not just set filters to 2nd neighbor colliders to avoid the collision, since they are supposed to collide with them to create real time new constrained system.

    On the hand, I am doing my best to create my own simple joint solver for muscle system.
    I think it's better to use the engine's custom collision system and do the artwork.
    Because this muscle joint system is much more trials and fixing errors of only "collision response".

    Anyway, thank for help!
     
  7. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    480
    You can also help the iterative solver converge to a stable solution (even after these extreme violations) by increasing the 'Solver Iteration Count' in the 'Physics Step' component. 5 worked ok in your scene but 6 was really stable in my tests.
    upload_2021-4-9_11-54-8.png
     
  8. Sab_Rango

    Sab_Rango

    Joined:
    Aug 30, 2019
    Posts:
    100
    Hey!
    In my joint system, changing the Solver Iteration Count could not stop violation of limited DOF.


    I think muscle system requires smth like Double TORQUE solver rather than single torque in one entity.

    For instance, 2 objects: A and B that was connected each other are floating in the air. These is a muscle fiber between A and B(shown as a red line)
    staticmassmuscle.png


    Now lets add some torque for B object. if the B object is 10000x mass of A (like 2-case), generated force of the muscle fiber will move only object A as if the torque added to object A even we added torque to object B.
    Since here B behaves as if a static object.

    here , how it behaves in the physics engine.



    I am adding torque only RED object,
    1st pair 1000x vs 1x mass ratio
    2nd pair 1x vs 1000x mass ratio


    As you can see in the video 2nd slowly moving red object(which has 1000x mass) is not real life muscle simulation.
    If it was real life physics, the muscle force would rotate only 1x mass object , then , the 1000x red object would behave like static object in the real world muscle physics.



    That's just what I believe how the muscle system should be solved, and not to use simple one sided torque physics for muscle system simulation
     
unityunity