Initial commit: Vision-Guided Robotic Pick-and-Place Simulation
This commit is contained in:
@@ -0,0 +1,225 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
"""
|
||||
Environment Verification Script for Vision-Guided Robotic Pick-and-Place Simulation
|
||||
Platform: Ubuntu 24.04 LTS | NVIDIA Omniverse | Isaac Sim 6.2 | Kit 110.4 | RTX 5090
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import shutil
|
||||
import platform
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
def inspect_system_pre_app():
|
||||
"""System-level checks prior to starting Kit SimulationApp."""
|
||||
print("=" * 70)
|
||||
print(" STAGE 1: Host System & Hardware Inspection")
|
||||
print("=" * 70)
|
||||
|
||||
# 1. OS & Kernel
|
||||
os_info = {
|
||||
"platform": platform.platform(),
|
||||
"system": platform.system(),
|
||||
"release": platform.release(),
|
||||
"version": platform.version(),
|
||||
"machine": platform.machine(),
|
||||
"python_exe": sys.executable,
|
||||
"python_version": sys.version.split()[0],
|
||||
}
|
||||
print(f"[OS] {os_info['system']} {os_info['release']} ({os_info['machine']})")
|
||||
print(f"[Python] {os_info['python_version']} at {os_info['python_exe']}")
|
||||
|
||||
# 2. Disk Space
|
||||
total, used, free = shutil.disk_usage("/")
|
||||
disk_info = {
|
||||
"total_gb": round(total / (1024**3), 2),
|
||||
"used_gb": round(used / (1024**3), 2),
|
||||
"free_gb": round(free / (1024**3), 2),
|
||||
"percent_used": round((used / total) * 100, 1),
|
||||
}
|
||||
print(f"[Disk] Total: {disk_info['total_gb']} GB | Used: {disk_info['used_gb']} GB | Free: {disk_info['free_gb']} GB ({disk_info['percent_used']}% used)")
|
||||
if disk_info['free_gb'] < 15.0:
|
||||
print("[WARNING] Free disk space is critically constrained (< 15 GB). Asset downloads must be avoided!")
|
||||
|
||||
# 3. GPU & Driver via nvidia-smi
|
||||
gpu_info = {}
|
||||
try:
|
||||
smi_out = subprocess.check_output(
|
||||
["nvidia-smi", "--query-gpu=name,driver_version,memory.total,memory.free,memory.used", "--format=csv,noheader,nounits"],
|
||||
text=True
|
||||
).strip()
|
||||
parts = [p.strip() for p in smi_out.split(",")]
|
||||
gpu_info = {
|
||||
"gpu_name": parts[0],
|
||||
"driver_version": parts[1],
|
||||
"vram_total_mb": parts[2],
|
||||
"vram_free_mb": parts[3],
|
||||
"vram_used_mb": parts[4],
|
||||
}
|
||||
print(f"[GPU] {gpu_info['gpu_name']} | Driver: {gpu_info['driver_version']} | Total VRAM: {gpu_info['vram_total_mb']} MB")
|
||||
except Exception as e:
|
||||
print(f"[GPU] Failed to query nvidia-smi: {e}")
|
||||
|
||||
# 4. Omniverse and Isaac Sim Installation Paths
|
||||
isaac_root = Path("/home/dmhai/isaacsim")
|
||||
isaac_version_file = isaac_root / "VERSION"
|
||||
isaac_version = "Unknown"
|
||||
if isaac_version_file.exists():
|
||||
isaac_version = isaac_version_file.read_text().strip()
|
||||
print(f"[Isaac Sim] Root: {isaac_root} | Version: {isaac_version}")
|
||||
|
||||
kit_root = isaac_root / "kit"
|
||||
kit_exe = kit_root / "kit"
|
||||
print(f"[Omniverse Kit] Executable: {kit_exe} (exists: {kit_exe.exists()})")
|
||||
|
||||
return {
|
||||
"os_info": os_info,
|
||||
"disk_info": disk_info,
|
||||
"gpu_info": gpu_info,
|
||||
"isaac_version": isaac_version,
|
||||
"isaac_root": str(isaac_root),
|
||||
"kit_root": str(kit_root),
|
||||
}
|
||||
|
||||
def inspect_simulation_runtime(sys_data):
|
||||
"""Runtime simulation checks inside Isaac Sim Kit environment."""
|
||||
print("\n" + "=" * 70)
|
||||
print(" STAGE 2: Omniverse Kit & Isaac Sim Runtime Verification")
|
||||
print("=" * 70)
|
||||
|
||||
from isaacsim import SimulationApp
|
||||
simulation_app = SimulationApp({"headless": True, "hide_ui": True})
|
||||
|
||||
results = {}
|
||||
try:
|
||||
import numpy as np
|
||||
import omni.usd
|
||||
import omni.physx
|
||||
import omni.kit.app
|
||||
from pxr import Usd, UsdGeom, UsdPhysics, Gf
|
||||
from isaacsim.core.simulation_manager import SimulationManager
|
||||
import isaacsim.core.experimental.utils.app as app_utils
|
||||
from isaacsim.core.experimental.prims import RigidPrim, GeomPrim
|
||||
from isaacsim.core.experimental.objects import Cube, GroundPlane
|
||||
from isaacsim.robot_motion.cumotion import load_cumotion_supported_robot, RmpFlowController
|
||||
from isaacsim.storage.native import get_assets_root_path
|
||||
import omni.replicator.core as rep
|
||||
|
||||
# 1. OpenUSD Stage & SimulationManager
|
||||
print("\n[Test 1/5] Physics Scene & USD Stage...")
|
||||
SimulationManager.setup_simulation(dt=1.0 / 60.0, device="cuda")
|
||||
ground = GroundPlane("/World/GroundPlane")
|
||||
cube = Cube("/World/TestCube", positions=[np.array([0.0, 0.0, 1.0])], sizes=0.2)
|
||||
cube_rigid = RigidPrim(cube.paths)
|
||||
GeomPrim(cube.paths, apply_collision_apis=True)
|
||||
|
||||
app_utils.play()
|
||||
omni.kit.app.get_app().update()
|
||||
|
||||
# Step physics
|
||||
for _ in range(30):
|
||||
omni.kit.app.get_app().update()
|
||||
|
||||
cube_pos, _ = cube_rigid.get_world_poses()
|
||||
pos_np = cube_pos.numpy()
|
||||
dropped_z = float(pos_np[0, 2])
|
||||
physics_passed = dropped_z < 0.95
|
||||
print(f" Physics test: Cube dropped from Z=1.0m to Z={dropped_z:.4f}m. Passed: {physics_passed}")
|
||||
results["physics_verified"] = physics_passed
|
||||
results["physics_final_z"] = dropped_z
|
||||
|
||||
# 2. RTX Camera & Replicator
|
||||
print("\n[Test 2/5] RTX Camera Rendering & Annotators...")
|
||||
camera = rep.create.camera(position=(1.2, 1.2, 0.8), look_at=(0, 0, 0.1))
|
||||
render_product = rep.create.render_product(camera, (512, 512))
|
||||
rgb_annot = rep.AnnotatorRegistry.get_annotator("rgb")
|
||||
rgb_annot.attach([render_product])
|
||||
depth_annot = rep.AnnotatorRegistry.get_annotator("distance_to_image_plane")
|
||||
depth_annot.attach([render_product])
|
||||
sem_annot = rep.AnnotatorRegistry.get_annotator("semantic_segmentation")
|
||||
sem_annot.attach([render_product])
|
||||
|
||||
for _ in range(5):
|
||||
omni.kit.app.get_app().update()
|
||||
rep.orchestrator.step()
|
||||
|
||||
rgb_data = rgb_annot.get_data()
|
||||
depth_data = depth_annot.get_data()
|
||||
sem_data = sem_annot.get_data()
|
||||
|
||||
rgb_ok = rgb_data is not None and rgb_data.shape == (512, 512, 4)
|
||||
depth_ok = depth_data is not None and depth_data.shape == (512, 512)
|
||||
sem_ok = sem_data is not None
|
||||
print(f" RTX RGB rendered: shape={rgb_data.shape if rgb_data is not None else None} | OK: {rgb_ok}")
|
||||
print(f" RTX Depth rendered: shape={depth_data.shape if depth_data is not None else None} | OK: {depth_ok}")
|
||||
print(f" RTX Semantic Segmentation available: OK: {sem_ok}")
|
||||
results["rtx_camera_verified"] = rgb_ok and depth_ok and sem_ok
|
||||
|
||||
# 3. cuMotion Robot Motion Planning
|
||||
print("\n[Test 3/5] cuMotion Library & Franka Robot Model...")
|
||||
robot_config = load_cumotion_supported_robot("franka")
|
||||
tool_frames = robot_config.robot_description.tool_frame_names()
|
||||
cumotion_ok = len(tool_frames) > 0 and "panda_hand" in tool_frames
|
||||
print(f" cuMotion Franka tool frames: {tool_frames} | OK: {cumotion_ok}")
|
||||
results["cumotion_verified"] = cumotion_ok
|
||||
results["tool_frames"] = tool_frames
|
||||
|
||||
# 4. Storage & Asset Server Access
|
||||
print("\n[Test 4/5] NVIDIA Cloud Assets CDN...")
|
||||
assets_root = get_assets_root_path()
|
||||
assets_ok = assets_root.startswith("http")
|
||||
print(f" Asset root: {assets_root} | OK: {assets_ok}")
|
||||
results["assets_root"] = assets_root
|
||||
results["assets_accessible"] = assets_ok
|
||||
|
||||
# 5. Extension Ecosystem Check
|
||||
print("\n[Test 5/5] Required NVIDIA Extensions Verification...")
|
||||
ext_manager = omni.kit.app.get_app().get_extension_manager()
|
||||
required_exts = [
|
||||
"isaacsim.core.simulation_manager",
|
||||
"isaacsim.core.experimental.prims",
|
||||
"isaacsim.core.experimental.objects",
|
||||
"isaacsim.robot_motion.cumotion",
|
||||
"isaacsim.sensors.camera",
|
||||
"isaacsim.sensors.rtx",
|
||||
"omni.physx",
|
||||
"omni.replicator.core",
|
||||
"omni.usd",
|
||||
"omni.ui",
|
||||
]
|
||||
ext_statuses = {}
|
||||
for ext in required_exts:
|
||||
enabled = ext_manager.is_extension_enabled(ext)
|
||||
ext_statuses[ext] = enabled
|
||||
print(f" Extension '{ext}': {'ENABLED' if enabled else 'AVAILABLE/LOADABLE'}")
|
||||
results["extensions"] = ext_statuses
|
||||
|
||||
app_utils.stop()
|
||||
except Exception as e:
|
||||
print(f"[ERROR] Simulation runtime verification error: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
results["runtime_error"] = str(e)
|
||||
finally:
|
||||
full_report = {
|
||||
**sys_data,
|
||||
"runtime_verification": results
|
||||
}
|
||||
report_path = Path("/home/dmhai/Desktop/nvidia-omniverse/vision_guided_robot_simulation/docs/environment_verification_report.json")
|
||||
report_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with open(report_path, "w") as f:
|
||||
json.dump(full_report, f, indent=2)
|
||||
print(f"\n[REPORT] Verification report written to: {report_path}")
|
||||
|
||||
simulation_app.close()
|
||||
print("\nSimulationApp shut down cleanly.")
|
||||
|
||||
return results
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys_data = inspect_system_pre_app()
|
||||
runtime_data = inspect_simulation_runtime(sys_data)
|
||||
Reference in New Issue
Block a user