How to control the door using physics in Omniverse Creat or sim

Hi, I would like to open and close the 3D door naturally when I press the keyboard event I key using physics in the omniverse Create or Isaac sim.

Using the omniverse extension manager, I created the extension.py file in the visual studio code and created the code I wanted.

However, contrary to my expectation, on the omniverse Isaac sim, the door went down when I clicked the play button. I didn’t even press the keyboard event I key.

What I wanted was a toggle method that went up when I pressed the keyboard I key, and came down when I pressed the I key again.

I am still studying physics through the omniverse document. However, please take a look at the code I created. As shown in the video below, I just clicked on the play button, but if you could point out why the door went down, it would be very helpful to study my physics.
Please tell me how to raise and lower the door to the desired height. I’m not sure what I’m missing.

I added both Articulation Root and Rigid Body to tdoor_57.


Also, when I click the play button and press the keyboard event I key that I specified, the following error appears.

Hello @toni.sm
I would like to control the door using the physics you helped me with the other day.
However, the above-mentioned problems occurred and I opened up a new topic.
I’d really appreciate it if you could help me.

After seeing the physics example code you showed me, I’m studying about physics.
But it’s not easy yet. If you help me, it will be very helpful to study and organize the materials.
Thank you for your kindness.

When I ran Isaac Sim in omniverse-launcher, I received an error message about omni.isaac.dynamic_control_plugin.
I haven’t even loaded any usd files yet.
I think this is also an error related to the photo above.

Hi @gudwnzm

It seems like your extension omni.abcd.world is trying to load the articulation when the extension manager enable it. You need to make sure that your articulation is loaded after all USD assets are ready and the simulation is running, for example, using a button…

Regarding the physics, it seems to be the current configuration is not well defined. In this scenario your door must be a child rigid-body prim joined, using a prismatic joint, to other rigid body prim inside a root articulation parent prim, for example

Inspect how are distributed and configured the prims in the .USD shared in this topic the How to turn on/off the light or object in Omniverse Creat or sim - #16 by toni.sm

Hi @toni.sm
Thank you for your kind reply and help.
I will study and revise it as you told me.
I have a question.
In the previous topic, I changed the code you gave me as a door example to use in extension and applied it to isaac sim.

And the result of isaac sim is that even though I didn’t press the keyboard event I like the video above, the door goes down every time I press play.
Even though the door example code you gave me goes up.

Why does this happen when the door goes down as soon as you run play? Please help me make the door go up, and if I press I, the door goes up, and if I press again, help me make the toggle key that goes down.

Thank you very much for always helping me despite your busyness in answering many people.

Hi @gudwnzm

The problem of the door going down when pressing the play button seems to be related to a wrong configuration of the joints, articulations and prims involved. That is why I insisted on inspecting the example .usd I posted in the other topic.

Could you provide a minimum .usd where the problem is evidenced or describe, in detail, how is the prims hierarchy and its articulation and joints configuration?

Hi @toni.sm

First of all, thank you for your reply and I’m sorry for the late reply.

I will make the door as minimum .usd and attach it with a screenshot.
I still haven’t solved this problem.
I have difficulty setting the points, articulations and primes to open and close the door with the code you gave me.

tdoor_1_window.usd (174.4 KB)
tdoor_2_window.usd (193.7 KB)

I usually use isaac sim to execute the code you gave me. This screenshot was taken by create to provide usd files.

Hi @gudwnzm

Here you can find an example that set the articulation, joint, and prims to open/close your door (real_door).
The idea is to create an articulation prim, with your door (joined to another prim “frame” by using a prismatic joint) and a frame (fixed with respect to the articulation prim) as shown in the image. Both, the door and the frame are rigid bodies. The root joint has only configured one body: the frame

door_real.usd (179.4 KB)


The code con control the new door is the same :)

import pxr
import carb
import omni
import omni.usd
from omni.isaac.dynamic_control import _dynamic_control

opened = False

# left door (prim attributes)
stage = omni.usd.get_context().get_stage()
left_door = stage.GetPrimAtPath("/World/left_door/door")

# right door (articulation)
dc = _dynamic_control.acquire_dynamic_control_interface()
ar = dc.get_articulation("/World/right_door")
dof = dc.get_articulation_dof(ar, 0)

# real door (articulation)
dc = _dynamic_control.acquire_dynamic_control_interface()
ar_real_door = dc.get_articulation("/World/real_door")
dof_right_door = dc.get_articulation_dof(ar_real_door, 0)


def keyboard_event(event, *args, **kwargs):
    global opened

    if event.type == carb.input.KeyboardEventType.KEY_PRESS:
        if event.input == carb.input.KeyboardInput.P:
            dc.wake_up_articulation(ar)
            dc.wake_up_articulation(ar_real_door)
            # close
            if opened:
                left_door.GetAttribute("xformOp:translate").Set(pxr.Gf.Vec3d(0,0,0))
                dc.set_dof_position_target(dof, 0)
                dc.set_dof_position_target(dof_right_door, 0)
            # open
            else:
                left_door.GetAttribute("xformOp:translate").Set(pxr.Gf.Vec3d(0,0,195))
                dc.set_dof_position_target(dof, 195)
                dc.set_dof_position_target(dof_right_door, 265)
            opened = not opened
 
# subscribe to keyboard event
appwindow = omni.appwindow.get_default_app_window()
input = carb.input.acquire_input_interface()
input.subscribe_to_keyboard_events(appwindow.get_keyboard(), keyboard_event)

1 Like

Hi @toni.sm

Thank you very much for your kind examples and answers.
I will learn and use the examples and codes you gave me and apply them to a large .usd that has a lot of my doors.
Thank you so much.

I want to use the example and code you provided to create a door and a new cube, put the physics properties in the cube, and see the result of the physical collision.

I tried to create a cube and put the Rigid body in, but it went down through the ground. So I created a collider, but there was no conflict.
I don’t know much about physics yet, but what should I do to see the results of these physical collisions?

Hi @gudwnzm

Make sure all target prims (or shapes/meshes) have the collision property set. You can visualize the collision using the Element Visibility menu as shown in the image

Hi @toni.sm


I wanted to see a physical collision like the video above, so I put a collider in target prims as you showed me in the example.

How can I use the example and code you gave me to experience a natural physical collision between my door and cube like a video above?

Mmmm, can you modify the collider attributes: contact offset and rest offset and set them, for example, to 0?
Stop the simulation, change them, an start the simulation again

Screenshot from 2022-03-25 10-15-03

@toni.sm

Do you mean the same thing as a screenshot?
As shown in the screenshot, there is no conflict if I change contact offset and rest offset from trackduck_board_320 and cube to 0 or other numbers.
Am I missing a rigid body or something?


Mmmm, even without changing the collider’s attributes it should work…
Could you share your testing .USD?

door_real_collider.usd (179.8 KB)

@toni.sm

I removed the left and right doors from the door_real.usd you provided me last time and proceeded only with the real_door.

The usd file you provided just now causes a conflict. Thank you very much. I have a question.
Can you tell me in the video why you changed the Target Position from the Drive property of prismaticJoint?

Because the contact offset and rest offset setting you mentioned in the above question seems to be set to default in the door_real_collider.usd you provided.

I changed the target position from 0 to 200 to start with the door open. Then, I show the collision when I try to close the door (target position to 0).

1 Like

Hi @toni.sm
Thank you for your kind response.
Thanks to you, my studies are improving.
If you don’t mind, I’ll ask you another question next time.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.