|
9 | 9 | import os
|
10 | 10 | import time
|
11 | 11 |
|
12 |
| - |
13 |
| -class TorcsEnv: |
| 12 | +# SIDD: To fix spec not found error while using openai baselines a2c |
| 13 | +class TorcsEnv(gym.Env): |
14 | 14 | terminal_judge_start = 500 # Speed limit is applied after this step
|
15 | 15 | termination_limit_progress = 5 # [km/h], episode terminates if car is running slower than this limit
|
16 | 16 | default_speed = 50
|
@@ -52,14 +52,17 @@ def __init__(self, vision=False, throttle=False, gear_change=False):
|
52 | 52 | else:
|
53 | 53 | self.action_space = spaces.Box(low=-1.0, high=1.0, shape=(2,))
|
54 | 54 |
|
55 |
| - if vision is False: |
56 |
| - high = np.array([1., np.inf, np.inf, np.inf, 1., np.inf, 1., np.inf]) |
57 |
| - low = np.array([0., -np.inf, -np.inf, -np.inf, 0., -np.inf, 0., -np.inf]) |
58 |
| - self.observation_space = spaces.Box(low=low, high=high) |
59 |
| - else: |
60 |
| - high = np.array([1., np.inf, np.inf, np.inf, 1., np.inf, 1., np.inf, 255]) |
61 |
| - low = np.array([0., -np.inf, -np.inf, -np.inf, 0., -np.inf, 0., -np.inf, 0]) |
62 |
| - self.observation_space = spaces.Box(low=low, high=high) |
| 55 | + low = np.array([-np.pi , 0, 0, -np.inf, -np.inf, -np.inf, -np.inf, 0]) |
| 56 | + high = np.array([np.pi, np.inf, np.inf, np.inf, np.inf, np.inf, np.inf, np.inf]) |
| 57 | + self.observation_space = spaces.Box(low=low, high=high) |
| 58 | + # if vision is False: |
| 59 | + # high = np.array([1., np.inf, np.inf, np.inf, 1., np.inf, 1., np.inf]) |
| 60 | + # low = np.array([0., -np.inf, -np.inf, -np.inf, 0., -np.inf, 0., -np.inf]) |
| 61 | + # self.observation_space = spaces.Box(low=low, high=high) |
| 62 | + # else: |
| 63 | + # high = np.array([1., np.inf, np.inf, np.inf, 1., np.inf, 1., np.inf, 255]) |
| 64 | + # low = np.array([0., -np.inf, -np.inf, -np.inf, 0., -np.inf, 0., -np.inf, 0]) |
| 65 | + # self.observation_space = spaces.Box(low=low, high=high) |
63 | 66 |
|
64 | 67 | def step(self, u):
|
65 | 68 | #print("Step")
|
@@ -240,6 +243,16 @@ def obs_vision_to_image_rgb(self, obs_image_vec):
|
240 | 243 | return np.array(rgb, dtype=np.uint8)
|
241 | 244 |
|
242 | 245 | def make_observaton(self, raw_obs):
|
| 246 | + obs = [raw_obs['angle'], |
| 247 | + raw_obs['curLapTime'], |
| 248 | + raw_obs['damage'], |
| 249 | + raw_obs['speedX'], |
| 250 | + raw_obs['speedY'], |
| 251 | + raw_obs['speedZ'], |
| 252 | + raw_obs['trackPos'], |
| 253 | + raw_obs['wheelSpinVel'][0]] |
| 254 | + return np.array(obs) |
| 255 | + |
243 | 256 | if self.vision is False:
|
244 | 257 | names = ['focus',
|
245 | 258 | 'speedX', 'speedY', 'speedZ',
|
|
0 commit comments