Closed PARKBONG closed 1 year ago
Hi @PARKBONG
This is a known issue in Isaac Sim... I tried the solution in this topic (https://forums.developer.nvidia.com/t/the-camera-crops-objects-when-i-zoom-in/220278) but it doesn't work. I don't know how to solve it yet :disappointed:
@Toni-SM ,
I solved the issue by applying this post,
I changed the openxr.py / get_or_create_viewport_window
to this:
def get_or_create_vieport_window(camera, teleport=True, window_size=(400, 300), resolution=(1280, 720)):
window = None
camera = str(camera.GetPath() if type(camera) is Usd.Prim else camera)
# get viewport window
for interface in self._viewport_interface.get_instance_list():
w = self._viewport_interface.get_viewport_window(interface)
if camera == w.get_active_camera():
window = w
# check visibility
if not w.is_visible():
w.set_visible(True)
break
# create viewport window if not exist
if window is None:
window = self._viewport_interface.get_viewport_window(self._viewport_interface.create_instance())
window.set_window_size(*window_size)
window.set_active_camera(camera)
window.set_texture_resolution(*resolution)
if teleport:
window.set_camera_position(camera, 1.0, 1.0, 1.0, True)
window.set_camera_target(camera, 0.0, 0.0, 0.0, True)
return window
stage = omni.usd.get_context().get_stage()
# left camera
teleport_camera = False
self._prim_left = None
if type(left_camera) is Usd.Prim:
self._prim_left = left_camera
elif stage.GetPrimAtPath(left_camera).IsValid():
self._prim_left = stage.GetPrimAtPath(left_camera)
else:
teleport_camera = True
self._prim_left = stage.DefinePrim(omni.usd.get_stage_next_free_path(stage, left_camera, False), "Camera")
# bong - camera solutions
self._prim_left.GetAttribute("clippingRange").Set( (0.01, 1000000) ) #ADDED
self._prim_left.GetAttribute("clippingPlanes").Set( np.array([1.0, 0.0, 1.0, 1.0]) ) #ADDED
self._viewport_window_left = get_or_create_vieport_window(self._prim_left, teleport=teleport_camera)
# right camera
teleport_camera = False
self._prim_right = None
if right_camera is not None:
if type(right_camera) is Usd.Prim:
self._prim_right = right_camera
elif stage.GetPrimAtPath(right_camera).IsValid():
self._prim_right = stage.GetPrimAtPath(right_camera)
else:
teleport_camera = True
self._prim_right = stage.DefinePrim(omni.usd.get_stage_next_free_path(stage, right_camera, False), "Camera")
self._prim_right.GetAttribute("clippingRange").Set( (0.01, 1000000) ) #ADDED
self._prim_right.GetAttribute("clippingPlanes").Set( np.array([1.0, 0.0, 1.0, 1.0]) ) # ADDED
self._viewport_window_right = get_or_create_vieport_window(self._prim_right, teleport=teleport_camera) # CHANGED INDENT
# set recommended resolution
resolutions = self.get_recommended_resolutions()
if len(resolutions) and self._viewport_window_left is not None:
self._viewport_window_left.set_texture_resolution(*resolutions[0])
if len(resolutions) == 2 and self._viewport_window_right is not None:
self._viewport_window_right.set_texture_resolution(*resolutions[1])
# set camera properties
for property in camera_properties:
self._prim_left.GetAttribute(property).Set(camera_properties[property])
if right_camera is not None:
self._prim_right.GetAttribute(property).Set(camera_properties[property])
# enable sensors
if self._viewport_window_left is not None:
sensors.enable_sensors(self._viewport_window_left, [_syntheticdata.SensorType.Rgb])
if self._viewport_window_right is not None:
sensors.enable_sensors(self._viewport_window_right, [_syntheticdata.SensorType.Rgb])
Hi @PARKBONG
I encourage you to create a pull request with the change :)
Hi,
The asset near the camera disappears. It happens not only HMD viewport, but also IsaacSim's native viewport. Do you know the cause or solution?
https://user-images.githubusercontent.com/39259734/196816686-ed5a02dd-7faf-4dd0-bc01-76c530f41cb4.mp4
Thanks.