How to see the real-time screen while Python is running

I am running Python, for example: set a Cube rotation, the 3D screen will directly give me the result of the rotation, without the process of rotation. Hope to see the rotation process in 3D view.Hope I can get some help, thanks.

Hi @fsb0147 - To see the rotation process in the 3D view, you need to animate the rotation over time. This can be done by setting up a loop that gradually changes the rotation of the cube and then updates the scene.

Here is a simple example of how you might do this in Python:

import time
from omni.isaac.dynamic_control import _dynamic_control
dc = _dynamic_control.acquire_dynamic_control_interface()

# Assuming cube_prim is the prim of your cube
cube_handle = dc.get_rigid_body("/World/cube")

for i in range(100):
    # Compute the new rotation
    new_rotation = Gf.Rotation(Gf.Vec3d(0, 0, 1), i)

    # Set the rotation of the cube
    dc.set_rigid_body_pose(cube_handle, Gf.Vec3f(0, 0, 0), new_rotation.GetQuaternion())

    # Update the scene

    # Wait for a short time before the next update

This script will rotate the cube around the Z-axis over the course of 1 second. You can adjust the range of the loop, the rotation calculation, and the sleep time to get the effect you want.

Hi,@rthaker Thank you for your help, I copied the code, but it doesn’t work, as shown in the picture, I don’t know why. In addition, I have another question, if my cube_handle = dc.get_rigid_body(“/World/Xform/cube”), will it take effect? I want to control the whole Xform rotation.

according to set_rigid_body_pose, you need to use a transform. Convert your position and rotation with the following

q = new_rotation.GetQuaternion()
t = dc.Transform()
t.p = [0,0,0]
t.r = [q.x, q.y, q.z, q.w]

then call dc.set_rigid_body_pose(cube_handle, t)

@rgasoto I’m very sorry, he still prompted an error,

“2023-09-14 09:14:05 [Error] [] [py stderr]: AttributeError: ‘omni.isaac.dynamic_control._dynamic_control.Dynami’ object has no attribute ‘Tansform’”

Sorry, I had a typo on my code, It should be dc.Transform()… I updated it in the original snippet too

2023-09-25 02:31:07 [Error] [] [py stderr]: AttributeError: ‘omni.isaac.dynamic_control._dynamic_control.Dynami’ object has no attribute ‘Transform’

This kind of error still exists. Could you please provide me with a complete code study?

from pxr import Gf
from omni.isaac.dynamic_control import _dynamic_control
import time
import asyncio
#Assuming cube_prim'is the prim ofyour cube|
cube_handle = dc.get_rigid_body("/World/Cube")
async def run():
    for i in range (100):
        new_rotation = Gf.Rotation(Gf.Vec3d(0, 0, 1), i)
        q = new_rotation.GetQuaternion()
        v= q.GetImaginary()
        t = _dynamic_control.Transform()
        t.p= [0,0,10]
        t.r = [v[0], v[1], v[2], q.GetReal()]

        # Set therotation of the cube
        dc.set_rigid_body_pose(cube_handle, t)
        # Wait for a short time before the next update