-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcheck_model.py
More file actions
38 lines (33 loc) · 1.06 KB
/
check_model.py
File metadata and controls
38 lines (33 loc) · 1.06 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
import argparse
import os
from onshape_to_robot.message import bright, error, info
arg_parser = argparse.ArgumentParser(description="Test loading a model")
arg_parser.add_argument(
"model_name",
type=str,
help="The example to test loading (e.g., '2wheels_urdf', '2wheels_mujoco', etc.)",
)
args = arg_parser.parse_args()
if "urdf" in args.model_name:
import pinocchio
print(info("Loading model in pinocchio"))
output_filename = f"{args.model_name}/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),
)
print(model)
elif "mujoco" in args.model_name:
import mujoco
print(info("Loading model in mujoco"))
output_filename = f"{args.model_name}/scene.xml"
mujoco.MjModel.from_xml_path(output_filename)