-
Notifications
You must be signed in to change notification settings - Fork 12
/
test_examples.py
89 lines (57 loc) · 1.95 KB
/
test_examples.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import os
import sys
import pathlib
import importlib
optas_path = pathlib.Path(
__file__
).parent.parent.resolve() # path to current working directory
examples_path = optas_path / "example"
sys.path.append(str(examples_path.absolute()))
def import_module(path):
spec = importlib.util.spec_from_file_location("user_module", path)
module = importlib.util.module_from_spec(spec)
sys.modules["module.name"] = module
spec.loader.exec_module(module)
return module
def load_main_function(filename):
path = examples_path / filename
# Get main function handle from filename
module = import_module(path)
main = getattr(module, "main")
return main
def test_dual_arm():
main = load_main_function("dual_arm.py")
assert main(gui=False) == 0
def test_planar_idk():
main = load_main_function("planar_idk.py")
assert main() == 0
def test_planar_ik():
main = load_main_function("planar_ik.py")
assert main() == 0
def test_figure_eight_plan():
main = load_main_function("figure_eight_plan.py")
assert main(gui=False) == 0
def test_figure_eight_plan_6dof():
main = load_main_function("figure_eight_plan_6dof.py")
assert main(gui=False) == 0
def test_point_mass_mpc():
main = load_main_function("point_mass_mpc.py")
assert main(show=False) == 0
def test_point_mass_planner():
main = load_main_function("point_mass_planner.py")
assert main(show=False) == 0
def test_pushing():
main = load_main_function("pushing.py")
assert main(gui=False) == 0
def test_pushing():
main = load_main_function("pushing.py")
assert main(gui=False) == 0
def test_pybullet_api():
main = load_main_function("pybullet_api.py")
assert main(gui=False) == 0
def test_simple_joint_space_planner():
main = load_main_function("simple_joint_space_planner.py")
assert main(gui=False) == 0
# def test_example():
# path = examples_path / "example.py"
# module = import_module(path)