Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Suggestion / Idea  ArticulationBody support
#1
Hey there, 

I'm not sure if you are aware of the new type of rigidbody: ArticulationBody. It's discussed in greater detail here: https://forum.unity.com/threads/feathers...ns.792294/

It's basically a new way of having super stable hierarchical joints for robotics and similar applications. I tried it with ObiRope and unsurprisingly, static interaction works. But I guess thats just the same as moving the transform of any collider with an ObiCollider component attached.

The API is similar to the one provided by the RigidBody, you can add torques and forces and read velocity and angularVelocity. Directly adding to the velocity or angularVelocity like it's done in ObiRigidbody is not possible because they're only getters.

I also tried to get working that the Rope is dragged along the surface of moving ArticulationBody. For that, I copied ObiRigidbody to a new ObiArticulationBody class and removed the code from UpdateVelocities(). Finally I added a method overload for Oni.Rigidbody.Set(UnityEngine.ArticulationBody) (in Oni.cs), that reads the velocity and angularVelocity and removed the rotation axis constraints code.

Code:
public void Set(UnityEngine.ArticulationBody source, bool kinematicForParticles){

    bool kinematic = !Application.isPlaying || kinematicForParticles;

    rotation = source.transform.rotation;
    linearVelocity = kinematicForParticles ? Vector3.zero : source.velocity;
    angularVelocity = kinematicForParticles ? Vector3.zero : source.angularVelocity;

    // center of mass in unity is affected by local rotation and position, but not scale.
    // We need it expressed in world space:
    centerOfMass = source.transform.position + rotation * source.centerOfMass;

    Vector3 invTensor = new Vector3(
        1/source.inertiaTensor.x,
        1/source.inertiaTensor.y,
    1/source.inertiaTensor.z);

    // the inertia tensor is a diagonal matrix (Vector3) because it is expressed in the
    // space generated by the principal axes of rotation (inertiaTensorRotation).
    inertiaTensor = kinematic ? Vector3.zero : invTensor;
    inertiaRotation = source.inertiaTensorRotation;
    inverseMass = kinematic ? 0 : 1/source.mass;

}

However, the rope that I put on top of a moving Cube is not dragged along. Any ideas?
Reply


Messages In This Thread
ArticulationBody support - by fiasko - 26-03-2020, 11:45 AM
RE: ArticulationBody support - by josemendez - 26-03-2020, 12:29 PM
RE: ArticulationBody support - by fiasko - 26-03-2020, 02:01 PM
RE: ArticulationBody support - by josemendez - 26-03-2020, 04:30 PM
RE: ArticulationBody support - by fiasko - 26-03-2020, 04:49 PM
RE: ArticulationBody support - by josemendez - 26-03-2020, 04:55 PM
RE: ArticulationBody support - by fiasko - 26-03-2020, 09:54 PM