Gap between two objects when applying physics using replicator composer

Hello,

When applying physics with replicator composer I noticed there is a gap between 2 meshes with colliders enabled. I am attaching a video for reference and script as well to reproduce this issue.

Script:
temp.txt (414 Bytes)

Please help me understand if the problem reside in my system or it is a bug in replicator composer itself

Thanks,
Mayank

@ahaidu Can you please help me understand this?

Hello @mayank.ukani! I’ve shared your post with the dev team for further assistance.

@mayank.ukani,
in omni\replicator\core\ogn\python_impl\nodes\OgnWritePhysics.py of the Replicator 1.5.3 extension code, the code sets contactOffset to 2 and restOffset to 1

prim.GetAttribute("physxCollision:contactOffset").Set(2)
prim.GetAttribute("physxCollision:restOffset").Set(1)

I have not found an easy way to set those to a more appropriate value.
I had to create my own node and make sure it ran after setting the physics attributes using the OgnWritePhysics node.

There should be a way to set this properly. I would love to know how to do this as well.

my guess is that you use a set attribute, (physxCollision:contactOffset and physxCollision:restOffset) node after the physics node. I can’t recall if I tried this or not.

1 Like

Thanks, @mark148 for this!

I haven’t explicitly changed any contact or collision offsets. If you check the attached file, you will see that I am simply applying a rigid body to a prim. I don’t know if there is any internal call in that API that sets these offsets.

@mayank.ukani ,
Ya, the Replicator extension is setting contactOffset and restOffset to a hard coded default value of 2 and 1 respectively.
I tried using:

rep.modify.attribute("physxCollision:contactOffset", 0.2)

but that did not work.
I do not have a solution but am providing my understanding on that part of the extension code.

1 Like

Hi @mayank.ukani @mark148 , thanks for spotting that! We’ve fixed this and the fix will be published in the next release.

1 Like

Can you please provide the fix if it is okay to publish it open-source? I must generate data with physics applied to my prims to train a model. If not, how long will it take for the next release to publish?

Someone is having the same issue as you. Can you try the solution I posted in that post?

Thanks, @jiehanw for the reply. Unfortunately, I am creating multiple instances (100-200) for each frame so prim paths are always different and the number of objects as well

hmm then I think there is not a very convenient way for doing this. But the fix is merged and you can expect it in the next release.

@mayank.ukani

I had the same issue so I created a solution for myself and would like to share. I’ve made a repository with a custom node to help with this. The extension is not discoverable in Isaac Sim, so you’ll have to use Create 2022.3 for easy extension install.
You can also download from Release 1.0.0 · theory-studios/ov-helpers · GitHub and enabled it manually if you still want to use Isaac Sim.

Using Code 2022.3 In the extensions tab click on Third Party to get the community extensions, then do a search for theory.replicator.helpers
click on the extension, enable and auto load it.

then you can use as below:
Notes:

  • use with rep.utils.sequential() as it allows the nodes to be put in sequence otherwise it won’t work.
  • must be used after rep.physics.rigid_body()
  • tested in Code 2022.3 and works in Isaac Sim 2022.1.1
  • only tested on these attributes: physxCollision:contactOffset physxCollision:restOffset
  • helpers.modify.write_physics_attribute_float only accepts a float as the second arg, not another node or ReplicatorItem
  • no guarantee that it will work in all situations. It’s a straight forward custom node, but I have not thought of all scenarios of course. It’s just code that works for me.
import omni.replicator.core as rep

import theory.replicator.helpers as helpers

with rep.new_layer():
    cube = rep.create.cube(scale=0.01, position=(0, 0 , 2))
    with cube:
        with rep.utils.sequential():
            rep.physics.rigid_body()
            helpers.modify.write_physics_attribute_float("physxCollision:contactOffset", 0.02)
            helpers.modify.write_physics_attribute_float("physxCollision:restOffset", 0.01)