Skip to content

Commit

Permalink
Merge pull request #113 from f1tenth/fix_call_edt_only_once
Browse files Browse the repository at this point in the history
Fix call edt only once
  • Loading branch information
hzheng40 authored Feb 28, 2024
2 parents fa63eb8 + 34e61b3 commit be29da9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions gym/f110_gym/envs/laser_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ def __init__(self, num_beams, fov, eps=0.0001, theta_dis=2000, max_range=30.0):
self.map_height = None
self.map_width = None
self.map_resolution = None
self.track = None
self.map_img = None
self.origin = None
self.dt = None

# precomputing corresponding cosines and sines of the angle array
Expand All @@ -465,6 +468,9 @@ def set_map(self, map_name: str):
Returns:
flag (bool): if image reading and loading is successful
"""
if self.track and self.track.spec.name == map_name:
return True

self.track = Track.from_track_name(map_name)

# load map image
Expand Down
8 changes: 4 additions & 4 deletions tests/test_f110_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ def test_manual_reset_options_in_asynch_vec_env(self):
"num_agents": num_agents,
"observation_config": {"type": "kinematic_state"},
}
vec_env = gym.vector.make(
"f110_gym:f110-v0", asynchronous=True, config=config, num_envs=num_envs
vec_env = gym.make_vec(
"f110_gym:f110-v0", vectorization_mode="async", config=config, num_envs=num_envs
)

rnd_poses = np.random.random((2, 3))
Expand Down Expand Up @@ -219,8 +219,8 @@ def test_auto_reset_options_in_synch_vec_env(self):
"observation_config": {"type": "kinematic_state"},
"reset_config": {"type": "rl_random_random"},
}
vec_env = gym.vector.make(
"f110_gym:f110-v0", asynchronous=False, config=config, num_envs=num_envs
vec_env = gym.make_vec(
"f110_gym:f110-v0", vectorization_mode="sync", config=config, num_envs=num_envs,
)

obss, infos = vec_env.reset()
Expand Down

0 comments on commit be29da9

Please sign in to comment.