forked from ci-group/revolve
-
Notifications
You must be signed in to change notification settings - Fork 1
/
revolve.py
executable file
·54 lines (44 loc) · 1.48 KB
/
revolve.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
#!/usr/bin/env python3
import os
import sys
from pyrevolve import parser
from pyrevolve.util import Supervisor
here = os.path.dirname(os.path.abspath(__file__))
rvpath = os.path.abspath(os.path.join(here, '..', 'revolve'))
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
class OnlineEvolutionSupervisor(Supervisor):
"""
Supervisor class that adds some output filtering for ODE errors
"""
def __init__(self, *args, **kwargs):
super(OnlineEvolutionSupervisor, self).__init__(*args, **kwargs)
self.ode_errors = 0
def write_stderr(self, data):
"""
:param data:
:return:
"""
if 'ODE Message 3' in data:
self.ode_errors += 1
elif data.strip():
sys.stderr.write(data)
if self.ode_errors >= 100:
self.ode_errors = 0
sys.stderr.write('ODE Message 3 (100)\n')
if __name__ == "__main__":
settings = parser.parse_args()
manager_settings = sys.argv[1:]
supervisor = OnlineEvolutionSupervisor(
manager_cmd=settings.manager,
manager_args=manager_settings,
world_file=settings.world,
simulator_cmd=settings.simulator_cmd,
simulator_args=["--verbose"],
plugins_dir_path=os.path.join(rvpath, 'build', 'lib'),
models_dir_path=os.path.join(rvpath, 'models')
)
if settings.manager is None:
ret = supervisor.launch_simulator()
else:
ret = supervisor.launch()
sys.exit(ret)