Using the Replicator with a fully developed scene
Using the Replicator with a fully developed scene — Omniverse Extensions documentation
Learning Objectives Through this tutorial you will learn how to use a previously developed scene with Replicator. Here, we will show you how you can randomize what is visible on the scene, but you should be able to use any of the randomizers following this
docs.omniverse.nvidia.com
완전히 개발된 장면과 함께 Replicator를 사용
학습 목표
이 자습서에서는 이전에 개발된 장면을 레플리케이터로 사용하는 방법을 배웁니다. 여기서는 장면에 보이는 것을 랜덤화할 수 있는 방법을 보여드리지만, 이 구조를 따르는 randomizers는 모두 사용할 수 있어야 합니다.
기존 장면을 열기
이 예제를 통해 두 장면을 사용하는 방법을 보여드리겠습니다. 하나는 일반 NVIDIA 자산이 있는 것이고 다른 하나는 옴니버스 로봇 시뮬레이션 애플리케이션인 Isaac Sim의 웨어하우스를 활용하는 것입니다. 두 사람 모두 Setting sup nucleus server(핵 서버 설정)와 Isaac Sim 예제에 따라 Isaac 폴더를 다운로드했는지 확인합니다.
다락방 장면
이 예에서는 NVIDIA가 로컬 Nucleus 서버를 통해 제공하는 Attic 장면을 사용합니다. 로컬 Nucleus 서버를 설정하려면 Nucleus 서버 설정의 지침을 따르십시오. 로컬 핵 서버가 설정되면 컨텐츠 브라우저를 통해 omniverse://localhost/NVIDIA/Samples/OldAttic/Attic_NVIDIA.usd 폴더에서 Attic 장면을 찾을 수 있습니다. 더 빠른 렌더링을 위해 렌더링 모드를 실시간으로 전환할 수 있습니다.
씬(scene)을 랜덤화
다음 스크립트를 실행하려면 스크립트 편집기 설정의 설정 지침을 따르십시오.
이 스크립트에서는 omni.replicator를 가져오고 새 USD 계층을 시작합니다. 씬(scene)에 대한 모든 랜덤화 및 변경 사항이 새 레이어 내에 자체 포함되도록 이 작업을 수행합니다. 새 레이어를 USD 파일에 추가하지 않고 스크립트를 통해 변경한 내용이 씬(scene)을 영구적으로 변경합니다. 그런 다음 우리는 렌더 제품을 첨부합니다. 이 장면에서는 뷰포트가 기본값으로 설정되어 있는 카메라가 아닌 다른 카메라를 사용하고 있습니다. 이렇게 하면 캡처된 시점을 보여주는 스크립트가 실행될 때 새 뷰포트가 생성됩니다.
import omni.replicator.core as rep
with rep.new_layer():
render_product = rep.create.render_product('/Root/Camera', (2048, 1024))
우리는 현장에서 소파에 있는 곰을 선택하고 라벨을 붙이고 가시성을 랜덤화합니다. 마지막으로 랜덤라이저를 등록합니다.
def hide_bear():
bear = rep.get.prims(path_pattern='/Root/Geometry/Bear')
with bear:
rep.modify.semantics([('class', 'bear')])
rep.modify.visibility(rep.distribution.choice([True, False]))
return bear.node
rep.randomizer.register(hide_bear)
Randomizer가 100 프레임에 대해 작동됩니다.
with rep.trigger.on_frame(num_frames=100):
rep.randomizer.hide_bear()
이 작업을 보려면 스크립트를 실행하고 레플리케이터의 맨 왼쪽 모서리를 눌러 레플리케이터를 실행한 후 레플리케이터 실행 및 미리 보기에 표시된 대로 실행하십시오. 아래는 전체 코드입니다.
import omni.replicator.core as rep
with rep.new_layer():
render_product = rep.create.render_product('/Root/Camera', (2048, 1024))
def hide_bear():
bear = rep.get.prims(path_pattern='/Root/Geometry/Bear')
with bear:
rep.modify.semantics([('class', 'bear')])
rep.modify.visibility(rep.distribution.choice([True, False]))
return bear.node
rep.randomizer.register(hide_bear)
# Setup randomization
with rep.trigger.on_frame(num_frames=100):
rep.randomizer.hide_bear()
아이작 심 창고 장면
이 예에서는 Isaac Sim의 창고를 사용합니다. 로컬 컴퓨터에서 이 장면을 사용하려면 Isaac Sim을 다운로드하여 Isaac Sim 자산을 다운로드해야 합니다. Isaac Sim은 로봇 자산이 있는 Isaac 폴더를 로컬 Nuclear 서버에 자동으로 다운로드합니다.
먼저 컨텐츠 브라우저를 통해 /Isaac/Samples/DR/Stage/simple_warehouse_material_sample.usd에 있는 창고 장면을 엽니다.
씬(scene)을 랜덤화
다음 스크립트를 실행하려면 스크립트 편집기 설정의 설정 지침을 따르십시오.
먼저 레플리케이터를 가져오고 render_product를 만듭니다. 이 튜토리얼에서는 현장에 이미 설치된 카메라를 사용합니다.
import omni.replicator.core as rep
with rep.new_layer():
render_product = rep.create.render_product('/Root/Cameras/Camera_02', (2048, 1024))
원하는 방식으로 임의 추출 및 임의 추출할 수 있습니다. 이 경우 가시성을 전환하고 있습니다. 그런 다음 랜덤라이저를 등록합니다.
def hide_boxes():
boxes = rep.get.prims(path_pattern='SM_CardBox[AD]_\d\d$', prim_types=['Xform'])
with boxes:
rep.modify.visibility(rep.distribution.choice([True, False]))
return boxes.node
rep.randomizer.register(hide_boxes)
마지막으로 100프레임마다 랜덤화가 작동됩니다. 레플리케이터를 실행하려면 상단 모서리를 누른 후 실행하십시오. 여기에 작성자가 없으므로 저장되지 않습니다. 다른 튜토리얼에서 BasicWriter를 사용하거나 사용자 지정 작성기를 만드는 방법을 보여 줍니다.
with rep.trigger.on_frame(num_frames=100):
rep.randomizer.hide_boxes()
전체 스크립트는 다음과 같습니다.
import omni.replicator.core as rep
with rep.new_layer():
render_product = rep.create.render_product('/Root/Cameras/Camera_02', (2048, 1024))
def hide_boxes():
boxes = rep.get.prims(path_pattern='SM_CardBox[AD]_\d\d$', prim_types=['Xform'])
with boxes:
rep.modify.visibility(rep.distribution.choice([True, False]))
return boxes.node
rep.randomizer.register(hide_boxes)
# Setup randomization
with rep.trigger.on_frame(num_frames=100):
rep.randomizer.hide_boxes()
'omniverse > replicator' 카테고리의 다른 글
옴니버스 레플리케이터 예제 11탄 (0) | 2022.06.01 |
---|---|
옴니버스 레플리케이터 예제 10탄 (0) | 2022.05.31 |
옴니버스 레플리케이터 예제 8탄 (0) | 2022.05.29 |
옴니버스 레플리케이터 예제 7탄 (0) | 2022.05.28 |
옴니버스 레플리케이터 예제 6탄 (0) | 2022.05.27 |