han-xudong commited on
Commit
509b0c4
·
verified ·
1 Parent(s): e6ff778

Qualify the native RoboCasa OpenDoor Task Program

Browse files
scene_assets/robocasa365_v1/validation/task_programs/open_microwave/README.md ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # RoboCasa365 OpenMicrowave · OpenDoor Task Program
2
+ The default Franka deployment runs a single registered `simulation.open_door` call. The episode starts with the fixture closed. The robot grasps the physical vertical handle, opens the negative-direction hinge, releases and retreats. The measured predicate requires at least 81° of the 90° travel. The final criterion is evaluated against the live joint.
3
+
4
+ The video includes reset and each consecutive control tick from one native hybrid-renderer, CPU PhysX episode. `episode.json` matches every image to the simulator time, hinge angle, robot joints and controller action; it includes the program and skill runtime receipt. `qa.json` reports the decoded PTS, threshold crossing and final measurement. `native_trajectory/traj_env0_000000.pt` is a separate first-attempt public CLI run at the same seed, recorded by the framework. The source appliance archive and credit are linked from the task README.
5
+
6
+ ## Reproduce
7
+
8
+ Check out [the verified source](https://github.com/han-xudong/EmbodiChain/tree/cbc2096c408d6939e764d0455ac978e1e6214211), install the simulation dependencies, and use the repository root as the working directory.
9
+
10
+ ```sh
11
+ embodichain run-task --gym-config embodichain/extensions/tasks/configs/tasks/manipulation/robocasa365_open_microwave/task.franka.yaml --headless --disable-sensor --renderer no-render --device cpu --seed 0 --record-trajectory --trajectory-save-dir outputs/microwave
12
+ python record.py --seed 0 --output-dir outputs/microwave_camera
13
+ ```
14
+
15
+ Download the adjacent `record.py` for the second command and make the checkout importable. The camera run requires the native hybrid renderer and a display or Xvfb.
scene_assets/robocasa365_v1/validation/task_programs/open_microwave/episode.json ADDED
The diff for this file is too large to render. See raw diff
 
scene_assets/robocasa365_v1/validation/task_programs/open_microwave/native_trajectory/traj_env0_000000.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f3570f0b6aab608f0d99fdf8daf3d24f684f05ae4454a7fcd5b191d66b34382
3
+ size 129634
scene_assets/robocasa365_v1/validation/task_programs/open_microwave/open_microwave.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a22fecb8d3ea1d047bac65984b550e76a2e22f28d9585b3d948be9c863b77dce
3
+ size 584149
scene_assets/robocasa365_v1/validation/task_programs/open_microwave/qa.json ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "source": "cbc2096c408d6939e764d0455ac978e1e6214211",
3
+ "task_id": "RoboCasa365OpenMicrowave-TaskProgram-Franka-v1",
4
+ "seed": 0,
5
+ "attempts": 1,
6
+ "camera": "cam_high",
7
+ "physics_backend": "physx",
8
+ "frames": 293,
9
+ "resolution": [
10
+ 640,
11
+ 480
12
+ ],
13
+ "fps": 25,
14
+ "duration_seconds": 11.72,
15
+ "consecutive_pts": true,
16
+ "first_frame_to_last_mean_absolute_rgb_difference_0_to_255": 7.0149153645833335,
17
+ "control_steps": 292,
18
+ "gym_success": true,
19
+ "call": "simulation.open_door",
20
+ "skill": "open_door",
21
+ "planned_commands": 292,
22
+ "first_90_percent_step": 225,
23
+ "start_hinge_rad": 0.0,
24
+ "end_hinge_rad": -1.5707963705062866,
25
+ "end_opening_fraction": 1.0,
26
+ "end_opening_degrees": 90.00000250447816,
27
+ "end_fingers_m": [
28
+ 0.03999890759587288,
29
+ 0.03992784023284912
30
+ ],
31
+ "robot_joints": [
32
+ "fr3_joint1",
33
+ "fr3_joint2",
34
+ "fr3_joint3",
35
+ "fr3_joint4",
36
+ "fr3_joint5",
37
+ "fr3_joint6",
38
+ "fr3_joint7",
39
+ "fr3_finger_joint1",
40
+ "fr3_finger_joint2"
41
+ ],
42
+ "video_sha256": "a22fecb8d3ea1d047bac65984b550e76a2e22f28d9585b3d948be9c863b77dce"
43
+ }
scene_assets/robocasa365_v1/validation/task_programs/open_microwave/record.py ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ----------------------------------------------------------------------------
2
+ # Copyright (c) 2021-2026 DexForce Technology Co., Ltd.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ # ----------------------------------------------------------------------------
16
+
17
+ """Record the native microwave expert and the hinge position of every video frame."""
18
+
19
+ from __future__ import annotations
20
+
21
+ import argparse
22
+ from fractions import Fraction
23
+ import json
24
+ import math
25
+ import subprocess
26
+ from pathlib import Path
27
+ from tempfile import TemporaryDirectory
28
+
29
+ import av
30
+
31
+ from embodichain.extensions import tasks # Register the workcell.
32
+ from embodichain.lab.gym.envs.demo import execute_demo_episode
33
+ from embodichain.lab.gym.utils.gym_utils import config_to_cfg
34
+ from embodichain.lab.gym.utils.registration import make
35
+ from embodichain.utils.utility import load_config
36
+
37
+
38
+ def main() -> None:
39
+ """Run one seeded episode, writing an H.264 video and its measurement trace."""
40
+ parser = argparse.ArgumentParser(description=__doc__)
41
+ parser.add_argument("--output-dir", type=Path, required=True)
42
+ parser.add_argument("--seed", type=int, default=0)
43
+ args = parser.parse_args()
44
+ source = (
45
+ Path(tasks.__file__).resolve().parent
46
+ / "configs/tasks/manipulation/"
47
+ "robocasa365_open_microwave/task.franka.yaml"
48
+ )
49
+ payload = load_config(source)
50
+ payload.update(
51
+ headless=True,
52
+ device="cpu",
53
+ renderer="hybrid",
54
+ enable_sensor=True,
55
+ seed=args.seed,
56
+ )
57
+ env = make(payload["id"], cfg=config_to_cfg(payload, source_path=source))
58
+ try:
59
+ obs, _ = env.reset(seed=args.seed, options={"save_data": False})
60
+ fixture = env.sim.get_articulation("microwave")
61
+ joint = fixture.joint_names.index("microwave_right_group_1_microjoint")
62
+ lower, upper = fixture.get_qpos_limits()[0, joint].tolist()
63
+ fps = Fraction(str(env.control_frequency)).limit_denominator()
64
+ samples = []
65
+ args.output_dir.mkdir(parents=True, exist_ok=True)
66
+ with TemporaryDirectory(dir=args.output_dir) as tmp:
67
+ video = Path(tmp) / "open_microwave.mp4"
68
+ with av.open(str(video), mode="w") as container:
69
+ stream = container.add_stream("libx264", rate=fps)
70
+ image = obs["sensor"]["cam_high"]["color"][0]
71
+ stream.height, stream.width = image.shape[:2]
72
+ stream.pix_fmt = "yuv420p"
73
+ stream.options = {"crf": "18"}
74
+
75
+ def capture(observation, action=None):
76
+ qpos = env.robot.get_qpos()[0]
77
+ targets = None if action is None else action.value[0].detach().cpu().tolist()
78
+ rgb = observation["sensor"]["cam_high"]["color"][0, ..., :3]
79
+ frame = av.VideoFrame.from_ndarray(
80
+ rgb.contiguous().cpu().numpy(), format="rgb24"
81
+ )
82
+ for packet in stream.encode(frame):
83
+ container.mux(packet)
84
+ angle = float(fixture.get_qpos()[0, joint])
85
+ simulation_time = float(env.sim.simulation_time)
86
+ if samples and not math.isclose(
87
+ simulation_time - samples[-1]["simulation_time_s"],
88
+ 1 / float(fps),
89
+ abs_tol=1e-6,
90
+ ):
91
+ raise RuntimeError(
92
+ "Camera observations must cover successive control steps."
93
+ )
94
+ samples.append(
95
+ {
96
+ "step": len(samples),
97
+ "video_time_s": len(samples) / float(fps),
98
+ "simulation_time_s": simulation_time,
99
+ "hinge_rad": angle,
100
+ "robot_qpos": qpos.detach().cpu().tolist(),
101
+ "controller_targets": targets,
102
+ "opening_fraction": (upper - angle) / (upper - lower),
103
+ }
104
+ )
105
+
106
+ capture(obs)
107
+ result = execute_demo_episode(
108
+ env,
109
+ step_observer=lambda active, action, observation: capture(
110
+ observation, action
111
+ ),
112
+ )
113
+ for packet in stream.encode():
114
+ container.mux(packet)
115
+ if (
116
+ not result.completed
117
+ or not result.all_success
118
+ or not bool(env.is_task_success()[0])
119
+ ):
120
+ raise RuntimeError(f"Microwave expert failed: {result.to_metadata()}")
121
+ if len(samples) != result.length + 1:
122
+ raise RuntimeError(
123
+ "Camera sampling must include reset and every control step."
124
+ )
125
+ metrics = {
126
+ "task": payload["id"],
127
+ "source_commit": subprocess.check_output(
128
+ ["git", "-C", str(Path(tasks.__file__).parent), "rev-parse", "HEAD"], text=True
129
+ ).strip(),
130
+ "units": {"hinge": "rad", "arm_joints": "rad", "finger_joints": "m"},
131
+ "robot_joints": list(env.robot.joint_names),
132
+ "physical_joint": fixture.joint_names[joint],
133
+ "first_threshold_crossing_step": next(x["step"] for x in samples if x["opening_fraction"] >= .9),
134
+ "task_program": result.to_metadata(),
135
+ "seed": args.seed,
136
+ "physics_backend": "physx",
137
+ "renderer": "hybrid",
138
+ "camera": "cam_high",
139
+ "fps": float(fps),
140
+ "width": stream.width,
141
+ "height": stream.height,
142
+ "frames": len(samples),
143
+ "control_steps": result.length,
144
+ "duration_s": len(samples) / float(fps),
145
+ "hinge_limits_rad": [lower, upper],
146
+ "acceptance_fraction": 0.9,
147
+ "success": result.all_success,
148
+ "terminal_reason": result.terminal_reason,
149
+ "segments": [
150
+ {"name": s.name, "start_step": s.start_step, "end_step": s.end_step}
151
+ for s in result.segments
152
+ ],
153
+ "samples": samples,
154
+ }
155
+ trace = Path(tmp) / "episode.json"
156
+ trace.write_text(json.dumps(metrics, indent=2, allow_nan=False) + "\n")
157
+ video.replace(args.output_dir / video.name)
158
+ trace.replace(args.output_dir / trace.name)
159
+ print(
160
+ f"{result.length} control steps, {len(samples)} RGB frames, final opening {samples[-1]['opening_fraction']:.3f}"
161
+ )
162
+ finally:
163
+ env.close(exit_process=False)
164
+
165
+
166
+ if __name__ == "__main__":
167
+ main()
scene_assets/robocasa365_v1/validation/task_programs/open_microwave/sha256.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "README.md": {
3
+ "bytes": 1712,
4
+ "sha256": "dc9a37f7057724243b916ffbb7fffe875c284712327f67ceabf33e01b667415b"
5
+ },
6
+ "episode.json": {
7
+ "bytes": 264569,
8
+ "sha256": "a197dfb78da1596f25beba2fb528dbf83b838a2735f16b716aa348273d6882eb"
9
+ },
10
+ "native_trajectory/traj_env0_000000.pt": {
11
+ "bytes": 129634,
12
+ "sha256": "8f3570f0b6aab608f0d99fdf8daf3d24f684f05ae4454a7fcd5b191d66b34382"
13
+ },
14
+ "open_microwave.mp4": {
15
+ "bytes": 584149,
16
+ "sha256": "a22fecb8d3ea1d047bac65984b550e76a2e22f28d9585b3d948be9c863b77dce"
17
+ },
18
+ "qa.json": {
19
+ "bytes": 1081,
20
+ "sha256": "dd89f1f138c487aac929b02e6d1f02a6fbd624fc19dde20b0e5de833dcfa433d"
21
+ },
22
+ "record.py": {
23
+ "bytes": 7359,
24
+ "sha256": "b1fb13388892bd1b247a8031e2ddf2f6ef3d4b5e9627f8cd4fe14f13aad9e125"
25
+ }
26
+ }