fixes in racecarGymEnv: implement 'render' rgb image, fix in naming,
fix in observation bounds.
This commit is contained in:
@@ -18,7 +18,7 @@ register(
|
|||||||
|
|
||||||
register(
|
register(
|
||||||
id='RacecarBulletEnv-v0',
|
id='RacecarBulletEnv-v0',
|
||||||
entry_point='pybullet_envs.bullet:RacecarBulletEnv',
|
entry_point='pybullet_envs.bullet:RacecarGymEnv',
|
||||||
timestep_limit=1000,
|
timestep_limit=1000,
|
||||||
reward_threshold=5.0,
|
reward_threshold=5.0,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ class RacecarGymEnv(gym.Env):
|
|||||||
observationDim = 2 #len(self.getExtendedObservation())
|
observationDim = 2 #len(self.getExtendedObservation())
|
||||||
#print("observationDim")
|
#print("observationDim")
|
||||||
#print(observationDim)
|
#print(observationDim)
|
||||||
observation_high = np.array([np.finfo(np.float32).max] * observationDim)
|
# observation_high = np.array([np.finfo(np.float32).max] * observationDim)
|
||||||
|
observation_high = np.ones(observationDim) * 1000 #np.inf
|
||||||
if (isDiscrete):
|
if (isDiscrete):
|
||||||
self.action_space = spaces.Discrete(9)
|
self.action_space = spaces.Discrete(9)
|
||||||
else:
|
else:
|
||||||
@@ -130,7 +131,19 @@ class RacecarGymEnv(gym.Env):
|
|||||||
return np.array(self._observation), reward, done, {}
|
return np.array(self._observation), reward, done, {}
|
||||||
|
|
||||||
def _render(self, mode='human', close=False):
|
def _render(self, mode='human', close=False):
|
||||||
return
|
width=320
|
||||||
|
height=200
|
||||||
|
img_arr = self._p.getCameraImage(width,height)
|
||||||
|
w=img_arr[0]
|
||||||
|
h=img_arr[1]
|
||||||
|
rgb=img_arr[2]
|
||||||
|
dep=img_arr[3]
|
||||||
|
#print 'width = %d height = %d' % (w,h)
|
||||||
|
# reshape creates np array
|
||||||
|
np_img_arr = np.reshape(rgb, (h, w, 4))
|
||||||
|
# remove alpha channel
|
||||||
|
np_img_arr = np_img_arr[:, :, :3]
|
||||||
|
return np_img_arr
|
||||||
|
|
||||||
def _termination(self):
|
def _termination(self):
|
||||||
return self._envStepCounter>1000
|
return self._envStepCounter>1000
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from baselines import deepq
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
env = RacecarGymEnv(renders=False,isDiscrete=True)
|
env = RacecarGymEnv(renders=True,isDiscrete=True)
|
||||||
act = deepq.load("racecar_model.pkl")
|
act = deepq.load("racecar_model.pkl")
|
||||||
print(act)
|
print(act)
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ parentdir = os.path.dirname(os.path.dirname(currentdir))
|
|||||||
os.sys.path.insert(0,parentdir)
|
os.sys.path.insert(0,parentdir)
|
||||||
|
|
||||||
from pybullet_envs.bullet.racecarGymEnv import RacecarGymEnv
|
from pybullet_envs.bullet.racecarGymEnv import RacecarGymEnv
|
||||||
isDiscrete = True
|
isDiscrete = False
|
||||||
|
|
||||||
environment = RacecarGymEnv(renders=True, isDiscrete=isDiscrete)
|
environment = RacecarGymEnv(renders=True, isDiscrete=isDiscrete)
|
||||||
environment.reset()
|
environment.reset()
|
||||||
|
|||||||
Reference in New Issue
Block a user