Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Articulation body getJointForce always zero

Discussion in 'Physics' started by EdwinBabaians, Dec 30, 2020.

  1. EdwinBabaians

    EdwinBabaians

    Joined:
    Nov 4, 2018
    Posts:
    5
    Hello all,

    I have been working with the new articulation body feature of Unity for a while and I want to simulate the torque sensors behavior in each joint, which basically is the current force applied on the joint.

    I found several properties like position, velocity, acceleration, and force. The problem is the joint force value is always zero.

    Does anybody know, why is this like that or is there something which I need to do in order to get the force measurement available in the articulation body?

    The example of code which I am reading the force values:
    Code (CSharp):
    1. float currentRotation = articulation.jointPosition[0];
    2. float currentVel = articulation.jointVelocity[0];
    3. float currentEffort = articulation.jointForce[0];
     
    ZiadJ likes this.
  2. Kenmuir

    Kenmuir

    Joined:
    Jan 8, 2019
    Posts:
    3
    Hey have you figured anything out yet?
     
    EdwinBabaians likes this.
  3. EdwinBabaians

    EdwinBabaians

    Joined:
    Nov 4, 2018
    Posts:
    5
    Hi,

    I have tested with version 2021.2 alpha 13. The official documentation from Unity3D for "ArticulationBody.GetJointForces" is here. I have tried it and the force list array is always zero.

    Code (CSharp):
    1. List<float> forces = new List<float>() ;
    2. ArticulationBody body = GetComponent<ArticulationBody>();
    3. int f = body.GetJointForces(forces);
    4. print(forces[0]);
    If anyone has any updates on this problem, I would glad to hear.
     
    ZiadJ likes this.
  4. EdwinBabaians

    EdwinBabaians

    Joined:
    Nov 4, 2018
    Posts:
    5
    It seems the Physx 4.1 implementation in Unity3D is still missing some functionalities such as "Inverse Dynamics". For sure the low-level functionality from Nivida Physx has already implemented the force feedback for the new articulation body component and I am wondering why still we don't have it on the Unity3D side.

    Code (CSharp):
    1.  
    2. // Example from Physx 4.1
    3. PxReal maximalJointForces[NbLinks*6]; //There are 6 dofs (x,y,z,twist,swing1,swing2) per link
    4. articulation->unpackJointData(cache->jointForces, maximalJointForces);
     
  5. MrJohnWeez

    MrJohnWeez

    Joined:
    Aug 31, 2013
    Posts:
    11
    I find it odd that the function in Unity 2021.1.9 still always returns 0. Why would they include such a function if they have no current plans on implementing it.

    I don't believe there is a way to even calculate it yourself from the information given in a articulation body
     
  6. AetherBiomedical

    AetherBiomedical

    Joined:
    Jul 16, 2021
    Posts:
    1
    I suppose you can calculate it from the equation: Effect = stiffness * (drivePosition - targetPosition) - damping * (driveVelocity - targetVelocity)
     
  7. JuozasK

    JuozasK

    Unity Technologies

    Joined:
    Mar 23, 2017
    Posts:
    84
    Hey!
    The jointForce property and the GetJointForces method only return the forces you applied to the articulation yourself.

    For a use case of a torque sensor I believe the driveForce from the Inverse Dynamics update should do the trick.
    https://forum.unity.com/threads/inverse-dynamics-for-articulation-bodies.1198696/

    AetherBiomedical correctly pointed out that you can calculate this value from the Drive settings, but the drive Force property just makes it easier to grab.