아래 내용은 제가 공식 튜토리얼 자료를 보고 정리한 내용으로 잘못된 내용이 있을 수 있습니다.
./python.sh
을 사용.이동/복사
cd exts/omni.isaac.examples/omni/isaac/examples
cp hello_world/hello_world* user_examples/
exts/omni.isaac.examples/omni/isaac/examples/user_examples/__init__.py
에 다음 줄을 추가
from omni.isaac.examples.user_examples.hello_world import HelloWorld
from omni.isaac.examples.user_examples.hello_world_extension import HelloWorldExtension
exts/omni.isaac.examples/omni/isaac/examples/user_examples/hello_world_extension.py
를 다음과 같이 수정
import os
from omni.isaac.examples.base_sample import BaseSampleExtension
from omni.isaac.examples.user_examples import HelloWorld
class HelloWorldExtension(BaseSampleExtension):
def on_startup(self, ext_id: str):
super().on_startup(ext_id)
super().start_extension(
menu_name="",
submenu_name="",
name="Awesome Example",
title="My Awesome Example",
doc_link="https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/tutorial_core_hello_world.html",
overview="This Example introduces the user on how to do cool stuff with Isaac Sim through scripting in asynchronous mode.",
file_path=os.path.abspath(__file__),
sample=HelloWorld(),
)
return
exts/omni.isaac.examples/omni/isaac/examples/user_examples/hello_world.py
를 다음과 같이 수정
from omni.isaac.examples.base_sample import BaseSample
import numpy as np
from omni.isaac.core.objects import DynamicCuboid
class HelloWorld(BaseSample):
def __init__(self) -> None:
super().__init__()
return
def setup_scene(self):
world = self.get_world()
world.scene.add_default_ground_plane()
fancy_cube = world.scene.add(
DynamicCuboid(
prim_path="/World/random_cube",
name="fancy_cube",
position=np.array([0, 0, 1.0]),
scale=np.array([0.5015, 0.5015, 0.5015]),
color=np.array([0, 0, 1.0]),
))
return
async def setup_post_load(self):
self._world = self.get_world()
self._cube = self._world.scene.get_object("fancy_cube")
self._world.add_physics_callback("sim_step", callback_fn=self.print_cube_info) #callback names have to be unique
return
# here we define the physics callback to be called before each physics step, all physics callbacks must take
# step_size as an argument
def print_cube_info(self, step_size):
position, orientation = self._cube.get_world_pose()
linear_velocity = self._cube.get_linear_velocity()
# will be shown on terminal
print("Cube position is : " + str(position))
print("Cube's orientation is : " + str(orientation))
print("Cube's linear velocity is : " + str(linear_velocity))