Remove duplicated episode_steps variable

This commit is contained in:
whikwon
2019-04-15 15:28:54 +09:00
parent 4ee5c07e61
commit 771de4f98e
3 changed files with 6 additions and 16 deletions
@@ -2,6 +2,7 @@ from math import pi
from geometry_msgs.msg import Quaternion
config = {
"ENV_NAME": "OpenManipulatorReacher",
"TERM_COUNT": 10,
@@ -41,7 +42,6 @@ config = {
"LOWER_Z": 0.116,
"ENV_MODE": "sim",
"TRAIN_MODE": True,
"MAX_EPISODE_STEPS": 100,
"DISTANCE_THRESHOLD": 0.1,
"REWARD_RESCALE_RATIO": 1.0,
"REWARD_FUNC": "l2",
@@ -33,7 +33,6 @@ class OpenManipulatorReacherEnv(gym.Env):
self.cfg = cfg
self.env_name = self.cfg["ENV_NAME"]
self.env_mode = self.cfg["ENV_MODE"]
self._max_episode_steps = self.cfg["MAX_EPISODE_STEPS"]
self.reward_rescale_ratio = self.cfg["REWARD_RESCALE_RATIO"]
self.reward_func = self.cfg["REWARD_FUNC"]
@@ -43,7 +42,6 @@ class OpenManipulatorReacherEnv(gym.Env):
else:
self.ros_interface = OpenManipulatorRosRealInterface()
self.episode_steps = 0
self.done = False
self.reward = 0
@@ -67,27 +65,19 @@ class OpenManipulatorReacherEnv(gym.Env):
Returns:
Tuple of obs, reward_rescale * reward, done
"""
if action is None:
action = np.array([1, 1, 1, 1, 1, 1])
self.done = False
if self.episode_steps == self._max_episode_steps:
self.done = True
self.episode_steps = 0
act = action.flatten().tolist()
self.ros_interface.set_joints_position(act)
if self.env_mode == "sim":
self.reward = self.compute_reward()
if self.ros_interface.check_for_termination():
print ("Terminates current Episode : OUT OF BOUNDARY")
self.done = True
elif self.ros_interface.check_for_success():
print ("Succeeded current Episode")
obs = self.ros_interface.get_observation()
self.done = True
self.episode_steps += 1
obs = self.ros_interface.get_observation()
return obs, self.reward_rescale_ratio * self.reward, self.done, None
@@ -287,7 +287,7 @@ class OpenManipulatorRosBaseInterface(object):
if dist < self.distance_threshold:
self.success_count += 1
if self.success_count == self.cfg["SUCCESS_COUNT"]:
self.done = True
print("Current episode succeeded")
self.success_count = 0
return True
else:
@@ -344,7 +344,7 @@ class OpenManipulatorRosBaseInterface(object):
rospy.logwarn("OUT OF BOUNDARY : joint_1_limit exceeds")
if self.termination_count == term_count:
self.done = True
print("Current episode terminated")
self.termination_count = 0
return True
else: