create model.urdf for every objects inside google_16k that loads the object. These .urdf paths need to be passed to Isaac Gym to load the models.
Browse files- add_urdf_loader.py +46 -0
add_urdf_loader.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
# Directory where subdirectories are located
|
4 |
+
base_dir = '.'
|
5 |
+
|
6 |
+
# Get all subdirectory names in the base directory
|
7 |
+
subdirectories = [name for name in os.listdir(base_dir) if os.path.isdir(os.path.join(base_dir, name))]
|
8 |
+
|
9 |
+
# Iterate through each subdirectory
|
10 |
+
for subdir in subdirectories:
|
11 |
+
# Define the path to the URDF file
|
12 |
+
urdf_file = os.path.join(base_dir, subdir, 'google_16k', 'model.urdf')
|
13 |
+
|
14 |
+
# Create the URDF content
|
15 |
+
urdf_content = f'''<robot name="{subdir}">
|
16 |
+
<link name="link">
|
17 |
+
<inertial>
|
18 |
+
<origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
|
19 |
+
<mass value="0.3" />
|
20 |
+
<inertia ixx="6.9144774308701545e-06" ixy="1.0257828334065293e-08" ixz="-1.590110554892427e-09" iyy="6.8933748177717795e-06" iyz="-6.199552338721599e-09" izz="7.782976960493179e-06" />
|
21 |
+
</inertial>
|
22 |
+
<visual>
|
23 |
+
<origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
|
24 |
+
<geometry>
|
25 |
+
<mesh filename="nontextured_proc.stl" />
|
26 |
+
</geometry>
|
27 |
+
</visual>
|
28 |
+
<collision>
|
29 |
+
<origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0"/>
|
30 |
+
<geometry>
|
31 |
+
<mesh filename="nontextured_proc.stl" />
|
32 |
+
</geometry>
|
33 |
+
</collision>
|
34 |
+
</link>
|
35 |
+
</robot>
|
36 |
+
'''
|
37 |
+
|
38 |
+
# Write the URDF content to the file
|
39 |
+
os.makedirs(os.path.dirname(urdf_file), exist_ok=True)
|
40 |
+
with open(urdf_file, 'w') as f:
|
41 |
+
f.write(urdf_content)
|
42 |
+
|
43 |
+
print(f'Created URDF file for {subdir}.')
|
44 |
+
|
45 |
+
print('Task completed.')
|
46 |
+
|