A bug in the camera.py of Isaac Sim 2022.2.1

In the latest version of Isaac Sim, I believe you get the wrong parameter when computing the intrinsic matrix of a camera. Specifically, it should be
vertical_aperture = self.get_vertical_aperture()

I got another question about the camera. I found that if I set physics_dt when instancing World class, the “distance_to_camera” returns None. But if i don’t specify physics_dt, the “distance_to_camera” returns the value normally. How physics_dt influences the camera, and how do I specify physics_dt if I must have camera in the scene?

Below is the example code, thanks.

from omni.isaac.kit import SimulationApp
simulation_app = SimulationApp({"headless": False})
from omni.isaac.core.objects import DynamicCuboid
from omni.isaac.sensor import Camera
from omni.isaac.core import World
import omni.isaac.core.utils.numpy.rotations as rot_utils
import numpy as np
import os
import matplotlib.pyplot as plt

file_path = os.path.split(os.path.realpath(__file__))[0]

from omni.kit.viewport.utility import (
    get_active_viewport_window,
)
    
my_world = World(
                #  physics_dt=1. / 100., 
                 stage_units_in_meters=1.0)

cube_2 = my_world.scene.add(
    DynamicCuboid(
        prim_path="/new_cube_2",
        name="cube_1",
        position=np.array([5.0, 3, 1.0]),
        scale=np.array([0.6, 0.5, 0.2]),
        size=1.0,
        color=np.array([255, 0, 0]),
    )
)

cube_3 = my_world.scene.add(
    DynamicCuboid(
        prim_path="/new_cube_3",
        name="cube_2",
        position=np.array([-5, 1, 3.0]),
        scale=np.array([0.1, 0.1, 0.1]),
        size=1.0,
        color=np.array([0, 0, 255]),
        linear_velocity=np.array([0, 0, 0.4]),
    )
)

camera = Camera(
    prim_path="/World/camera",
    position=np.array([0.0, 0.0, 25.0]),
    frequency=20,
    resolution=(256, 256),
    orientation=rot_utils.euler_angles_to_quats(np.array([0, 90, 0]), degrees=True),
)

camera.set_resolution((640, 480))
camera.set_focal_length(1.93)
camera.set_horizontal_aperture(2.0117263843648208)
camera.set_vertical_aperture(1.5087947882736157)

my_world.scene.add_default_ground_plane()
my_world.reset()
camera.initialize()

camera.add_distance_to_camera_to_frame()

# using default viewport window
camera_window = get_active_viewport_window(window_name="Viewport")
camera_window.viewport_api.set_texture_resolution((640,480))
i = 0

camera_window.viewport_api.set_active_camera("/World/camera")
while simulation_app.is_running():
    my_world.step(render=True)
    if i % 1000 == 0:
        rgb = camera.get_rgba()[:, :, :3]
        plt.imsave(file_path+"/test.jpg", rgb)
        depth = camera.get_current_frame()["distance_to_camera"]
        if depth is not None and depth.size>0:
            print(depth[239,319])
    if my_world.is_playing():
        if my_world.current_time_step_index == 0:
            my_world.reset()
    i += 1

simulation_app.close()

Hi @juxiaozhu - Someone from our team will look at the issue and get back to you.

+1 to this. It was possible up to the latest version to do this but now it is impossible and the vertical is always related to the image ratio.