Use omniverse api to add camera in scene got rotation problem

i’m using the code below to create a camera, i set up the position and rotation tags, and then i find that a Camera_Xform is created, and a Camera instance is under it. For this step there’s no problem, and the position is only set to Camera_Xform, this also has no problem, but!! the rotation is set up to both Camera_Xform and Camera instance, which means that the camera is rotated twice, why and how to solve this problem?

camera = rep.create.camera(position=(4.0, 0, 1.0),rotation=(90,0,90),focus_distance=rep.distribution.normal(400.0, 100),f_stop=0)

Hi @baikaixin. I am not able to reproduce that. When I run that in Code-2022.3 or Code-2022.2, I don’t see any Transform properties on the Camera prim. Which app are you using?

Hi @mati-nvidia . I’m currently using isaac sim 2022.2.0. With the code “camera = rep.create.camera(position=(0.0, 0.0, 2), rotation=(0, 0, 0))”, we could find that the camera instance is created and the translation and rotation of the Camera_Xform is defined as what we expected. But if you go into the Camera instance under the Camera_Xform, you could easily find that the rotation is 90,0,90, which may lead to a wrong rotation, because the created camera has rotated twice.


image

Ah, I see. I’ve moved this to the SDG forum where hopefully someone from the Replicator team can comment about that API.

I tried to change the rotation of the camera to (0,0,0) using Pixel’s API or isaac sim replicator API, but I failed. I found that when I combined the camera creation code and the code to change the rotation using the prim path in a single Python file, the modification failed because the camera couldn’t be found through the prim path. However, if I split my code into two separate Python files - one for creating the camera and another for finding the camera through the prim path and modifying the rotation - then it works. However, I don’t want to split my code into multiple files and run them separately. Is there any way for me to immediately modify the incorrect rotation to (0,0,0) after creating the new camera? p.s. even if i set a sleep code between the creation and modification, it didn’t work.

Hello,

I believe this might be due to your world-up being different in Isaac Sim than the default Omniverse/USD UpAxis.

When the UpAxis is different, Replicator will apply a 90 degree rotation so that the camera appears correct when viewed (camera frame up being world-up)

If you want to reset the rotation to be truly (0,0,0) then you could use this example code as a start:

camera = rep.create.camera()

with camera:
    rep.modify.attribute('xformOp:rotateXYZ', (0, 0, 0))

But that might give you undesirable visual results

Thanks for your reply! But it doesn’t work.
with the code you offered as below, only the Xform’s rotation is changed, as i mentioned above, the problem is to change the rotation the the camera instance under the Camera_Xform tree.

>>> import omni.replicator.core as rep
... camera = rep.create.camera(position=(0.0, 0.0, 2), rotation=(1, 0, 0))
... with camera:
...     rep.modify.attribute('xformOp:rotateXYZ', (0, 0, 0))