Skip to content

Commit

Permalink
new flag to specify if episodes end when the robot collides with anot…
Browse files Browse the repository at this point in the history
…her entity
  • Loading branch information
pilarbachiller committed May 14, 2024
1 parent 68682c9 commit 9dc6ab1
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions environment_configs/exp1_no_sngnn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rendering:
episode:
episode_length: 200 # maximum steps in an episode
time_step: 1 # number of seconds that one step corresponds to
end_with_collision: True # episode end with collision

robot:
robot_radius: 0.25 # radius of the robot
Expand Down
1 change: 1 addition & 0 deletions environment_configs/exp1_with_sngnn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rendering:
episode:
episode_length: 200 # maximum steps in an episode
time_step: 1 # number of seconds that one step corresponds to
end_with_collision: True # episode end with collision

robot:
robot_radius: 0.25 # radius of the robot
Expand Down
1 change: 1 addition & 0 deletions environment_configs/exp2_no_sngnn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rendering:
episode:
episode_length: 200 # maximum steps in an episode
time_step: 1 # number of seconds that one step corresponds to
end_with_collision: True # episode end with collision

robot:
robot_radius: 0.25 # radius of the robot
Expand Down
1 change: 1 addition & 0 deletions environment_configs/exp2_with_sngnn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rendering:
episode:
episode_length: 200 # maximum steps in an episode
time_step: 1 # number of seconds that one step corresponds to
end_with_collision: True # episode end with collision

robot:
robot_radius: 0.25 # radius of the robot
Expand Down
1 change: 1 addition & 0 deletions environment_configs/exp3_no_sngnn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rendering:
episode:
episode_length: 200 # maximum steps in an episode
time_step: 1 # number of seconds that one step corresponds to
end_with_collision: True # episode end with collision

robot:
robot_radius: 0.25 # radius of the robot
Expand Down
1 change: 1 addition & 0 deletions environment_configs/exp3_with_sngnn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rendering:
episode:
episode_length: 200 # maximum steps in an episode
time_step: 1 # number of seconds that one step corresponds to
end_with_collision: True # episode end with collision

robot:
robot_radius: 0.25 # radius of the robot
Expand Down
1 change: 1 addition & 0 deletions environment_configs/exp4_no_sngnn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rendering:
episode:
episode_length: 200 # maximum steps in an episode
time_step: 1 # number of seconds that one step corresponds to
end_with_collision: True # episode end with collision

robot:
robot_radius: 0.25 # radius of the robot
Expand Down
1 change: 1 addition & 0 deletions environment_configs/exp4_with_sngnn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rendering:
episode:
episode_length: 200 # maximum steps in an episode
time_step: 1 # number of seconds that one step corresponds to
end_with_collision: True # episode end with collision

robot:
robot_radius: 0.25 # radius of the robot
Expand Down
1 change: 1 addition & 0 deletions environment_configs/test2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rendering:
episode:
episode_length: 200 # maximum steps in an episode
time_step: 1 # number of seconds that one step corresponds to
end_with_collision: True # episode end with collision

robot:
robot_radius: 0.7 # radius of the robot
Expand Down
1 change: 1 addition & 0 deletions environment_configs/test_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rendering:
episode:
episode_length: 200 # maximum steps in an episode
time_step: 1 # number of seconds that one step corresponds to
end_with_collision: True # episode end with collision

robot:
robot_radius: 0.7 # radius of the robot
Expand Down
9 changes: 7 additions & 2 deletions socnavgym/envs/socnavenv_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class SocNavEnv_v1(gym.Env):
# episode params
EPISODE_LENGTH = None
TIMESTEP = None
END_WITH_COLLISION = None

# rewards
REWARD_PATH = None
Expand Down Expand Up @@ -285,6 +286,7 @@ def _configure(self, config_path):
self.EPISODE_LENGTH = config["episode"]["episode_length"]
assert(self.EPISODE_LENGTH > 0), "episode length should be greater than 0"
self.TIMESTEP = config["episode"]["time_step"]
self.END_WITH_COLLISION = config["episode"]["end_with_collision"]

# robot
self.ROBOT_RADIUS = config["robot"]["robot_radius"]
Expand Down Expand Up @@ -2474,7 +2476,8 @@ def compute_reward_and_ticks(self, action):

# calculate the reward and record necessary information
if self.MAP_X/2 < self.robot.x or self.robot.x < -self.MAP_X/2 or self.MAP_Y/2 < self.robot.y or self.robot.y < -self.MAP_Y/2:
self._is_terminated = True
self._is_terminated = self._is_terminated or self.END_WITH_COLLISION
self._collision = True
info["OUT_OF_MAP"] = True

elif distance_to_goal < self.GOAL_THRESHOLD:
Expand All @@ -2483,7 +2486,8 @@ def compute_reward_and_ticks(self, action):
info["TIME_TO_REACH_GOAL"] = self.ticks * self.TIMESTEP

elif collision is True:
self._is_terminated = True
self._is_terminated = self._is_terminated or self.END_WITH_COLLISION
self._collision = True
info["COLLISION"] = True

if collision_human:
Expand Down Expand Up @@ -3357,6 +3361,7 @@ def try_reset(self, seed=None, options=None) :

self._is_terminated = False
self._is_truncated = False
self._collision = False
self.ticks = 0
self.compliant_count = 0 # keeps track of how many times the agent is outside the personal space of humans
self.prev_goal_distance = np.sqrt((self.robot.x - self.robot.goal_x)**2 + (self.robot.y - self.robot.goal_y)**2)
Expand Down

0 comments on commit 9dc6ab1

Please sign in to comment.