-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_xml_parsing.py
More file actions
61 lines (48 loc) · 1.46 KB
/
check_xml_parsing.py
File metadata and controls
61 lines (48 loc) · 1.46 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
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
"""
Check if XML spring definition is being parsed correctly.
"""
import mujoco
import numpy as np
import os
print("="*80)
print("XML PARSING CHECK")
print("="*80)
# Load model
model_path = os.path.join(os.path.dirname(__file__), 'ezgripper.xml')
model = mujoco.MjModel.from_xml_path(model_path)
# Check the raw XML content
print(f"\nChecking XML joint definition...")
# Read the XML file directly
with open(model_path, 'r') as f:
xml_content = f.read()
# Find the joint definition
import re
joint_pattern = r'<joint[^>]*name="F1_palm_knuckle"[^>]*>.*?</joint>'
joint_match = re.search(joint_pattern, xml_content, re.DOTALL)
if joint_match:
joint_xml = joint_match.group(0)
print(f"Found joint definition:")
print(joint_xml)
else:
print("Joint definition not found!")
# Check all joint definitions
print(f"\n" + "="*50)
print("ALL JOINT DEFINITIONS:")
print("="*50)
all_joints = re.findall(r'<joint[^>]*name="[^"]*"[^>]*>', xml_content)
for joint in all_joints:
if 'stiffness' in joint or 'springref' in joint:
print(joint)
# Check if there are any actuator springs that might override
print(f"\n" + "="*50)
print("ACTUATOR DEFINITIONS:")
print("="*50)
actuator_pattern = r'<actuator>.*?</actuator>'
actuator_match = re.search(actuator_pattern, xml_content, re.DOTALL)
if actuator_match:
actuators_xml = actuator_match.group(0)
print(actuators_xml)
else:
print("No actuators found (tendons disabled)")
print("="*80)