mirror of
https://github.com/wassname/kair_algorithms_draft.git
synced 2026-09-09 11:25:10 +08:00
Remove duplicated episode_steps variable
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user