Hi everyone,
I am trying to create a D455 camera in my isaac sim environment by python code. But after I run my program, I cannot see the D455 camera model although I still can see the d455 Xform in my stage (as in the photo).
It also shows me the viewpoints from the realsense camera, but when I select one one of the viewpoints, it was just white view.
My code is as following. Please help me to solve the problem.
Thank you !
#launch Isaac Sim before any other imports
#default first two lines in any standalone application
from omni.isaac.kit import SimulationApp
simulation_app = SimulationApp({"headless": False}) # we can also run as headless.
from omni.isaac.core import World
from omni.isaac.core.objects import DynamicCuboid
from object_utils.object_utils import ObjectUtils
from omni.isaac.core.utils.nucleus import find_nucleus_server, get_assets_root_path
from omni.isaac.core.utils.stage import add_reference_to_stage
from pxr import Sdf, Usd, UsdGeom, Gf
import carb
import numpy as np
import carb
# D455_USD_PATH = "/home/huynn/huynn_ws/edge-server-project/isaac_sim_learning/cameras/rsd455/rsd455.usd"
class RobotJuggler:
def __init__(self,):
self.ou = ObjectUtils()
kp=1.0
ki=0.0
kd=0.0
self.ou.pid_controller.update_params(kp, ki, kd)
self.goal_position = np.array([10.0, 5.0, 0.0])
# Khởi tạo mô phỏng
time_step = 1/60 # 1000 time faster then realtime
self.world = World(physics_dt = time_step, rendering_dt = time_step)
self.setup_scene()
self.stop_sim = False
def setup_scene(self,):
# Thiết lập môi trường
self.world.scene.add_default_ground_plane(
z_position=0,
name="fancy_ground_plane",
prim_path="/World/fancy_ground_plane",
static_friction=0.0,
dynamic_friction=0.0,
restitution=0.01,
)
self.ou.add_dome_light("/fancy_dome_light", 1000.0, [1.0, 1.0, 1.0])
self.fancy_cube_prim_path = "/World/fancy_cube"
self.fancy_cube = self.ou.add_box(self.world, self.fancy_cube_prim_path,
position=[0, 0, 0.05],
scale=[0.1, 0.1, 0.1],
color=[1.0, 0.0, 1.0])
nucleus_server = get_assets_root_path()
# if result is False:
# carb.log_error("Could not find nucleus server with /Isaac folder")
print("nucleus_server: ", nucleus_server)
d455_usd_path = nucleus_server + "/Isaac/Sensors/Intel/RealSense/rsd455.usd"
d455:Usd.Prim = add_reference_to_stage(usd_path=d455_usd_path, prim_path="/World/d455")
stage = self.world.stage
d455 = stage.GetPrimAtPath("/World/d455")
d455_xform = UsdGeom.Xform(d455)
# Đặt vị trí (translation)
translation = Gf.Vec3f(1, 0, 0.1) # Giá trị dịch chuyển theo các trục x, y, z
d455_xform.AddTranslateOp().Set(translation)
# Đặt hướng (rotation)
rotation = Gf.Vec3f(0, 0, 90) # Giá trị xoay theo các trục x, y, z (đơn vị độ)
d455_xform.AddRotateXYZOp().Set(rotation)
print('-------------------------------------------- ', type(d455))
# Reset thế giới để cập nhật các thay đổi
self.world.reset()
# Create an example timeline callback
self.world.add_timeline_callback('template_timeline_callback', self.timeline_callback)
def timeline_callback(self, timeline_event):
"""An example timeline callback. It will get invoked every time a timeline event occurs. In this example,
we will check if the event is for a 'simulation stop'. If so, we will attempt to close the app
Args:
timeline_event: A timeline event
"""
if self.world.is_stopped():
self.stop_sim = True
def run_simulation(self,):
"""
Method that implements the application main loop, where the physics steps are executed.
"""
# print('----------------------------------------------------------------------------')
# self.timeline.play()
# Chạy mô phỏng
# self.ou.apply_velocity(self.fancy_cube_prim_path, 1.0, 0, 3.0)
while simulation_app.is_running() and not self.stop_sim:
# print('----------------------------------------------------------------------------')
# self.ou.apply_velocity(self.fancy_cube_prim_path, 5.0, 0, 5.0)
self.world.step(render=True) # Bước mô phỏng vật lý và rendering
carb.log_warn("Template Simulation App is closing.")
# self.timeline.stop()
simulation_app.close()
# Sử dụng class
if __name__ == "__main__":
simulation = RobotJuggler()
simulation.run_simulation()
simulation_app.close()