def __init__(self, omni_kit, z_height=0): self.omni_kit = omni_kit # 링크 확인 result, nucleus_server = find_nucleus_server() if result is False: carb.log_error( "Could not find nucleus server with /Isaac folder. Please specify the correct nucleus server in experiences/isaac-sim-python.json" ) return # 변수 설정 self.tile_size = [25.0, 25.0] # 1=UP, 2 = DOWN, 3 = LEFT, 4= RIGHT self.direction_map = {1: 180, 2: 0, 3: -90, 4: 90} self.prims = [] # list of spawned tiles self.height = z_height # height of the ground tiles self.tiles = None self.state = None # because the ground plane is what the robot drives on, we only do this once. We can then re-generate the road as often as we need without impacting physics self.setup_physics() self.road_map = None self.road_path_helper = None self.omni_kit.create_prim("/World/Floor", "Xform") # cube 생성 stage = omni.usd.get_context().get_stage() cubeGeom = UsdGeom.Cube.Define(stage, "/World/Floor/thefloor") cubeGeom.CreateSizeAttr(300) offset = Gf.Vec3f(75, 75, -150.1) cubeGeom.AddTranslateOp().Set(offset) # 환경 load # In manual mode, user can control when scene randomization occur whereas in non-manual mode scene randomization is controlled via the duration parameter in various DR components. self.dr = DomainRandomization() self.dr.toggle_manual_mode() self.omni_kit.update(1 / 60.0) print("waiting for materials to load...") while self.omni_kit.is_loading(): self.omni_kit.update(1 / 60.0) # Create a sphere room so the world is not black lights = [] for i in range(5): prim_path = "/World/Lights/light_" + str(i) self.omni_kit.create_prim( prim_path, "SphereLight", translation=(0, 0, 200), rotation=(0, 0, 0), attributes={"radius": 10, "intensity": 1000.0, "color": (1.0, 1.0, 1.0)}, ) lights.append(prim_path) self.dr.create_light_comp(light_paths=lights) self.dr.create_movement_comp(prim_paths=lights, min_range=(0, 0, 30), max_range=(150, 150, 30))
async def _on_create_robot(self, task): """ load robot from USD """ done, pending = await asyncio.wait({task}) if task not in done: return self._stage = self._usd_context.get_stage() self._create_robot_btn.enabled = False self._editor.stop() set_up_z_axis(self._stage) add_ground_plane(self._stage, "/groundPlane", "Z", 1000.0, Gf.Vec3f(0.0), Gf.Vec3f(1.0)) setup_physics(self._stage) result, nucleus_server = find_nucleus_server() if result is False: carb.log_error("Could not find nucleus server with /Isaac folder") return asset_path = nucleus_server + "/Isaac" robot_usd = asset_path + "/Robots/Franka/franka.usd" robot_path = "/scene/robot" create_prim_from_usd(self._stage, robot_path, robot_usd, Gf.Vec3d(0, 0, 0)) self.objects = [ asset_path + "/Props/Flip_Stack/large_corner_bracket_physics.usd", asset_path + "/Props/Flip_Stack/screw_95_physics.usd", asset_path + "/Props/Flip_Stack/screw_99_physics.usd", asset_path + "/Props/Flip_Stack/small_corner_bracket_physics.usd", asset_path + "/Props/Flip_Stack/t_connector_physics.usd", ] self.current_obj = 0 self._physxIFace.release_physics_objects() self._physxIFace.force_load_physics_from_usd() self._editor_event_subscription = self._editor.subscribe_to_update_events( self._on_editor_step) self._physxIFace.release_physics_objects() self._physxIFace.force_load_physics_from_usd() self._reset_btn.enabled = True self._editor.set_camera_position("/OmniverseKit_Persp", 142, -127, 56, True) self._editor.set_camera_target("/OmniverseKit_Persp", -180, 234, -27, True) light_prim = UsdLux.DistantLight.Define( self._stage, Sdf.Path("/World/defaultLight")) light_prim.CreateIntensityAttr(500) self._first_step = True self._following = False self._robot = None self._created = True
def __init__(self, omni_kit): self.omni_kit = omni_kit result, nucleus_server = find_nucleus_server() if result is False: carb.log_error("Could not find nucleus server with /Isaac folder") return self.usd_path = nucleus_server + "/Isaac/Robots/STR/STR_V4_Physics_Caster.usd" self.robot_prim = None self.dc = _dynamic_control.acquire_dynamic_control_interface() self.ar = None
def generate_warehouse(self, shape): stage = self.omni_kit.get_stage() result, nucleus_server = find_nucleus_server() if result is False: carb.log_error("Could not find nucleus server with /Isaac folder") return path = nucleus_server + "/Isaac/Environments/Simple_Warehouse/warehouse.usd" prefix = "/World/Env/Track" prim_path = omni.kit.utils.get_stage_next_free_path(stage, prefix, False) track_prim = stage.DefinePrim(prim_path, "Xform") track_prim.GetReferences().AddReference(path)
def create_franka(self, *args): result, nucleus_server = find_nucleus_server() if result is False: carb.log_error("Could not find nucleus server with /Isaac folder") return self.asset_path = nucleus_server + "/Isaac" # USD paths loaded by scenarios self.franka_table_usd = self.asset_path + "/Samples/Leonardo/Stage/franka_block_stacking.usd" self.franka_ghost_usd = self.asset_path + "/Samples/Leonardo/Robots/franka_ghost.usd" self.background_usd = self.asset_path + "/Environments/Grid/gridroom_curved.usd" self.rubiks_cube_usd = self.asset_path + "/Props/Rubiks_Cube/rubiks_cube.usd" self.red_cube_usd = self.asset_path + "/Props/Blocks/red_block.usd" self.yellow_cube_usd = self.asset_path + "/Props/Blocks/yellow_block.usd" self.green_cube_usd = self.asset_path + "/Props/Blocks/green_block.usd" self.blue_cube_usd = self.asset_path + "/Props/Blocks/blue_block.usd" self._created = True self._stage = omni.usd.get_context().get_stage() set_up_z_axis(self._stage) self.stop_tasks() pass