Skip to content

Commit

Permalink
finish gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsleaf committed Jan 14, 2025
1 parent 5e98e81 commit 0fc2582
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 23 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 70 additions & 22 deletions demos/IsaacSim/gallery/gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@
from omni.isaac.lab_assets import (
FRANKA_PANDA_CFG,
G1_MINIMAL_CFG,
H1_CFG,
H1_MINIMAL_CFG,
KINOVA_GEN3_N7_CFG,
KINOVA_JACO2_N6S300_CFG,
KINOVA_JACO2_N7S300_CFG,
SAWYER_CFG,
UR10_CFG,
)
Expand All @@ -64,52 +63,97 @@
from simpub.sim.isaacsim_publisher import IsaacSimPublisher


def design_scene() -> tuple[dict, list[list[float]]]:
def design_scene():
scene_entities = {}
origins = []

scene_asset_cfg = AssetBaseCfg(
prim_path="/World/scene",
init_state=AssetBaseCfg.InitialStateCfg(pos=[0.0, 0.0, 0.0], rot=[1.0, 0.0, 0.0, 0.0]),
spawn=UsdFileCfg(
usd_path=f"{Path(__file__).parent.as_posix()}/simple_room.usd",
usd_path=f"{Path(__file__).parent.as_posix()}/gallery.usd",
),
)
scene_asset_cfg.spawn.func(scene_asset_cfg.prim_path, scene_asset_cfg.spawn)

anymal_c_cfg = ANYMAL_C_CFG
anymal_c_cfg.prim_path = "/World/scene/anymal_c"
anymal_c_cfg.spawn = None
scene_entities["anymal_c"] = Articulation(cfg=anymal_c_cfg)
origins.append([0, 0, 0])
anymal_b_cfg = ANYMAL_B_CFG
anymal_b_cfg.prim_path = "/World/scene/anymal_b"
anymal_b_cfg.spawn = None
scene_entities["anymal_b"] = Articulation(cfg=anymal_b_cfg)

anymal_d_cfg = ANYMAL_D_CFG
anymal_d_cfg.prim_path = "/World/scene/anymal_d"
anymal_d_cfg.spawn = None
scene_entities["anymal_d"] = Articulation(cfg=anymal_d_cfg)

go2_cfg = UNITREE_GO2_CFG
go2_cfg.prim_path = "/World/scene/go2"
go2_cfg.spawn = None
scene_entities["go2"] = Articulation(cfg=go2_cfg)

a1_cfg = UNITREE_A1_CFG
a1_cfg.prim_path = "/World/scene/a1"
a1_cfg.spawn = None
scene_entities["a1"] = Articulation(cfg=a1_cfg)

franka_cfg = FRANKA_PANDA_CFG
franka_cfg.prim_path = "/World/scene/franka_panda"
franka_cfg.spawn = None
scene_entities["franka"] = Articulation(cfg=franka_cfg)

ur10_cfg = UR10_CFG
ur10_cfg.prim_path = "/World/scene/ur10"
ur10_cfg.spawn = None
scene_entities["ur10"] = Articulation(cfg=ur10_cfg)

gen3n7_cfg = KINOVA_GEN3_N7_CFG
gen3n7_cfg.prim_path = "/World/scene/gen3n7"
gen3n7_cfg.spawn = None
scene_entities["gen3n7"] = Articulation(cfg=gen3n7_cfg)

sawyer_cfg = SAWYER_CFG
sawyer_cfg.prim_path = "/World/scene/sawyer"
sawyer_cfg.spawn = None
scene_entities["sawyer"] = Articulation(cfg=sawyer_cfg)

h1_cfg = H1_CFG
h1_cfg.prim_path = "/World/scene/h1"
h1_cfg.spawn = None
scene_entities["h1"] = Articulation(cfg=h1_cfg)

# return the scene information
return scene_entities, origins
return scene_entities


def run_simulator(
sim: sim_utils.SimulationContext,
entities: dict[str, Articulation],
origins: torch.Tensor,
):
"""Runs the simulation loop."""
# Define simulation stepping
sim_dt = sim.get_physics_dt()
sim_time = 0.0
count = 0

for robot in entities.values():
robot.data.default_root_state = robot.data.root_state_w.clone()

elbow_indices, _ = entities["h1"].find_joints(".*_elbow")
default_joint_pos = entities["h1"].data.default_joint_pos.clone()
default_joint_pos[0, elbow_indices] = -0.2
entities["h1"].data.default_joint_pos = default_joint_pos

# Simulate physics
while simulation_app.is_running():
# reset
if count % 200 == 0:
if count % 2000 == 0:
# reset counters
sim_time = 0.0
count = 0
# reset robots
for index, robot in enumerate(entities.values()):
# # root state
# root_state = robot.data.default_root_state.clone()
# root_state[:, :3] += origins[index]
# robot.write_root_state_to_sim(root_state)
for robot in entities.values():
# root state
root_state = robot.data.default_root_state.clone()
robot.write_root_state_to_sim(root_state)
# joint state
joint_pos, joint_vel = (
robot.data.default_joint_pos.clone(),
Expand Down Expand Up @@ -145,22 +189,26 @@ def main():
# Set main camera
sim.set_camera_view(eye=[2.5, 2.5, 2.5], target=[0.0, 0.0, 0.0])
# design scene
scene_entities, scene_origins = design_scene()
scene_origins = torch.tensor(scene_origins, device=sim.device)
scene_entities = design_scene()
# Play the simulator
sim.reset()

_ = IsaacSimPublisher(
host="127.0.0.1",
stage=sim.stage,
ignored_prim_paths=["/World/defaultGroundPlane"],
ignored_prim_paths=[
"/World/scene/GroundPlane",
"/World/scene/Cube_04",
"/World/scene/Cube_05",
"/World/scene/Cube_06",
],
texture_cache_dir=f"{Path(__file__).parent.as_posix()}/.textures",
)

# Now we are ready!
print("[INFO]: Setup complete...")
# Run the simulator
run_simulator(sim, scene_entities, scene_origins)
run_simulator(sim, scene_entities)


if __name__ == "__main__":
Expand Down
Binary file added demos/IsaacSim/gallery/gallery.usd
Binary file not shown.
Binary file removed demos/IsaacSim/gallery/simple_room.usd
Binary file not shown.
Binary file removed demos/IsaacSim/gallery/warehouse.usd
Binary file not shown.
6 changes: 5 additions & 1 deletion simpub/parser/isaacsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,14 @@ def parse_prim_material(
texture_path = None
if diffuse_texture.Get() is not None:
texture_path = str(diffuse_texture.Get().resolvedPath)
if not texture_path:
texture_path = str(diffuse_texture.Get().path)
else:
diffuse_texture = mat_shader.GetInput("AlbedoTexture")
if diffuse_texture.Get() is not None:
texture_path = str(diffuse_texture.Get().resolvedPath)
if not texture_path:
texture_path = str(diffuse_texture.Get().path)

with self.timer.start("parse_prim_material_3"):
diffuse_color = [1.0, 1.0, 1.0]
Expand Down Expand Up @@ -416,7 +420,7 @@ def parse_prim_material(
image = Image.open(texture_path)

# this is not needed for local textures. but anyway...
if image is not None:
if image is not None and self.texture_cache_dir is not None:
ext = os.path.splitext(texture_path)[1]
texture_file_name = f"{str(uuid.uuid4())}{ext}"
texture_file_path = os.path.join(self.texture_cache_dir, texture_file_name)
Expand Down

0 comments on commit 0fc2582

Please sign in to comment.