-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrun_all.py
45 lines (40 loc) · 1.55 KB
/
run_all.py
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
import os
import pinocchio
import mujoco
from onshape_to_robot.message import bright, error, info
examples = [
"2wheels_urdf", "2wheels_mujoco",
"adjustable_height_arm_urdf", "adjustable_height_arm_mujoco",
"rsk_urdf", "rsk_mujoco",
"quadruped_urdf", "quadruped_mujoco",
"dog_urdf", "dog_mujoco",
"sigmaban2019_urdf", "sigmaban2019_mujoco",
"orbita_mujoco",
"field_urdf", "field_mujoco",
]
def process_example(example: str):
print('')
print(bright(f"========== Running {example} =========="))
print("")
result = os.system(f"python -m onshape_to_robot.export {example}")
if result == 0:
if "urdf" in example:
print(info("Loading model in pinocchio"))
output_filename = f"{example}/robot.urdf"
model = pinocchio.buildModelFromUrdf(output_filename)
pinocchio.buildGeomFromUrdf(model, output_filename, pinocchio.COLLISION, package_dirs=os.path.dirname(output_filename))
pinocchio.buildGeomFromUrdf(model, output_filename, pinocchio.VISUAL, package_dirs=os.path.dirname(output_filename))
elif "mujoco" in example:
print(info("Loading model in mujoco"))
output_filename = f"{example}/scene.xml"
mujoco.MjModel.from_xml_path(output_filename)
else:
raise Exception(f"Failed to run example {example}")
for example in examples:
try:
process_example(example)
except Exception as e:
print("")
print(error(f"Failed to run example {example}"))
print(e)
input()