-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_gripper.py
More file actions
executable file
·51 lines (42 loc) · 1.52 KB
/
test_gripper.py
File metadata and controls
executable file
·51 lines (42 loc) · 1.52 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
#!/usr/bin/env python3
"""
Test script to verify EZGripper model loads with MuJoCo 3.0+
"""
import mujoco
import mujoco.viewer
import os
# Get the directory of this script
script_dir = os.path.dirname(os.path.abspath(__file__))
model_path = os.path.join(script_dir, "ezgripper.xml")
print(f"Testing EZGripper model: {model_path}")
print(f"MuJoCo version: {mujoco.__version__}")
try:
# Load the model
model = mujoco.MjModel.from_xml_path(model_path)
data = mujoco.MjData(model)
print("✓ Model loaded successfully!")
print(f" - Number of bodies: {model.nbody}")
print(f" - Number of joints: {model.njnt}")
print(f" - Number of actuators: {model.nu}")
print(f" - Number of tendons: {model.ntendon}")
# Print actuator info
print("\nActuators:")
for i in range(model.nu):
actuator_name = mujoco.mj_id2name(model, mujoco.mjtObj.mjOBJ_ACTUATOR, i)
print(f" {i}: {actuator_name}")
# Print tendon info
print("\nTendons:")
for i in range(model.ntendon):
tendon_name = mujoco.mj_id2name(model, mujoco.mjtObj.mjOBJ_TENDON, i)
print(f" {i}: {tendon_name}")
# Launch interactive viewer
print("\nLaunching interactive viewer...")
print("Controls:")
print(" - Double-click on gripper to select")
print(" - Use sliders to control actuators")
print(" - Press ESC to exit")
mujoco.viewer.launch(model)
except Exception as e:
print(f"✗ Error loading model: {e}")
import traceback
traceback.print_exc()