-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_vbot_debug.py
More file actions
51 lines (44 loc) · 1.59 KB
/
test_vbot_debug.py
File metadata and controls
51 lines (44 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from motrix_envs import registry
import motrix_envs.navigation.vbot.vbot_section001_np # Ensure it is registered
import numpy as np
import traceback
def test_env():
print("Creating environment...")
# Initialize the environment
try:
env = registry.make("vbot_navigation_section001", num_envs=2)
except Exception as e:
print(f"Failed to create env: {e}")
traceback.print_exc()
return
print("Resetting environment...")
try:
# NpEnv uses init_state() for the first reset, which returns NpEnvState
state = env.init_state()
obs = state.obs
info = state.info
print("Reset successful")
except Exception as e:
print(f"Reset failed: {e}")
traceback.print_exc()
return
print("Stepping environment...")
try:
for i in range(10):
# Create random actions
actions = np.zeros((env.num_envs, 12), dtype=np.float32)
# Step the environment
# NpEnv.step returns NpEnvState, not the standard tuple
state = env.step(actions)
obs = state.obs
reward = state.reward
terminated = state.terminated
truncated = state.truncated
info = state.info
print(f"Step {i+1} completed. Reward: mean={np.mean(reward):.2f}, min={np.min(reward):.2f}, max={np.max(reward):.2f}")
print(f"Terminated: {terminated}")
except Exception as e:
print(f"Step failed: {e}")
traceback.print_exc()
if __name__ == "__main__":
test_env()