Softbody states

Hi, I am wondering if there is a way to get the state of a certain softbody. e.g. location of a vertex. I do noticed "Gym.acquire_particle_state_tensor"method returns a [n x 11] tensor, yet what does that mean? And how can I get the state for a particular actor? The documentation of such state and functionality is a must-have feature for RL with softbodies.

The soft body functionality is very much a work in progress - it currently works only with the Flex physics back-end, and with the CPU pipeline. While we may update it and add more documentation in a future update, our focus for soft body work is more likely to be using PhysX based simulation inside Omniverse.

If you do want to try it out as-is, here’s some background:

The tensor contains all the particles in the simulation. For each particle, the 11 values are position, velocity, and normal:
(p.x, p.y, p.z, p.w, v.x, v.y, v.z, n.x, n.y, n.z, n.w)

The particle states of each actor are written to the tensor in the same order as the actors were created. Unfortunately, in the current release there is no method to retrieve the offset of an actor’s particles in the tensor.

So to figure out the offset of each actor’s particles right now, you would need to know the number of particles that each actor has and keep a running total as you add actors during simulation setup.

Hi @buoyancy99,

FYI a research sample that shows the use of the soft-body APIs is available now: GitHub - NVlabs/DefGraspSim: This package provides a framework to automatically perform grasp tests on an arbitrary object model of choice.

We still aren’t likely to have more formal documentation for these APIs until the Omniverse transition is done however.

Take care,
-Gav

Hi @gstate, one last question related to this problem. I tried to find the info in the documentation regarding isaacgym.gymapi.SoftContact and it says:

Returns: :obj: list of isaacgym.gymapi.SoftContact: Contact information for the simulation

Can you provide some more info about this list? That would be really helpful. Thanks alot!

You can run help(gymapi.SoftContact)to get a list of the attributes and their meaning:

 |  Data descriptors defined here:
 |
 |  bodyIndex
 |      Body index (global)
 |
 |  env0
 |      Environment contact body0 belongs to, -1 if it is shared/unrecognized env
 |
 |  env1
 |      Environment contact body1 belongs to, -1 if it is shared/unrecognized env
 |
 |  lambda
 |      Contact force magnitude
 |
 |  normal
 |      Contact normal from body0->body1 in world space
 |
 |  particleBarys
 |      Particle barycentric coords (for triangle collision)
 |
 |  particleIndices
 |      Particle indices (global
3 Likes

Thanks alot! @milesmacklin

Hello. I have been tring to use the get_soft_contacts() function.
When I iterate over the returned SoftContact array elements, I do not completely understand how they relate to the list of SoftContact attributes, as they are documented in the Preview 3 API.

Specifically,

soft_contacts = gym.get_soft_contacts(sim)
    for soft_contact in soft_contacts:
        print("soft_contact (bodyIndex: {}) = {}".format(soft_contact[0], soft_contact))

would give:

soft_contact (bodyIndex: -1) = (-1, -1, (189, 319, 317), (0.73, 0.27, 0.), 3, (-0.15, 0.25, -0.88), (4.41e-05, 0.3, -0.95), 8.39e-06, 0.01
soft_contact (bodyIndex: -1) = (-1, -1, (20, 19, 18), (0.22, 0.78, 0.), 1, (0.11, 0.25, -0.88), (-3.99e-05, -0.18, -0.98), 5.76e-06, 0.01)
soft_contact (bodyIndex: -1) = (-1, -1, (30, 27, 26), (0., 0.88, 0.12), 1, (-0.13, 0.25, -0.88), (-7.44e-05, -0.42, -0.91), 9.09e-06, 0.01)

I understand that the two first -1 might be env0 & env1, but I am not completely sure about the rest of the variables.

The output refers to a soft contact environment similar to the soft_body.py IsaacGym example, but instead of top-down pressing the body, it pushes it along the z axis by controlling the prismatic joint position target.