minimal maniskill cpu step
Browse files
gradio-web/minimal_maniskill_cpu_step.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Minimal ManiSkill CPU sim/render sanity check.
|
| 2 |
+
|
| 3 |
+
This uses an official ManiSkill environment instead of RoboMME wrappers so the
|
| 4 |
+
execution path stays as small as possible.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import argparse
|
| 10 |
+
import warnings
|
| 11 |
+
|
| 12 |
+
import gymnasium as gym
|
| 13 |
+
import mani_skill.envs # noqa: F401 - registers ManiSkill environments
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
warnings.filterwarnings(
|
| 17 |
+
"ignore",
|
| 18 |
+
message=r"CUDA reports that you have .* fork_rng",
|
| 19 |
+
category=UserWarning,
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def main() -> None:
|
| 24 |
+
parser = argparse.ArgumentParser()
|
| 25 |
+
parser.add_argument("--env-id", default="PickCube-v1")
|
| 26 |
+
parser.add_argument("--seed", type=int, default=0)
|
| 27 |
+
args = parser.parse_args()
|
| 28 |
+
|
| 29 |
+
env = gym.make(
|
| 30 |
+
args.env_id,
|
| 31 |
+
obs_mode="rgbd",
|
| 32 |
+
control_mode="pd_joint_pos",
|
| 33 |
+
render_mode="rgb_array",
|
| 34 |
+
sim_backend="physx_cpu",
|
| 35 |
+
render_backend="sapien_cpu",
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
try:
|
| 39 |
+
obs, info = env.reset(seed=args.seed)
|
| 40 |
+
print(f"reset ok: env_id={args.env_id}")
|
| 41 |
+
print(f"obs keys: {list(obs.keys())}")
|
| 42 |
+
print(f"info keys: {list(info.keys())}")
|
| 43 |
+
|
| 44 |
+
action = env.action_space.sample()
|
| 45 |
+
obs, reward, terminated, truncated, info = env.step(action)
|
| 46 |
+
|
| 47 |
+
rgb = obs["sensor_data"]["base_camera"]["rgb"]
|
| 48 |
+
depth = obs["sensor_data"]["base_camera"]["depth"]
|
| 49 |
+
|
| 50 |
+
print("step ok")
|
| 51 |
+
print(f"reward={reward}")
|
| 52 |
+
print(f"terminated={terminated}")
|
| 53 |
+
print(f"truncated={truncated}")
|
| 54 |
+
print(f"rgb shape={tuple(rgb.shape)} dtype={rgb.dtype}")
|
| 55 |
+
print(f"depth shape={tuple(depth.shape)} dtype={depth.dtype}")
|
| 56 |
+
print(f"info keys after step: {list(info.keys())}")
|
| 57 |
+
finally:
|
| 58 |
+
env.close()
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
if __name__ == "__main__":
|
| 62 |
+
main()
|