| 15 | |
| 16 | # VecEnv Wrapper for RL training |
| 17 | class VecTask(): |
| 18 | def __init__(self, task, rl_device, clip_observations=5.0, clip_actions=1.0): |
| 19 | self.task = task |
| 20 | |
| 21 | self.num_environments = task.num_envs |
| 22 | self.num_agents = 1 # used for multi-agent environments |
| 23 | self.num_observations = task.num_obs |
| 24 | self.num_states = task.num_states |
| 25 | self.num_actions = task.num_actions |
| 26 | |
| 27 | self.obs_space = spaces.Box(np.ones(self.num_obs) * -np.Inf, np.ones(self.num_obs) * np.Inf) |
| 28 | self.state_space = spaces.Box(np.ones(self.num_states) * -np.Inf, np.ones(self.num_states) * np.Inf) |
| 29 | self.act_space = spaces.Box(np.ones(self.num_actions) * -1., np.ones(self.num_actions) * 1.) |
| 30 | |
| 31 | self.clip_obs = clip_observations |
| 32 | self.clip_actions = clip_actions |
| 33 | self.rl_device = rl_device |
| 34 | |
| 35 | print("RL device: ", rl_device) |
| 36 | |
| 37 | def step(self, actions): |
| 38 | raise NotImplementedError |
| 39 | |
| 40 | def reset(self): |
| 41 | raise NotImplementedError |
| 42 | |
| 43 | def get_number_of_agents(self): |
| 44 | return self.num_agents |
| 45 | |
| 46 | @property |
| 47 | def observation_space(self): |
| 48 | return self.obs_space |
| 49 | |
| 50 | @property |
| 51 | def action_space(self): |
| 52 | return self.act_space |
| 53 | |
| 54 | @property |
| 55 | def num_envs(self): |
| 56 | return self.num_environments |
| 57 | |
| 58 | @property |
| 59 | def num_acts(self): |
| 60 | return self.num_actions |
| 61 | |
| 62 | @property |
| 63 | def num_obs(self): |
| 64 | return self.num_observations |
| 65 | |
| 66 | |
| 67 | # C++ CPU Class |
nothing calls this directly
no outgoing calls
no test coverage detected