File size: 1,489 Bytes
0210a65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Inspect state observations and kinematics for both 6-DoF (so100) and 7-DoF (panda) in ManiSkill 3
"""
import gymnasium as gym
import numpy as np
import mani_skill.envs

print("=" * 70)
print("INSPECTING ROBOT STATES & KINEMATICS")
print("=" * 70)

for uid in ["panda", "so100"]:
    print(f"\n--- Robot: {uid} ---")
    try:
        env = gym.make(
            "PickCube-v1",
            robot_uids=uid,
            obs_mode="state",
            control_mode="pd_joint_pos",
            sim_backend="cpu",
            render_backend="cpu",
        )
        obs, _ = env.reset()
        robot = env.unwrapped.agent.robot
        qpos = robot.get_qpos()
        qvel = robot.get_qvel()
        qlimits = robot.get_qlimits()
        print(f"[+] Robot {uid} DoF: {robot.dof}")
        print(f"[+] qpos shape: {qpos.shape}, dtype: {qpos.dtype}")
        print(f"[+] qvel shape: {qvel.shape}")
        print(f"[+] qlimits shape: {qlimits.shape}")
        print(f"[+] qlimits min: {qlimits[0, :, 0] if qlimits.ndim == 3 else qlimits[:, 0]}")
        print(f"[+] qlimits max: {qlimits[0, :, 1] if qlimits.ndim == 3 else qlimits[:, 1]}")
        
        # Test 1 step
        act = env.action_space.sample()
        obs, rew, term, trunc, info = env.step(act)
        print(f"[+] Step successful! Rew: {rew}, Term: {term}, Trunc: {trunc}")
        env.close()
    except Exception as e:
        print(f"[!] Error inspecting {uid}: {e}")
        import traceback
        traceback.print_exc()