Spaces:
Sleeping
Sleeping
Explicitly Reset the Simulation State
Browse files- tray_sim.py +17 -2
tray_sim.py
CHANGED
|
@@ -133,11 +133,25 @@ def format_as_natural_language_prompt(scene_description, task_description=None):
|
|
| 133 |
|
| 134 |
return "\n".join(lines)
|
| 135 |
|
| 136 |
-
def run_tray_simulation(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
np.random.seed(seed)
|
| 138 |
model = mujoco.MjModel.from_xml_path(MODEL_PATH)
|
| 139 |
data = mujoco.MjData(model)
|
| 140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
# Apply a transient force to the tray
|
| 143 |
tray_force_applied = True # False # One-time trigger
|
|
@@ -168,6 +182,7 @@ def run_tray_simulation(seed=0, num_objects=N_OBJECTS, azimuth=45, elevation=-25
|
|
| 168 |
data.qpos[obj_start:obj_start+3] = pos
|
| 169 |
data.qpos[obj_start+3:obj_start+7] = quat
|
| 170 |
data.qvel[i*6:i*6+6] = 0
|
|
|
|
| 171 |
|
| 172 |
# Renderer setup
|
| 173 |
renderer = mujoco.Renderer(model, width=480, height=480) # width=640, height=640
|
|
|
|
| 133 |
|
| 134 |
return "\n".join(lines)
|
| 135 |
|
| 136 |
+
def run_tray_simulation(
|
| 137 |
+
seed=0,
|
| 138 |
+
num_objects=N_OBJECTS,
|
| 139 |
+
azimuth=45,
|
| 140 |
+
elevation=-25,
|
| 141 |
+
distance=0.6
|
| 142 |
+
):
|
| 143 |
np.random.seed(seed)
|
| 144 |
model = mujoco.MjModel.from_xml_path(MODEL_PATH)
|
| 145 |
data = mujoco.MjData(model)
|
| 146 |
+
|
| 147 |
+
# Explicitly reset the simulation state
|
| 148 |
+
mujoco.mj_resetData(model, data)
|
| 149 |
+
|
| 150 |
+
tray_id = mujoco.mj_name2id(
|
| 151 |
+
model,
|
| 152 |
+
mujoco.mjtObj.mjOBJ_BODY,
|
| 153 |
+
"tray"
|
| 154 |
+
)
|
| 155 |
|
| 156 |
# Apply a transient force to the tray
|
| 157 |
tray_force_applied = True # False # One-time trigger
|
|
|
|
| 182 |
data.qpos[obj_start:obj_start+3] = pos
|
| 183 |
data.qpos[obj_start+3:obj_start+7] = quat
|
| 184 |
data.qvel[i*6:i*6+6] = 0
|
| 185 |
+
print(f"Object {i} initial position: {pos}") # Debug print
|
| 186 |
|
| 187 |
# Renderer setup
|
| 188 |
renderer = mujoco.Renderer(model, width=480, height=480) # width=640, height=640
|