How do I set camera rotation in Issac Sim Python standalone app?

Hi,

I’m currently using Isaac Sim Python 2022.2.0.

I would like to know how to adjust the rotation property of the camera, which can be seen on the screenshot:
image

However, I could only set the camera_position.
How can I set the initial camera rotation to [7, 0, -90] in Python standalone app?

My code is:

class MyEnv(gym.Env):
    # ...
    def set_initial_camera_params(self, camera_position=[22, 35, 220], camera_target=[0, 0, 0]):
        from omni.isaac.core.utils.viewports import set_camera_view
        set_camera_view(eye=camera_position, target=camera_target, camera_prim_path="/OmniverseKit_Persp")
    # ...

Hi @j.moon - If possible, I would suggest to update the Isaac Sim with the latest Isaac Sim 2022.2.1 release.

I will assign the question to the right dev and he should be able to answer your question.

Hi j.moon,

The viewport uses /OmniverseKit_Persp prim. Please, try setting the pose of that prim. Adjusting the position and rotation of that prim should change the position of the camera that is used to render the viewport.

Note, it looks like you are modifying the viewport position, instead of working with Isaac Sim camera API. In Isaac Sim, a standard approach is to work with the cameras/sensors, instead of the viewport, which is designed for GUI. An introduction to that approach is available here: Camera — isaacsim 2022.2.1 documentation

Thanks!

Hi, I found the similar problem with you, and I wrote a pose of it, hope it can help you out.
Maybe you can check this out.

Solution

According to the discussion in the form, I think its a designed mechanism to automatically keep the same camera coordinate system(+Y up) across different USD files.

And if you want to cancel this “auto-rotation” effect, you can use camera_axes="usd" args in set_world_pose().

from omni.isaac.sensor import Camera
camera = Camera(
    prim_path="/World/camera",
    position=np.array([0, 0, 0]),
    orientation=np.array([1, 0, 0, 0]),
)
camera.set_world_pose(np.array([0, 0, 0]), np.array([1, 0, 0, 0]), camera_axes="usd")
my_world.step(render=True)

This way, the default camera pose will aligned with the world frame.
Pasted image 20240501181344 Pasted image 20240501181355

You can find more detailed information about set_world_pose() in the API docs of it here.