HI, recently I am working on Isaacsim to build environments. And I import urdf file and i want to automatically record the bounding box of some elements in the urdf.
Since I wanna obtain them via python API, I try out the example with avocado first and it works.
Here is the code:
from omni.isaac.kit import SimulationApp
# URDF import, configuration and simulation sample
simulation_app = SimulationApp({"renderer": "RayTracedLighting", "headless": False})
import os
import numpy as np
import random
import sys
import omni.kit.commands
from omni.isaac.dynamic_control import _dynamic_control
from pxr import Sdf, Gf, UsdPhysics, UsdLux, PhysxSchema, UsdGeom
from omni.isaac.sensor import Camera
import omni.isaac.core.utils.numpy.rotations as rot_utils
import numpy as np
import omni.syntheticdata as sd
import os
# Get current work directory
current_work_dir = os.path.dirname(__file__)
stage = omni.usd.get_context().get_stage()
# Add world
from omni.isaac.core import World
world = World()
if __name__ == '__main__':
while simulation_app.is_running():
data = []
data_new = []
import json
import numpy as np
import omni
from omni.kit.viewport.utility import capture_viewport_to_file
import omni.replicator.core as rep
async def test_bbox_2d_loose():
with rep.new_layer():
# Add Default Light
distance_light = rep.create.light(rotation=(315,0,0), intensity=3000, light_type="distant")
AVOCADO = 'omniverse://localhost/NVIDIA/Assets/ArchVis/Residential/Food/Fruit/Avocado01.usd'
avocado = rep.create.from_usd(AVOCADO)
with avocado:
rep.modify.semantics([('class', 'avocado')])
sd.SyntheticData.Get().set_instance_mapping_semantic_filter("class:*")
camera = rep.create.camera(focus_distance=80)
render_product = rep.create.render_product(camera, resolution=(1024, 1024))
bbox_2d_loose = rep.AnnotatorRegistry.get_annotator("bounding_box_2d_loose")
bbox_2d_loose.attach(render_product)
await rep.orchestrator.step_async()
bbox_2d_loose_data = bbox_2d_loose.get_data()
print(bbox_2d_loose_data)
for j in range(60):
world.step(render=True)
import asyncio
# asyncio.ensure_future(generate_2d_bounding_boxes(camera,robot_arm_path,data_new))
asyncio.ensure_future(test_bbox_2d_loose())
The above code works.
However, when I wanna replace Avocado01.usd with my custom usd file(which is transferred from urdf file), the out put data of bbox_2d_loose_data is empty, here is the print-out:
{'data': array([],
dtype=[('semanticId', '<u4'), ('x_min', '<i4'), ('y_min', '<i4'), ('x_max', '<i4'), ('y_max', '<i4'), ('occlusionRatio', '<f4')]), 'info': {'bboxIds': array([], dtype=uint32), 'idToLabels': {}, 'primPaths': []}}
Can anyone help me solve this issue?