From 367d36762381e8948367acd3d0ec3b39f888e402 Mon Sep 17 00:00:00 2001 From: Luigi Berducci Date: Fri, 23 Feb 2024 11:09:51 +0100 Subject: [PATCH 1/2] avoid repeated call of edt for each agent --- gym/f110_gym/envs/laser_models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gym/f110_gym/envs/laser_models.py b/gym/f110_gym/envs/laser_models.py index 52aa296a..428d876b 100644 --- a/gym/f110_gym/envs/laser_models.py +++ b/gym/f110_gym/envs/laser_models.py @@ -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 @@ -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 From 34e61b3cb6ec49dd1448875c9cd02b3a8b4a60c6 Mon Sep 17 00:00:00 2001 From: Luigi Berducci Date: Fri, 23 Feb 2024 14:41:22 +0100 Subject: [PATCH 2/2] update deprecated gym.vector.make() to gym.make_vec() --- tests/test_f110_env.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_f110_env.py b/tests/test_f110_env.py index 053a2b20..0a2f5e9b 100644 --- a/tests/test_f110_env.py +++ b/tests/test_f110_env.py @@ -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)) @@ -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()