Merge pull request #1762 from alexis-jacq/patch-2
isAlive method forcing done=False for halfcheetah
This commit is contained in:
@@ -40,6 +40,9 @@ class WalkerBaseBulletEnv(MJCFBaseBulletEnv):
|
|||||||
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
def _isDone(self):
|
||||||
|
return self._alive < 0
|
||||||
|
|
||||||
def move_robot(self, init_x, init_y, init_z):
|
def move_robot(self, init_x, init_y, init_z):
|
||||||
"Used by multiplayer stadium to move sideways, to another running lane."
|
"Used by multiplayer stadium to move sideways, to another running lane."
|
||||||
self.cpp_robot.query_position()
|
self.cpp_robot.query_position()
|
||||||
@@ -60,8 +63,8 @@ class WalkerBaseBulletEnv(MJCFBaseBulletEnv):
|
|||||||
|
|
||||||
state = self.robot.calc_state() # also calculates self.joints_at_limit
|
state = self.robot.calc_state() # also calculates self.joints_at_limit
|
||||||
|
|
||||||
alive = float(self.robot.alive_bonus(state[0]+self.robot.initial_z, self.robot.body_rpy[1])) # state[0] is body height above ground, body_rpy[1] is pitch
|
self._alive = float(self.robot.alive_bonus(state[0]+self.robot.initial_z, self.robot.body_rpy[1])) # state[0] is body height above ground, body_rpy[1] is pitch
|
||||||
done = alive < 0
|
done = self._isDone()
|
||||||
if not np.isfinite(state).all():
|
if not np.isfinite(state).all():
|
||||||
print("~INF~", state)
|
print("~INF~", state)
|
||||||
done = True
|
done = True
|
||||||
@@ -89,7 +92,7 @@ class WalkerBaseBulletEnv(MJCFBaseBulletEnv):
|
|||||||
debugmode=0
|
debugmode=0
|
||||||
if(debugmode):
|
if(debugmode):
|
||||||
print("alive=")
|
print("alive=")
|
||||||
print(alive)
|
print(self._alive)
|
||||||
print("progress")
|
print("progress")
|
||||||
print(progress)
|
print(progress)
|
||||||
print("electricity_cost")
|
print("electricity_cost")
|
||||||
@@ -100,7 +103,7 @@ class WalkerBaseBulletEnv(MJCFBaseBulletEnv):
|
|||||||
print(feet_collision_cost)
|
print(feet_collision_cost)
|
||||||
|
|
||||||
self.rewards = [
|
self.rewards = [
|
||||||
alive,
|
self._alive,
|
||||||
progress,
|
progress,
|
||||||
electricity_cost,
|
electricity_cost,
|
||||||
joints_at_limit_cost,
|
joints_at_limit_cost,
|
||||||
@@ -136,6 +139,9 @@ class HalfCheetahBulletEnv(WalkerBaseBulletEnv):
|
|||||||
self.robot = HalfCheetah()
|
self.robot = HalfCheetah()
|
||||||
WalkerBaseBulletEnv.__init__(self, self.robot)
|
WalkerBaseBulletEnv.__init__(self, self.robot)
|
||||||
|
|
||||||
|
def _isDone(self):
|
||||||
|
return False
|
||||||
|
|
||||||
class AntBulletEnv(WalkerBaseBulletEnv):
|
class AntBulletEnv(WalkerBaseBulletEnv):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.robot = Ant()
|
self.robot = Ant()
|
||||||
@@ -172,4 +178,3 @@ class HumanoidFlagrunHarderBulletEnv(HumanoidBulletEnv):
|
|||||||
s = HumanoidBulletEnv.create_single_player_scene(self, bullet_client)
|
s = HumanoidBulletEnv.create_single_player_scene(self, bullet_client)
|
||||||
s.zero_at_running_strip_start_line = False
|
s.zero_at_running_strip_start_line = False
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user