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
#2
(26-03-2020, 11:45 AM)fiasko Wrote: 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;

}

Hi,

I'm aware of the new articulated bodies. We've yet to decide what we'll do regarding support, seems doable, save for two-way interaction.

But at the same time, the Unity Physics engine (DOTS) also needs to be supported, and Havok. Supporting each of these requires to invest a lot of time, and I feel it's still pretty unclear the role each one will play. People might adopt DOTS as the default, go-to physics solution, the built-in PhysX integration might linger around for quite some time (or not), may be replaced by Havok, or all 3 could coexist. Also PhysX 5 will be released soon with built-in FEM and particle physics support, I wonder if Unity will adopt it (they're still integrating Physx 4, so it may pay off for them to jump to 5 directly)... it all adds up to a confusing and uncertain future.

Once things clear up a little bit we will decide where to put our efforts. For the time being, we're porting the core engine of Obi to Burst+Jobs, for future-proofing, better platform support, as well as tighter integration with Unity:
http://blog.virtualmethodstudio.com/2020...nds-burst/

(26-03-2020, 11:45 AM)fiasko Wrote: However, the rope that I put on top of a moving Cube is not dragged along. Any ideas?

How are you moving the cube? If you're simply changing its transform, remember that this is basically "teleporting" as far as the physics engine is concerned. No friction will be applied whatsoever. If using forces/impulses or setting its velocity, it definitely should drag the rope along.
Reply
#3
thanks for the quick reply!

The cube is moved by the physics engine: I added an immovable object with the aforementioned cube attached using a prismatic joint. The cube is moving back and forth around its equilibrium point. I also added a high friction material.

When I debug into the Set() function that I created, I can see that velocity and angularVelocity are set inside the struct.
Reply
#4
(26-03-2020, 02:01 PM)fiasko Wrote: thanks for the quick reply!

The cube is moved by the physics engine: I added an immovable object with the aforementioned cube attached using a prismatic joint. The cube is moving back and forth around its equilibrium point. I also added a high friction material.

When I debug into the Set() function that I created, I can see that velocity and angularVelocity are set inside the struct.

What value is being set for velocity (source.velocity)? As long as it's not zero, friction should kick in.
Reply
#5
Yes, the velocity is being set. I stopped in the debugger to check.

   
Reply
#6
(26-03-2020, 04:49 PM)fiasko Wrote: Yes, the velocity is being set. I stopped in the debugger to check.

What's the mass of the body, relative to a particle in the rope? All impulses in a contact, including frictional impulses, take masses into account. So if the mass of the body is relatively small compared to the rope, most of the friction impulse would be applied to the body (and lost, since you can't set the body velocity directly).

Try forcing the inverseMass to zero (line 270 in your pic). This would make Obi believe the body has infinite mass, so all the frictional impulse should be applied to the particle.

That's the only possible cause that comes to mind. If it doesn't work, from this point on I'd probably have to test and debug it myself, which can take a few days since I have a lot on my plate right now.
Reply
#7
Thanks for your help, I'll test some more tomorrow with your suggestion. In case I don't get anywhere I'll take the liberty to provide a test project for you with my (flawed) code already in place. But concerning the whole issue, there is no rush on my side for this Sonrisa
Reply