Incorrect camera orientation with Python API

I’m using the Python API to load my robot (in this case, the example ur10 robot), add lighting + a ground plane, and spawn in a camera:

editor = omni.kit.editor.get_editor_interface()
editor.set_camera_position("/OmniverseKit_Persp", 300, 300, 300, True)
editor.set_camera_target("/OmniverseKit_Persp", 0, 0, 0, True)

However, it seems like the camera is not oriented correctly. If I load my robot URDF via the GUI rather than with Python API, it is shown to be upright, but not in this case. I’m also not sure if this is a case of my camera settings being weird or if my model is somehow misaligned with the axes. I tried doing import_config.set_up_vector(0, 0, 1) in order to have it be along the positive z-axis, but that did not end up changing anything. Any help would be appreciated!

Hi @verityw

You can try to set up the axis of the stage before calling those methods as defined in /isaac-sim/_build/linux-x86_64/release/exts/omni.isaac.samples/omni/isaac/samples/scripts/franka_scenarios/scenario.py line 18, for example

import omni
from pxr import Usd, UsdGeom

# Utility function to specify the stage with the z axis as "up"
def set_up_z_axis(stage):
    rootLayer = stage.GetRootLayer()
    rootLayer.SetPermissionToEdit(True)
    with Usd.EditContext(stage, rootLayer):
        UsdGeom.SetStageUpAxis(stage, UsdGeom.Tokens.z)

stage = omni.usd.get_context().get_stage()
set_up_z_axis(stage)
1 Like