methode isAlive
Method def isAlive(self), which defaults to return self._alive < 0, and each environment can override this method (Half Cheetah would implement return False)
(In response to bea468fb93)
This commit is contained in:
committed by
GitHub
parent
a57c480f28
commit
292a3f1cf6
@@ -14,7 +14,6 @@ class WalkerBaseBulletEnv(MJCFBaseBulletEnv):
|
|||||||
self.walk_target_x = 1e3 # kilometer away
|
self.walk_target_x = 1e3 # kilometer away
|
||||||
self.walk_target_y = 0
|
self.walk_target_y = 0
|
||||||
self.stateId=-1
|
self.stateId=-1
|
||||||
self.alive = None
|
|
||||||
|
|
||||||
|
|
||||||
def create_single_player_scene(self, bullet_client):
|
def create_single_player_scene(self, bullet_client):
|
||||||
@@ -41,11 +40,8 @@ class WalkerBaseBulletEnv(MJCFBaseBulletEnv):
|
|||||||
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def _isDone(self):
|
def _isAlive(self):
|
||||||
if self._alive is not None:
|
return self._alive > 0
|
||||||
return self._alive < 0
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
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."
|
||||||
@@ -67,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
|
||||||
|
|
||||||
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
|
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 = self._isDone()
|
done = not self._isAlive()
|
||||||
if not np.isfinite(state).all():
|
if not np.isfinite(state).all():
|
||||||
print("~INF~", state)
|
print("~INF~", state)
|
||||||
done = True
|
done = True
|
||||||
@@ -96,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")
|
||||||
@@ -143,8 +139,8 @@ class HalfCheetahBulletEnv(WalkerBaseBulletEnv):
|
|||||||
self.robot = HalfCheetah()
|
self.robot = HalfCheetah()
|
||||||
WalkerBaseBulletEnv.__init__(self, self.robot)
|
WalkerBaseBulletEnv.__init__(self, self.robot)
|
||||||
|
|
||||||
def _isDone(self):
|
def _isAlive(self):
|
||||||
return False
|
return True
|
||||||
|
|
||||||
class AntBulletEnv(WalkerBaseBulletEnv):
|
class AntBulletEnv(WalkerBaseBulletEnv):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user