Hi @gudwnzm
You can do it from different approaches, for example: editing the attributes of a prim and modifying its transformations or involving physics, through rigid bodies, joints (prismatic joint) and articulations (dynamic_control extension). While the former is simpler, the latter is more natural…
Here is a snippet that shows both approaches in a scenario with two doors: left (prim attr) and right (dynamic_control). Look inside the .usd to inspect the rigid bodies, the articulation and the joint
door.usd (4.5 KB)
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)
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)
# close
if opened:
left_door.GetAttribute("xformOp:translate").Set(pxr.Gf.Vec3d(0,0,0))
dc.set_dof_position_target(dof, 0)
# open
else:
dc.set_dof_position_target(dof, 195)
left_door.GetAttribute("xformOp:translate").Set(pxr.Gf.Vec3d(0,0,195))
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)