diff --git a/scripts/config/environment/open_manipulator.py b/scripts/config/environment/open_manipulator.py index 9af38f5..0567007 100755 --- a/scripts/config/environment/open_manipulator.py +++ b/scripts/config/environment/open_manipulator.py @@ -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", diff --git a/scripts/envs/open_manipulator/open_manipulator_reacher_env.py b/scripts/envs/open_manipulator/open_manipulator_reacher_env.py index 933ff66..2891fb4 100755 --- a/scripts/envs/open_manipulator/open_manipulator_reacher_env.py +++ b/scripts/envs/open_manipulator/open_manipulator_reacher_env.py @@ -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 diff --git a/scripts/envs/open_manipulator/ros_interface.py b/scripts/envs/open_manipulator/ros_interface.py index 2ca66a7..e0f8e02 100755 --- a/scripts/envs/open_manipulator/ros_interface.py +++ b/scripts/envs/open_manipulator/ros_interface.py @@ -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: