minimal robomme env cpu step
Browse files
scripts/minimal_robomme_env_cpu_step.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Minimal RoboMME custom-env CPU sanity check.
|
| 2 |
+
|
| 3 |
+
This bypasses BenchmarkEnvBuilder/make_env_for_episode and instantiates a
|
| 4 |
+
RoboMME custom environment class directly.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import argparse
|
| 10 |
+
import faulthandler
|
| 11 |
+
import os
|
| 12 |
+
import sys
|
| 13 |
+
import warnings
|
| 14 |
+
from pathlib import Path
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
| 18 |
+
SRC_DIR = PROJECT_ROOT / "src"
|
| 19 |
+
|
| 20 |
+
if str(PROJECT_ROOT) not in sys.path:
|
| 21 |
+
sys.path.insert(0, str(PROJECT_ROOT))
|
| 22 |
+
if str(SRC_DIR) not in sys.path:
|
| 23 |
+
sys.path.insert(0, str(SRC_DIR))
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def configure_cpu_only_runtime() -> None:
|
| 27 |
+
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
|
| 28 |
+
os.environ["NVIDIA_VISIBLE_DEVICES"] = "void"
|
| 29 |
+
os.environ["SAPIEN_RENDER_DEVICE"] = "cpu"
|
| 30 |
+
os.environ.pop("NVIDIA_DRIVER_CAPABILITIES", None)
|
| 31 |
+
os.environ.pop("VK_ICD_FILENAMES", None)
|
| 32 |
+
os.environ.pop("MUJOCO_GL", None)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
configure_cpu_only_runtime()
|
| 36 |
+
faulthandler.enable(all_threads=True)
|
| 37 |
+
|
| 38 |
+
warnings.filterwarnings(
|
| 39 |
+
"ignore",
|
| 40 |
+
message=r"CUDA reports that you have .* fork_rng",
|
| 41 |
+
category=UserWarning,
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def main() -> None:
|
| 46 |
+
parser = argparse.ArgumentParser()
|
| 47 |
+
parser.add_argument("--env-class", default="StopCube")
|
| 48 |
+
parser.add_argument("--seed", type=int, default=0)
|
| 49 |
+
args = parser.parse_args()
|
| 50 |
+
|
| 51 |
+
import robomme.robomme_env as robomme_env
|
| 52 |
+
|
| 53 |
+
env_cls = getattr(robomme_env, args.env_class)
|
| 54 |
+
env = None
|
| 55 |
+
|
| 56 |
+
print(f"instantiate start: env_class={args.env_class}", flush=True)
|
| 57 |
+
try:
|
| 58 |
+
env = env_cls(
|
| 59 |
+
obs_mode="rgb+depth+segmentation",
|
| 60 |
+
control_mode="pd_joint_pos",
|
| 61 |
+
render_mode="rgb_array",
|
| 62 |
+
reward_mode="dense",
|
| 63 |
+
sim_backend="physx_cpu",
|
| 64 |
+
render_backend="sapien_cpu",
|
| 65 |
+
seed=args.seed,
|
| 66 |
+
)
|
| 67 |
+
print("instantiate ok", flush=True)
|
| 68 |
+
|
| 69 |
+
obs, info = env.reset(seed=args.seed)
|
| 70 |
+
print(f"reset ok: obs keys={list(obs.keys())}", flush=True)
|
| 71 |
+
print(f"reset info keys={list(info.keys())}", flush=True)
|
| 72 |
+
|
| 73 |
+
action = env.action_space.sample()
|
| 74 |
+
obs, reward, terminated, truncated, info = env.step(action)
|
| 75 |
+
rgb = obs["sensor_data"]["base_camera"]["rgb"]
|
| 76 |
+
depth = obs["sensor_data"]["base_camera"]["depth"]
|
| 77 |
+
|
| 78 |
+
print("step ok", flush=True)
|
| 79 |
+
print(f"reward={reward}", flush=True)
|
| 80 |
+
print(f"terminated={terminated}", flush=True)
|
| 81 |
+
print(f"truncated={truncated}", flush=True)
|
| 82 |
+
print(f"rgb shape={tuple(rgb.shape)} dtype={rgb.dtype}", flush=True)
|
| 83 |
+
print(f"depth shape={tuple(depth.shape)} dtype={depth.dtype}", flush=True)
|
| 84 |
+
print(f"step info keys={list(info.keys())}", flush=True)
|
| 85 |
+
finally:
|
| 86 |
+
if env is not None:
|
| 87 |
+
env.close()
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
if __name__ == "__main__":
|
| 91 |
+
main()
|