-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
65 lines (41 loc) · 1.43 KB
/
run.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
import isaacgym
import hydra
from omegaconf import DictConfig, OmegaConf
from common.util import omegaconf_to_dict, print_dict, fix_wandb, update_dict
import torch
import numpy as np
import wandb
def get_agent(cfg_dict):
if "pid" in cfg_dict["agent"]["name"].lower():
from agents.pidcontrol import BlimpPositionController
agent = BlimpPositionController(cfg_dict)
elif "rmacomp" in cfg_dict["agent"]["name"].lower():
from agents.rmacompose import RMACompAgent
agent = RMACompAgent(cfg_dict)
elif "comp" in cfg_dict["agent"]["name"].lower():
from agents.compose import CompAgent
agent = CompAgent(cfg_dict)
elif "sac" in cfg_dict["agent"]["name"].lower():
from agents.sac import SACAgent
agent = SACAgent(cfg_dict)
else:
raise NotImplementedError
return agent
@hydra.main(config_name="config", config_path="./cfg")
def launch_rlg_hydra(cfg: DictConfig):
cfg_dict = omegaconf_to_dict(cfg)
if cfg_dict["wandb_log"]:
wandb.init()
else:
wandb.init(mode="disabled")
wandb_dict = fix_wandb(wandb.config)
update_dict(cfg_dict, wandb_dict)
cfg_dict["buffer"]["n_env"] = cfg_dict["env"]["num_envs"]
print_dict(cfg_dict)
torch.manual_seed(cfg_dict["seed"])
np.random.seed(cfg_dict["seed"])
agent = get_agent(cfg_dict)
agent.run()
wandb.finish()
if __name__ == "__main__":
launch_rlg_hydra()